Added a command to manually reload the plugin and therefore solved issue
#4.
This commit is contained in:
@@ -10,6 +10,14 @@ To install the plugin, simply place the compiled **XmlStats.jar** in your server
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
### Game side
|
||||||
|
|
||||||
|
At this time of the development you are only able to reload the plugin without reloading the whole server:
|
||||||
|
|
||||||
|
/xmlstats reload
|
||||||
|
|
||||||
|
### Browser side
|
||||||
|
|
||||||
Afterwards you can access the following xml files:
|
Afterwards you can access the following xml files:
|
||||||
|
|
||||||
For a list of all known players on your server:
|
For a list of all known players on your server:
|
||||||
|
|||||||
18
build.xml
18
build.xml
@@ -8,6 +8,7 @@
|
|||||||
<property name="version" value="0.1" />
|
<property name="version" value="0.1" />
|
||||||
<property name="package" value="de/sockenklaus/XmlStats" />
|
<property name="package" value="de/sockenklaus/XmlStats" />
|
||||||
<property name="resources" value="resources" />
|
<property name="resources" value="resources" />
|
||||||
|
<property name="author" value="sockenklaus" />
|
||||||
|
|
||||||
<path id="classpath">
|
<path id="classpath">
|
||||||
<pathelement location="lib/" />
|
<pathelement location="lib/" />
|
||||||
@@ -20,17 +21,18 @@
|
|||||||
|
|
||||||
<!-- Build a jar file -->
|
<!-- Build a jar file -->
|
||||||
<target name="jar" depends="compile">
|
<target name="jar" depends="compile">
|
||||||
|
<copy file="${resources}/plugin.yml" tofile="${bin}/plugin.yml">
|
||||||
|
<filterchain>
|
||||||
<!-- this is some ugly plugin.yml-writing -->
|
<replacetokens>
|
||||||
<echo file="${src}/plugin.yml">name: ${name}
|
<token key="VERSION" value="${version}-b${build.number}" />
|
||||||
main: de.sockenklaus.XmlStats.XmlStats
|
<token key="NAME" value="${name}" />
|
||||||
version: ${version}-b${build.number}
|
<token key="AUTHOR" value="${author}" />
|
||||||
author: sockenklaus</echo>
|
</replacetokens>
|
||||||
|
</filterchain>
|
||||||
|
</copy>
|
||||||
|
|
||||||
<jar jarfile="${dist}/${name}.jar">
|
<jar jarfile="${dist}/${name}.jar">
|
||||||
<fileset dir="${bin}"/>
|
<fileset dir="${bin}"/>
|
||||||
<fileset file="src/plugin.yml" />
|
|
||||||
</jar>
|
</jar>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
|||||||
8
resources/plugin.yml
Normal file
8
resources/plugin.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
name: @NAME@
|
||||||
|
main: de.@AUTHOR@.@NAME@.@NAME@
|
||||||
|
version: @VERSION@
|
||||||
|
author: @AUTHOR@
|
||||||
|
commands:
|
||||||
|
xmlstats:
|
||||||
|
description: The basic command.
|
||||||
|
usage: /<command> [reload]
|
||||||
@@ -25,7 +25,6 @@ import de.sockenklaus.XmlStats.XmlWorkers.*;
|
|||||||
/**
|
/**
|
||||||
* The Class WebServer.
|
* The Class WebServer.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("restriction")
|
|
||||||
public class Webserver {
|
public class Webserver {
|
||||||
|
|
||||||
private InetSocketAddress address;
|
private InetSocketAddress address;
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ package de.sockenklaus.XmlStats;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.event.Event.Priority;
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.bukkit.event.Event.Type;
|
import org.bukkit.event.Event.Type;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@@ -45,6 +47,8 @@ public class XmlStats extends JavaPlugin {
|
|||||||
|
|
||||||
if(this.enabled && webserverTemp.isRunning()){
|
if(this.enabled && webserverTemp.isRunning()){
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
|
|
||||||
|
XmlStatsRegistry.flush();
|
||||||
|
|
||||||
webserverTemp.stop();
|
webserverTemp.stop();
|
||||||
|
|
||||||
@@ -126,6 +130,11 @@ public class XmlStats extends JavaPlugin {
|
|||||||
log.log(Level.WARNING, logprefix + " "+ Message);
|
log.log(Level.WARNING, logprefix + " "+ Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log debug.
|
||||||
|
*
|
||||||
|
* @param Message the message
|
||||||
|
*/
|
||||||
public static void LogDebug(String Message){
|
public static void LogDebug(String Message){
|
||||||
Settings settingsTemp = (Settings)XmlStatsRegistry.get("settings");
|
Settings settingsTemp = (Settings)XmlStatsRegistry.get("settings");
|
||||||
if(settingsTemp.getBoolean("options.verbose-enabled")){
|
if(settingsTemp.getBoolean("options.verbose-enabled")){
|
||||||
@@ -133,6 +142,9 @@ public class XmlStats extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook plugins.
|
||||||
|
*/
|
||||||
protected void hookPlugins(){
|
protected void hookPlugins(){
|
||||||
Plugin StatsTemp = getServer().getPluginManager().getPlugin("Stats");
|
Plugin StatsTemp = getServer().getPluginManager().getPlugin("Stats");
|
||||||
Plugin iConomyTemp = getServer().getPluginManager().getPlugin("iConomy");
|
Plugin iConomyTemp = getServer().getPluginManager().getPlugin("iConomy");
|
||||||
@@ -156,6 +168,12 @@ public class XmlStats extends JavaPlugin {
|
|||||||
LogError("iConomy not found! Can't hook into it.");
|
LogError("iConomy not found! Can't hook into it.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is stats hooked.
|
||||||
|
*
|
||||||
|
* @return true, if is stats hooked
|
||||||
|
*/
|
||||||
public static boolean isStatsHooked(){
|
public static boolean isStatsHooked(){
|
||||||
Stats StatsTemp = (Stats)XmlStatsRegistry.get("stats");
|
Stats StatsTemp = (Stats)XmlStatsRegistry.get("stats");
|
||||||
|
|
||||||
@@ -165,6 +183,11 @@ public class XmlStats extends JavaPlugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is i conomy hooked.
|
||||||
|
*
|
||||||
|
* @return true, if is i conomy hooked
|
||||||
|
*/
|
||||||
public static boolean isiConomyHooked(){
|
public static boolean isiConomyHooked(){
|
||||||
iConomy iConomyTemp = (iConomy)XmlStatsRegistry.get("iconomy");
|
iConomy iConomyTemp = (iConomy)XmlStatsRegistry.get("iconomy");
|
||||||
|
|
||||||
@@ -174,10 +197,39 @@ public class XmlStats extends JavaPlugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register events.
|
||||||
|
*/
|
||||||
private void registerEvents(){
|
private void registerEvents(){
|
||||||
XmlStatsServerListener listener = new XmlStatsServerListener(this);
|
XmlStatsServerListener listener = new XmlStatsServerListener(this);
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, listener, Priority.Monitor, this);
|
getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, listener, Priority.Monitor, this);
|
||||||
getServer().getPluginManager().registerEvent(Type.PLUGIN_DISABLE, listener, Priority.Monitor, this);
|
getServer().getPluginManager().registerEvent(Type.PLUGIN_DISABLE, listener, Priority.Monitor, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @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){
|
||||||
|
|
||||||
|
if(commandLabel.equalsIgnoreCase("xmlstats")){
|
||||||
|
if(sender.isOp() && args.length == 1 && args[0].equalsIgnoreCase("reload")){
|
||||||
|
sender.sendMessage("Reloading the XmlStats plugin...");
|
||||||
|
LogInfo("Reloading the XmlStats plugin...");
|
||||||
|
this.reload();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reload.
|
||||||
|
*/
|
||||||
|
private void reload() {
|
||||||
|
this.onDisable();
|
||||||
|
this.onEnable();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,18 +5,29 @@ package de.sockenklaus.XmlStats;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
// TODO: Auto-generated Javadoc
|
||||||
/**
|
/**
|
||||||
* @author socrates
|
* The Class XmlStatsRegistry.
|
||||||
*
|
*
|
||||||
|
* @author socrates
|
||||||
*/
|
*/
|
||||||
public class XmlStatsRegistry {
|
public class XmlStatsRegistry {
|
||||||
private HashMap<String, Object> register = null;
|
private HashMap<String, Object> register = null;
|
||||||
private static XmlStatsRegistry instance = null;
|
private static XmlStatsRegistry instance = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new xml stats registry.
|
||||||
|
*/
|
||||||
private XmlStatsRegistry(){
|
private XmlStatsRegistry(){
|
||||||
register = new HashMap<String, Object>();
|
register = new HashMap<String, Object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put.
|
||||||
|
*
|
||||||
|
* @param key the key
|
||||||
|
* @param value the value
|
||||||
|
*/
|
||||||
public static void put(String key, Object value){
|
public static void put(String key, Object value){
|
||||||
if(instance == null){
|
if(instance == null){
|
||||||
instance = new XmlStatsRegistry();
|
instance = new XmlStatsRegistry();
|
||||||
@@ -24,10 +35,23 @@ public class XmlStatsRegistry {
|
|||||||
instance.register.put(key, value);
|
instance.register.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get.
|
||||||
|
*
|
||||||
|
* @param key the key
|
||||||
|
* @return the object
|
||||||
|
*/
|
||||||
static public Object get(String key){
|
static public Object get(String key){
|
||||||
if(instance == null){
|
if(instance == null){
|
||||||
instance = new XmlStatsRegistry();
|
instance = new XmlStatsRegistry();
|
||||||
}
|
}
|
||||||
return instance.register.get(key);
|
return instance.register.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flush.
|
||||||
|
*/
|
||||||
|
public static void flush(){
|
||||||
|
instance = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
name: XmlStats
|
|
||||||
main: de.sockenklaus.XmlStats.XmlStats
|
|
||||||
version: 0.1-b20
|
|
||||||
author: sockenklaus
|
|
||||||
Reference in New Issue
Block a user