Boosters/plugin/src/main/java/com/alttd/boosters/BoostersPlugin.java

66 lines
2.1 KiB
Java
Raw Normal View History

2021-09-06 17:35:04 +00:00
package com.alttd.boosters;
2021-12-25 17:05:07 +00:00
import com.alttd.boosterapi.BoosterAPI;
import com.alttd.boosterapi.BoosterImplementation;
import com.alttd.boosterapi.config.Config;
import com.alttd.boosters.listeners.MCmmoListener;
import com.alttd.boosters.listeners.MyPetListener;
import com.alttd.boosters.listeners.PhantomSpawnListener;
import com.alttd.boosters.listeners.PluginMessage;
import com.alttd.boosters.managers.BoosterManager;
2021-09-06 17:35:04 +00:00
import org.bukkit.command.CommandExecutor;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public final class BoostersPlugin extends JavaPlugin {
private static BoostersPlugin instance;
private static BoosterAPI boosterAPI;
2021-12-25 17:05:07 +00:00
private static BoosterManager boosterManager;
2021-09-06 17:35:04 +00:00
@Override
public void onEnable() {
instance = this;
2021-12-25 17:05:07 +00:00
boosterAPI = new BoosterImplementation();
boosterManager = new BoosterManager();
if (getServer().getPluginManager().isPluginEnabled("MyPet")) {
registerListener(new MyPetListener());
}
if (getServer().getPluginManager().isPluginEnabled("mcMMO")) {
registerListener(new MCmmoListener());
}
registerListener(new PhantomSpawnListener());
getServer().getMessenger().registerOutgoingPluginChannel(this, Config.pluginMessageChannel);
getServer().getMessenger().registerIncomingPluginChannel(this, Config.pluginMessageChannel, new PluginMessage());
2021-09-06 17:35:04 +00:00
}
@Override
public void onDisable() {
2021-12-25 17:05:07 +00:00
instance = null;
boosterAPI = null;
2021-09-06 17:35:04 +00:00
}
public void registerListener(Listener... listeners) {
for (Listener listener : listeners) {
getServer().getPluginManager().registerEvents(listener, this);
}
}
public void registerCommand(String commandName, CommandExecutor CommandExecutor) {
getCommand(commandName).setExecutor(CommandExecutor);
}
public static BoostersPlugin getInstance() {
return instance;
}
public BoosterAPI getAPI() {
return boosterAPI;
}
2021-12-25 17:05:07 +00:00
public BoosterManager getBoosterManager() {
return boosterManager;
}
2021-09-06 17:35:04 +00:00
}