75 lines
2.2 KiB
Java
75 lines
2.2 KiB
Java
package nl.iobyte.themepark;
|
|
|
|
import nl.iobyte.menuapi.MenuAPI;
|
|
import nl.iobyte.themepark.api.ThemeParkAPI;
|
|
import nl.iobyte.themepark.commands.ThemeParkCommand;
|
|
import nl.iobyte.themepark.listeners.*;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.plugin.Plugin;
|
|
import org.bukkit.plugin.PluginManager;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
import java.lang.reflect.Method;
|
|
|
|
public class ThemePark extends JavaPlugin {
|
|
|
|
private static ThemePark instance;
|
|
private final ThemeParkAPI api = new ThemeParkAPI();
|
|
private boolean disabling = false;
|
|
|
|
public void onEnable() {
|
|
instance = this;
|
|
api.enable();
|
|
loadCommands();
|
|
loadListeners();
|
|
loadTrainCarts();
|
|
}
|
|
|
|
private void loadCommands() {
|
|
new ThemeParkCommand();
|
|
}
|
|
|
|
private void loadListeners() {
|
|
PluginManager pm = Bukkit.getPluginManager();
|
|
pm.registerEvents(new PlayerListener(), this);
|
|
pm.registerEvents(new RegionListener(), this);
|
|
pm.registerEvents(new AttractionListener(), this);
|
|
pm.registerEvents(new StatusListener(), this);
|
|
pm.registerEvents(new RideCountListener(), this);
|
|
pm.registerEvents(new StatusSignListener(), this);
|
|
pm.registerEvents(new GeneralListener(), this);
|
|
MenuAPI.register(this);
|
|
}
|
|
|
|
private void loadTrainCarts() {
|
|
try {
|
|
Plugin plugin = Bukkit.getPluginManager().getPlugin("Train_Carts");
|
|
if (plugin != null && plugin.isEnabled()) {
|
|
Class<?> clazz = Class.forName("com.bergerkiller.bukkit.tc.signactions.SignAction");
|
|
Class<?> sign = Class.forName("nl.iobyte.themepark.traincarts.RideCountSign");
|
|
Method method = clazz.getMethod("register", clazz);
|
|
method.invoke(clazz, sign.newInstance());
|
|
}
|
|
} catch (Exception e) {
|
|
System.out.println("["+getName()+"] Unable to hook into TrainCarts");
|
|
}
|
|
}
|
|
|
|
public void onDisable() {
|
|
disabling = true;
|
|
api.disable();
|
|
|
|
instance = null;
|
|
}
|
|
|
|
public static ThemePark getInstance() {
|
|
return instance;
|
|
}
|
|
|
|
public ThemeParkAPI getAPI() {
|
|
return api;
|
|
}
|
|
|
|
public boolean isDisabling() {
|
|
return disabling;
|
|
}
|
|
}
|