public class Main extends JavaPlugin implements Listener
{
public static Economy econ;
public static Main instance;
static {
Main.econ = null;
}
public void onEnable() {
Bukkit.getServer().getLogger().info("enabled!");
Main.instance = this;
if (!this.setupEconomy()) {
Bukkit.getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", this.getDescription().getName()));
this.getServer().getPluginManager().disablePlugin(this);
return;
}
Bukkit.getPluginManager().registerEvents(this, this);
}
public void onDisable() {
Bukkit.getServer().getLogger().info("disabled!");
}
private boolean setupEconomy() {
if (this.getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
final RegisteredServiceProvider rsp = this.getServer().getServicesManager().getRegistration((Class)Economy.class);
if (rsp == null) {
return false;
}
Main.econ = (Economy)rsp.getProvider();
return Main.econ != null;
}
}