fillr -> plugin

By: Taylor Kelly <tkelly910@gmail.com>
This commit is contained in:
Bukkit/Spigot 2011-01-03 12:06:36 +08:00
parent 7f5bbdf764
commit a57c79eb6f
2 changed files with 25 additions and 56 deletions

View file

@ -1,67 +1,31 @@
package org.bukkit.fillr; 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; import java.util.logging.Logger;
public class Fillr { public class Fillr extends JavaPlugin {
private Logger log; private Logger log;
private String name = "Fillr"; private FillrListener listener;
public static String name = "Fillr";
public static String version = "1.0"; public static String version = "1.0";
public Server server;
private static Fillr singleton;
public static String directory = "plugins"; public static String directory = "plugins";
private Fillr(Server server) { public Fillr(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File plugin, ClassLoader cLoader) {
this.server = server; super(pluginLoader, instance, desc, plugin, cLoader);
registerEvents();
} }
public Fillr createInstance(Server server) { public void onDisable() {}
singleton = new Fillr(server); public void onEnable() {}
return singleton;
public void registerEvents() {
listener = new FillrListener(this.getServer());
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, listener, Event.Priority.Normal, this);
} }
public static Fillr getInstance() {
return singleton;
}
//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 <name>");
} 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 <name>");
} else {
try {
new Downloader().downloadFile(split[1], player);
} catch(Exception e) {
player.sendMessage("There was an error downloading "+ split[1]);
}
}
return true;
}
return false;
}
}*/
} }

View file

@ -10,6 +10,11 @@ import java.util.jar.*;
public class Updater { public class Updater {
public static String directory = Fillr.directory; 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 * Checks and updates the plugins with updatr files
@ -88,7 +93,7 @@ public class Updater {
//TODO again with the implicit jar support... //TODO again with the implicit jar support...
File plugin = new File(directory, name + ".jar"); File plugin = new File(directory, name + ".jar");
try { try {
Fillr.getInstance().server.getPluginManager().loadPlugin(plugin); server.getPluginManager().loadPlugin(plugin);
} catch (InvalidPluginException e) { } catch (InvalidPluginException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -96,7 +101,7 @@ public class Updater {
private void disablePlugin(FillReader update) { private void disablePlugin(FillReader update) {
String name = update.getName(); String name = update.getName();
Plugin plugin = Fillr.getInstance().server.getPluginManager().getPlugin(name); Plugin plugin = server.getPluginManager().getPlugin(name);
Fillr.getInstance().server.getPluginManager().disablePlugin(plugin); server.getPluginManager().disablePlugin(plugin);
} }
} }