Basic Permission Check

Discussion in 'Plugin Development' started by Taemera, Aug 5, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Taemera

    As the permissions 3.1.x API reference said, I used
    Code:
      if (!(MyPlugin).permissionHandler.has(player, "a.custom.node")) {
    
          return;
      }
    However, Eclipse tells me that "MyPlugin cannot be resolved to a variable".
    What do I need to do?
     
  2. Offline

    nisovin

    You're supposed to fill that in with a reference to your plugin, not just directly copy and paste the code.
     
  3. Offline

    Taemera

    Yes, I know, I changed it to Combust, but it still displays the message: "Combust cannot be resolved to a variable".
     
  4. Offline

    Nitnelave

    No, not a reference to the class, but to the instance. If you're running it from the main class, you don't need the (MyPlugin). part, or you could replace it with (this). Otherwise, you have to have a reference to your main plugin (like a plugin variable in the class, initiated at the constructor).
     
  5. Offline

    masteroftime

    You need to put a variable there not your class name.

    if you access it from your main class then you simply insert this
    if you want to access it from outside you have to pass it a VARIABLE storing your main plugin object.

    Code:
    public class SomeClass
    {
        Combust plugin;
    
        public SomeClass(Combust plugin)
        {
            this.plugin = plugin;
        }
    
        public void someMethod()
        {
            if(!plugin.permissionHandler.has(player, "a.custom.node")
            ...
        }
    }
     
  6. Offline

    Nitnelave

    It's ok, it should be fixed. He needed to call it from the main class, so just removing (MyPlugin) did the trick.
     
  7. Offline

    Taemera

Thread Status:
Not open for further replies.

Share This Page