How does i get a Plugin (org.bukkit.plugin) variable?

I need this to create an attachment and add a permission to a player

That’s your main plugin class. It extends JavaPlugin which extends Plugin

When i try “mainclass.getPlugin();” i get this: ‘getPlugin(java.lang.@org.jetbrains.annotations.NotNull Class)’ in ‘’ cannot be applied to ‘()’

I’m talking about the instance of your main class. The one that would be referenced using the “this” keyword if you are in your main class.

Im in another class

Well then you need to pass the instance of your main plugin through the constructor of your other class, or through a method, or have a static method on your main class you return a static field on your main class you set to this in the onEnable method.

1 Like