Java (Spigot/Bukkit) несколько классовJAVA

Программисты JAVA общаются здесь
Гость
Java (Spigot/Bukkit) несколько классов

Сообщение Гость »


У меня есть основной класс Main.java (метод onEnable)
и еще 3.
в Main.java я регистрирую другие классы так:

Код: Выделить всё

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.


Источник: https://stackoverflow.com/questions/774 ... le-classes

Вернуться в «JAVA»