I have my main class Main.java (onEnable method) and 3 others.
in Main.java I'm registering other classes so:
new Example(this);
new Shop(this);
new Info(this);
and in the classes themselves, I use this construction:
public class Shop implements Listener {
private final JavaPlugin plugin;
public Shop(JavaPlugin plugin) {
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
The gist of the question: I read somewhere that you can avoid writing class registration in the main method (because it takes up a lot of space and makes the code unreadable) How to get rid of
new Example(this);
new Shop(this);
new Info(this);
I've tried plugin = this; But it's not working.
Personally I'd do