Removed the server listener to fetch the enabling and disabling of
plugins. Dropped issue #5.
This commit is contained in:
@@ -40,9 +40,9 @@ public class Settings {
|
|||||||
conf.load();
|
conf.load();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
conf.setProperty("options.webserver-enabled", false);
|
conf.setProperty("options.webserver-enabled", true);
|
||||||
conf.setProperty("options.webserver-port", 9123);
|
conf.setProperty("options.webserver-port", 9123);
|
||||||
conf.setProperty("options.verbose-enabled", false);
|
conf.setProperty("options.verbose-enabled", true);
|
||||||
conf.save();
|
conf.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,14 +75,10 @@ public class XmlStats extends JavaPlugin {
|
|||||||
LogDebug("Settings read:");
|
LogDebug("Settings read:");
|
||||||
LogDebug("options.webserver-enabled: "+settingsTemp.getBoolean("options.webserver-enabled"));
|
LogDebug("options.webserver-enabled: "+settingsTemp.getBoolean("options.webserver-enabled"));
|
||||||
LogDebug("options.webserver-port: "+settingsTemp.getInt("options.webserver-port"));
|
LogDebug("options.webserver-port: "+settingsTemp.getInt("options.webserver-port"));
|
||||||
LogDebug("options.gzip-enabled: "+settingsTemp.getBoolean("options.gzip-enabled"));
|
|
||||||
LogDebug("options.verbose-enabled: "+settingsTemp.getBoolean("options.verbose-enabled"));
|
LogDebug("options.verbose-enabled: "+settingsTemp.getBoolean("options.verbose-enabled"));
|
||||||
|
|
||||||
this.hookPlugins();
|
this.hookPlugins();
|
||||||
|
|
||||||
this.registerEvents();
|
|
||||||
|
|
||||||
|
|
||||||
if (settingsTemp.getBoolean("options.webserver-enabled")){
|
if (settingsTemp.getBoolean("options.webserver-enabled")){
|
||||||
try {
|
try {
|
||||||
XmlStatsRegistry.put("webserver", new Webserver());
|
XmlStatsRegistry.put("webserver", new Webserver());
|
||||||
@@ -197,27 +193,22 @@ public class XmlStats extends JavaPlugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Register events.
|
|
||||||
*/
|
|
||||||
private void registerEvents(){
|
|
||||||
XmlStatsServerListener listener = new XmlStatsServerListener(this);
|
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, listener, Priority.Monitor, this);
|
|
||||||
getServer().getPluginManager().registerEvent(Type.PLUGIN_DISABLE, listener, Priority.Monitor, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.bukkit.plugin.java.JavaPlugin#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
* @see org.bukkit.plugin.java.JavaPlugin#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||||
*/
|
*/
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
|
||||||
|
|
||||||
if(commandLabel.equalsIgnoreCase("xmlstats")){
|
if(commandLabel.equalsIgnoreCase("xmlstats")){
|
||||||
if(sender.isOp() && args.length == 1 && args[0].equalsIgnoreCase("reload")){
|
if(sender.isOp()){
|
||||||
sender.sendMessage("Reloading the XmlStats plugin...");
|
if (args.length == 1 && args[0].equalsIgnoreCase("reload")){
|
||||||
LogInfo("Reloading the XmlStats plugin...");
|
sender.sendMessage("Reloading the XmlStats plugin...");
|
||||||
this.reload();
|
LogInfo("Reloading the XmlStats plugin...");
|
||||||
return true;
|
this.reload();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage("You don't have the permission to do this!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +218,7 @@ public class XmlStats extends JavaPlugin {
|
|||||||
/**
|
/**
|
||||||
* Reload.
|
* Reload.
|
||||||
*/
|
*/
|
||||||
private void reload() {
|
protected void reload() {
|
||||||
this.onDisable();
|
this.onDisable();
|
||||||
this.onEnable();
|
this.onEnable();
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package de.sockenklaus.XmlStats;
|
|
||||||
|
|
||||||
import org.bukkit.event.server.PluginDisableEvent;
|
|
||||||
import org.bukkit.event.server.PluginEnableEvent;
|
|
||||||
import org.bukkit.event.server.ServerListener;
|
|
||||||
|
|
||||||
import com.iConomy.iConomy;
|
|
||||||
import com.nidefawl.Stats.Stats;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author socrates
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class XmlStatsServerListener extends ServerListener {
|
|
||||||
private XmlStats plugin;
|
|
||||||
|
|
||||||
public XmlStatsServerListener(XmlStats plugin){
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPluginDisable(PluginDisableEvent event){
|
|
||||||
iConomy iConomy = (iConomy)XmlStatsRegistry.get("iconomy");
|
|
||||||
Stats Stats = (Stats)XmlStatsRegistry.get("stats");
|
|
||||||
|
|
||||||
if(iConomy != null){
|
|
||||||
if(event.getPlugin().getDescription().getName().equals("iConomy")){
|
|
||||||
iConomy = null;
|
|
||||||
XmlStats.LogInfo("iConomy is disabled now. Unhooking.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Stats != null){
|
|
||||||
if(event.getPlugin().getDescription().getName().equals("Stats")){
|
|
||||||
Stats = null;
|
|
||||||
XmlStats.LogInfo("Stats is disabled now. Unhooking.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPluginEnable(PluginEnableEvent event){
|
|
||||||
plugin.hookPlugins();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user