2021-09-24 23:56:42 +00:00
|
|
|
package com.alttd;
|
|
|
|
|
|
|
|
|
|
import com.alttd.GUI.GUIListener;
|
|
|
|
|
import com.alttd.commands.CommandManager;
|
2021-11-03 13:35:53 +00:00
|
|
|
import com.alttd.commands.database.Database;
|
2021-09-24 23:56:42 +00:00
|
|
|
import com.alttd.config.Config;
|
|
|
|
|
import com.alttd.config.VillagerConfig;
|
|
|
|
|
import com.alttd.config.WorthConfig;
|
|
|
|
|
import com.alttd.events.VillagerInteract;
|
2021-11-03 15:54:12 +00:00
|
|
|
import com.alttd.util.Logger;
|
2021-11-07 17:10:50 +00:00
|
|
|
import net.milkbowl.vault.economy.Economy;
|
|
|
|
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
2021-09-24 23:56:42 +00:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
|
|
|
|
|
public class VillagerUI extends JavaPlugin {
|
|
|
|
|
|
|
|
|
|
public static VillagerUI instance;
|
2021-11-07 17:10:50 +00:00
|
|
|
private static Economy econ = null;
|
2021-09-24 23:56:42 +00:00
|
|
|
|
|
|
|
|
public static VillagerUI getInstance() {
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-07 17:10:50 +00:00
|
|
|
public static Economy getEcon() {
|
|
|
|
|
return econ;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-24 23:56:42 +00:00
|
|
|
@Override
|
|
|
|
|
public void onLoad() {
|
|
|
|
|
instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onEnable() {
|
|
|
|
|
registerEvents();
|
|
|
|
|
new CommandManager();
|
|
|
|
|
Config.reload();
|
|
|
|
|
VillagerConfig.reload();
|
|
|
|
|
WorthConfig.reload();
|
2021-11-07 17:10:50 +00:00
|
|
|
if (!setupEconomy()) {
|
|
|
|
|
Logger.severe("% - Unable to find vault", getDescription().getName());
|
|
|
|
|
getServer().getPluginManager().disablePlugin(this);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-11-03 13:35:53 +00:00
|
|
|
Database.init();
|
2021-11-03 15:54:12 +00:00
|
|
|
Logger.info("--------------------------------------------------");
|
|
|
|
|
Logger.info("Villager UI started");
|
|
|
|
|
Logger.info("--------------------------------------------------");
|
2021-09-24 23:56:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void registerEvents() {
|
|
|
|
|
getServer().getPluginManager().registerEvents(new GUIListener(), this);
|
|
|
|
|
getServer().getPluginManager().registerEvents(new VillagerInteract(), this);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-07 17:10:50 +00:00
|
|
|
private boolean setupEconomy() {
|
|
|
|
|
if (getServer().getPluginManager().getPlugin("Vault") == null) return false;
|
|
|
|
|
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
|
|
|
|
if (rsp == null) return false;
|
|
|
|
|
econ = rsp.getProvider();
|
|
|
|
|
|
|
|
|
|
return econ != null;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-24 23:56:42 +00:00
|
|
|
}
|