Soulbound/src/main/java/com/me/tft_02/soulbound/Soulbound.java

139 lines
3.6 KiB
Java

package com.me.tft_02.soulbound;
import java.io.File;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import com.me.tft_02.soulbound.commands.BindCommand;
import com.me.tft_02.soulbound.commands.BindOnEquipCommand;
import com.me.tft_02.soulbound.commands.BindOnPickupCommand;
import com.me.tft_02.soulbound.commands.BindOnUseCommand;
import com.me.tft_02.soulbound.commands.SoulboundCommand;
import com.me.tft_02.soulbound.commands.UnbindCommand;
import com.me.tft_02.soulbound.config.Config;
import com.me.tft_02.soulbound.config.ItemsConfig;
import com.me.tft_02.soulbound.hooks.EpicBossRecodedListener;
import com.me.tft_02.soulbound.listeners.BlockListener;
import com.me.tft_02.soulbound.listeners.EntityListener;
import com.me.tft_02.soulbound.listeners.InventoryListener;
import com.me.tft_02.soulbound.listeners.PlayerListener;
import com.me.tft_02.soulbound.util.LogFilter;
import cn.citycraft.PluginHelper.config.FileConfig;
import cn.citycraft.PluginHelper.utils.VersionChecker;
public class Soulbound extends JavaPlugin {
/* File Paths */
private static String mainDirectory;
public static Soulbound p;
// Jar Stuff
public static File soulbound;
// Checks for hooking into other plugins
public static boolean epicBossRecodedEnabled = false;
public static boolean loreLocksEnabled = false;
FileConfig msgcfg;
FileConfig config;
// Update Check
private boolean updateAvailable;
public static String getMainDirectory() {
return mainDirectory;
}
public void debug(final String message) {
getLogger().info("[Debug] " + message);
}
@Override
public FileConfiguration getConfig() {
return config;
}
public String getlang(final String type) {
return this.getmessage("Message." + type);
}
public String getmessage(final String path) {
final String message = msgcfg.getMessage(path);
return message;
}
public boolean isUpdateAvailable() {
return updateAvailable;
}
/**
* Run things on enable.
*/
@Override
public void onEnable() {
p = this;
getLogger().setFilter(new LogFilter(this));
setupFilePaths();
loadConfigFiles();
setupEpicBossRecoded();
registerEvents();
getCommand("soulbound").setExecutor(new SoulboundCommand());
getCommand("bind").setExecutor(new BindCommand());
getCommand("bindonpickup").setExecutor(new BindOnPickupCommand());
getCommand("bindonuse").setExecutor(new BindOnUseCommand());
getCommand("bindonequip").setExecutor(new BindOnEquipCommand());
getCommand("unbind").setExecutor(new UnbindCommand());
new VersionChecker(this);
}
@Override
public void onLoad() {
msgcfg = new FileConfig(this, "message.yml");
config = new FileConfig(this);
}
@Override
public void reloadConfig() {
msgcfg.reload();
config.reload();
}
private void loadConfigFiles() {
Config.getInstance();
ItemsConfig.getInstance();
}
private void registerEvents() {
final PluginManager pm = getServer().getPluginManager();
pm.registerEvents(new PlayerListener(), this);
pm.registerEvents(new InventoryListener(), this);
pm.registerEvents(new EntityListener(), this);
pm.registerEvents(new BlockListener(), this);
}
private void setupEpicBossRecoded() {
if (getServer().getPluginManager().isPluginEnabled("EpicBossRecoded")) {
epicBossRecodedEnabled = true;
debug("EpicBossRecoded found!");
getServer().getPluginManager().registerEvents(new EpicBossRecodedListener(), this);
}
}
/**
* Setup the various storage file paths
*/
private void setupFilePaths() {
soulbound = getFile();
mainDirectory = getDataFolder().getPath() + File.separator;
}
}