diff --git a/paper-api/src/main/java/org/bukkit/fillr/Fillr.java b/paper-api/src/main/java/org/bukkit/fillr/Fillr.java index c2928a47e5..1f935f6cfb 100644 --- a/paper-api/src/main/java/org/bukkit/fillr/Fillr.java +++ b/paper-api/src/main/java/org/bukkit/fillr/Fillr.java @@ -1,67 +1,31 @@ package org.bukkit.fillr; -import org.bukkit.*; +import org.bukkit.*; +import org.bukkit.plugin.*; +import org.bukkit.plugin.java.*; +import org.bukkit.event.*; + +import java.io.File; import java.util.logging.Logger; -public class Fillr { +public class Fillr extends JavaPlugin { private Logger log; - private String name = "Fillr"; + private FillrListener listener; + public static String name = "Fillr"; public static String version = "1.0"; - public Server server; - private static Fillr singleton; public static String directory = "plugins"; - private Fillr(Server server) { - this.server = server; + public Fillr(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File plugin, ClassLoader cLoader) { + super(pluginLoader, instance, desc, plugin, cLoader); + registerEvents(); } - public Fillr createInstance(Server server) { - singleton = new Fillr(server); - return singleton; - } + public void onDisable() {} + public void onEnable() {} - public static Fillr getInstance() { - return singleton; + public void registerEvents() { + listener = new FillrListener(this.getServer()); + getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, listener, Event.Priority.Normal, this); } - - //TODO Get command hooks in somehow... - /*public class UpdatrListener extends PluginListener { - public boolean onCommand(Player player, String[] split) { - if (split[0].equalsIgnoreCase("/check") - && player.canUseCommand("/check")) { - new Checker().check(player); - return true; - } - if (split[0].equalsIgnoreCase("/updateAll") - && player.canUseCommand("/updateAll")) { - new Updater().updateAll(player); - return true; - } - if (split[0].equalsIgnoreCase("/update") - && player.canUseCommand("/update")) { - if (split.length == 1) { - player.sendMessage(premessage + "Usage is /update "); - } else { - new Updater().update(split[1], player); - } - return true; - } - if (split[0].equalsIgnoreCase("/download") - && player.canUseCommand("/download")) { - if (split.length == 1) { - player.sendMessage(premessage + "Usage is /download "); - } else { - try { - new Downloader().downloadFile(split[1], player); - } catch(Exception e) { - player.sendMessage("There was an error downloading "+ split[1]); - } - } - return true; - } - - return false; - } - }*/ } diff --git a/paper-api/src/main/java/org/bukkit/fillr/Updater.java b/paper-api/src/main/java/org/bukkit/fillr/Updater.java index 8af2148116..befcc84892 100644 --- a/paper-api/src/main/java/org/bukkit/fillr/Updater.java +++ b/paper-api/src/main/java/org/bukkit/fillr/Updater.java @@ -10,6 +10,11 @@ import java.util.jar.*; public class Updater { public static String directory = Fillr.directory; + private final Server server; + + public Updater(Server server) { + this.server = server; + } /** * Checks and updates the plugins with updatr files @@ -88,7 +93,7 @@ public class Updater { //TODO again with the implicit jar support... File plugin = new File(directory, name + ".jar"); try { - Fillr.getInstance().server.getPluginManager().loadPlugin(plugin); + server.getPluginManager().loadPlugin(plugin); } catch (InvalidPluginException e) { e.printStackTrace(); } @@ -96,7 +101,7 @@ public class Updater { private void disablePlugin(FillReader update) { String name = update.getName(); - Plugin plugin = Fillr.getInstance().server.getPluginManager().getPlugin(name); - Fillr.getInstance().server.getPluginManager().disablePlugin(plugin); + Plugin plugin = server.getPluginManager().getPlugin(name); + server.getPluginManager().disablePlugin(plugin); } } \ No newline at end of file