From 54b81b2dccd7cfa58e5bd5fe95a158126115381c Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Mon, 25 Apr 2022 18:33:18 +0200 Subject: Initial commit --- src/com/encrox/cplot/Core.java | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 src/com/encrox/cplot/Core.java (limited to 'src/com/encrox/cplot/Core.java') diff --git a/src/com/encrox/cplot/Core.java b/src/com/encrox/cplot/Core.java new file mode 100755 index 0000000..4d361c7 --- /dev/null +++ b/src/com/encrox/cplot/Core.java @@ -0,0 +1,65 @@ +package com.encrox.cplot; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.Properties; +import java.util.logging.Logger; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.RegisteredServiceProvider; +import org.bukkit.plugin.java.JavaPlugin; + +import com.earth2me.essentials.api.Economy; +import com.encrox.cplot.command.Gs; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; + +public class Core extends JavaPlugin { + + public static Logger logger; + public static PluginDescriptionFile pdf; + public static WorldGuardPlugin wg; + public static WorldEditPlugin we; + public static Properties p; + + public void onEnable() { + pdf = getDescription(); + logger = Logger.getLogger("Minecraft"); + if(setupMyself() && setupWorldGuard()) { + getCommand("gs").setExecutor(new Gs()); + logger.info(pdf.getName() + " " + pdf.getVersion() + " has been enabled."); + } else { + logger.info(pdf.getName() + " " + pdf.getVersion() + " has been disabled."); + } + } + + public boolean setupWorldGuard() { + wg = (WorldGuardPlugin) Bukkit.getPluginManager().getPlugin("WorldGuard"); + we = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"); + return (wg != null) && (we != null); + } + + public boolean setupMyself() { + if(!this.getDataFolder().exists()) + this.getDataFolder().mkdirs(); + p = new Properties(); + try { + p.load(new FileReader(new File(this.getDataFolder() + "/config.properties"))); + } catch (FileNotFoundException e) { + e.printStackTrace(); + return false; + } catch (IOException e) { + e.printStackTrace(); + return false; + } + return true; + } + + public void onDisable() { + logger.info(pdf.getName() + " " + pdf.getVersion() + " has been disabled."); + } + +} -- cgit v1.2.1