Added some basic javadoc.
This commit is contained in:
@@ -1,12 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) [2011] [Pascal K<>nig]
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
||||
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||
* 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.sockenklaus.XmlStats.Datasource;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class Datasource.
|
||||
*/
|
||||
public abstract class Datasource {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch all players.
|
||||
*
|
||||
* @return the array list
|
||||
*/
|
||||
protected ArrayList<String> fetchAllPlayers(){
|
||||
File[] files = new File("world/players").listFiles();
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) [2011] [Pascal K<>nig]
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
||||
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||
* 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.sockenklaus.XmlStats.Datasource;
|
||||
|
||||
/**
|
||||
* The Class MoneyDS.
|
||||
*/
|
||||
public class MoneyDS extends Datasource {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) [2011] [Pascal K<>nig]
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
||||
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||
* 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.sockenklaus.XmlStats.Datasource;
|
||||
|
||||
import java.io.File;
|
||||
@@ -10,12 +24,24 @@ import com.nidefawl.Stats.datasource.PlayerStatSQL;
|
||||
|
||||
import de.sockenklaus.XmlStats.XmlStats;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class StatsDS.
|
||||
*/
|
||||
public class StatsDS extends Datasource {
|
||||
|
||||
/** The stats plugin. */
|
||||
private Stats statsPlugin;
|
||||
//private Server serverRef;
|
||||
/** The all player names. */
|
||||
private ArrayList<String> allPlayerNames;
|
||||
|
||||
/** The stats. */
|
||||
private HashMap<String, PlayerStat> stats = new HashMap<String, PlayerStat>();
|
||||
|
||||
/**
|
||||
* Instantiates a new stats ds.
|
||||
*/
|
||||
public StatsDS() {
|
||||
this.statsPlugin = XmlStats.getStatsPlugin();
|
||||
//this.serverRef = XmlStats.getServerRef();
|
||||
@@ -23,14 +49,30 @@ public class StatsDS extends Datasource {
|
||||
this.stats = fetchAllPlayerStats(allPlayerNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the plugin.
|
||||
*
|
||||
* @return the plugin
|
||||
*/
|
||||
public Stats getPlugin() {
|
||||
return this.statsPlugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data folder.
|
||||
*
|
||||
* @return the data folder
|
||||
*/
|
||||
public File getDataFolder(){
|
||||
return this.statsPlugin.getDataFolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all player stats.
|
||||
*
|
||||
* @param pPlayerNames the player names
|
||||
* @return the hash map
|
||||
*/
|
||||
private HashMap<String, PlayerStat> fetchAllPlayerStats(ArrayList<String> pPlayerNames){
|
||||
HashMap<String, PlayerStat> result = new HashMap<String, PlayerStat>();
|
||||
|
||||
@@ -44,6 +86,11 @@ public class StatsDS extends Datasource {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the stats.
|
||||
*
|
||||
* @return the stats
|
||||
*/
|
||||
public HashMap<String, PlayerStat> getStats(){
|
||||
return this.stats;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) [2011] [Pascal K<>nig]
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
||||
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||
* 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.sockenklaus.XmlStats.Datasource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class UsersDS.
|
||||
*/
|
||||
public class UsersDS extends Datasource {
|
||||
|
||||
/**
|
||||
* Gets the all players.
|
||||
*
|
||||
* @return the all players
|
||||
*/
|
||||
public ArrayList<String> getAllPlayers(){
|
||||
return fetchAllPlayers();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) [2011] [Pascal K<>nig]
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
||||
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||
* 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.sockenklaus.XmlStats;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class Settings.
|
||||
*/
|
||||
public class Settings {
|
||||
|
||||
private static final String configFilename = "config.yml";
|
||||
private Configuration conf;
|
||||
|
||||
/**
|
||||
* Instantiates a new settings.
|
||||
*
|
||||
* @param xmlStats the xml stats
|
||||
*/
|
||||
public Settings(XmlStats xmlStats){
|
||||
File f = new File(xmlStats.getDataFolder(), configFilename);
|
||||
|
||||
@@ -26,18 +50,51 @@ public class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the int.
|
||||
*
|
||||
* @param path the path
|
||||
* @return the int
|
||||
*/
|
||||
public int getInt(String path){
|
||||
return conf.getInt(path, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the boolean.
|
||||
*
|
||||
* @param path the path
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean getBoolean(String path){
|
||||
return conf.getBoolean(path, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string.
|
||||
*
|
||||
* @param path the path
|
||||
* @return the string
|
||||
*/
|
||||
public String getString(String path){
|
||||
return conf.getString(path, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property.
|
||||
*
|
||||
* @param path the path
|
||||
* @param value the value
|
||||
*/
|
||||
public void setProperty(String path, Object value){
|
||||
conf.setProperty(path, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the settings filename.
|
||||
*
|
||||
* @return the settings filename
|
||||
*/
|
||||
public String getSettingsFilename(){
|
||||
return configFilename;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) [2011] [Pascal K<>nig]
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
||||
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||
* 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.sockenklaus.XmlStats;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -7,15 +21,21 @@ import com.sun.net.httpserver.HttpServer;
|
||||
|
||||
import de.sockenklaus.XmlStats.XmlWorkers.*;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class WebServer.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class WebServer {
|
||||
|
||||
|
||||
private InetSocketAddress address;
|
||||
private HttpServer server = null;
|
||||
|
||||
|
||||
/*
|
||||
* Konstruktoren, um die Address zu initialisieren
|
||||
/**
|
||||
* Instantiates a new web server.
|
||||
*
|
||||
* @param port the port
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public WebServer(int port) throws IOException {
|
||||
this.address = new InetSocketAddress(port);
|
||||
@@ -29,14 +49,19 @@ public class WebServer {
|
||||
this.server.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* Beende den Server
|
||||
/**
|
||||
* Stop server.
|
||||
*/
|
||||
public void stopServer() {
|
||||
server.stop(0);
|
||||
}
|
||||
|
||||
public boolean serverRunning(){
|
||||
/**
|
||||
* Server running.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean isRunning(){
|
||||
return (this.server == null) ? false : true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) [2011] [Pascal K<>nig]
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
||||
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||
* 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.sockenklaus.XmlStats;
|
||||
|
||||
import java.util.logging.Level;
|
||||
@@ -8,20 +22,27 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.nidefawl.Stats.Stats;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class XmlStats.
|
||||
*/
|
||||
public class XmlStats extends JavaPlugin {
|
||||
|
||||
public final static Logger log = Logger.getLogger("Minecraft");
|
||||
public final static double version = 0.01;
|
||||
public final static String logprefix = "[XmlStats]";
|
||||
public boolean enabled = false;
|
||||
private final static Logger log = Logger.getLogger("Minecraft");
|
||||
private final static double version = 0.01;
|
||||
private final static String logprefix = "[XmlStats]";
|
||||
private boolean enabled = false;
|
||||
private static Stats statsPlugin;
|
||||
private static Server serverRef;
|
||||
private WebServer xmlQueryServer;
|
||||
private Settings settings;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.bukkit.plugin.Plugin#onDisable()
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if(enabled && xmlQueryServer.serverRunning()){
|
||||
if(enabled && xmlQueryServer.isRunning()){
|
||||
enabled = false;
|
||||
|
||||
xmlQueryServer.stopServer();
|
||||
@@ -32,6 +53,9 @@ public class XmlStats extends JavaPlugin {
|
||||
LogInfo("Plugin Disabled");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.bukkit.plugin.Plugin#onEnable()
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
@@ -66,22 +90,47 @@ public class XmlStats extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Log error.
|
||||
*
|
||||
* @param Message the message
|
||||
*/
|
||||
public static void LogError(String Message) {
|
||||
log.log(Level.SEVERE, logprefix + " " + Message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log info.
|
||||
*
|
||||
* @param Message the message
|
||||
*/
|
||||
public static void LogInfo(String Message) {
|
||||
log.info(logprefix + " " + Message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log warn.
|
||||
*
|
||||
* @param Message the message
|
||||
*/
|
||||
public static void LogWarn(String Message){
|
||||
log.log(Level.WARNING, logprefix + " "+ Message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the stats plugin.
|
||||
*
|
||||
* @return the stats plugin
|
||||
*/
|
||||
public static Stats getStatsPlugin(){
|
||||
return statsPlugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server ref.
|
||||
*
|
||||
* @return the server ref
|
||||
*/
|
||||
public static Server getServerRef(){
|
||||
return serverRef;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) [2011] [Pascal K<>nig]
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
||||
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||
* 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.sockenklaus.XmlStats.XmlWorkers;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -14,9 +28,16 @@ import com.sun.net.httpserver.HttpExchange;
|
||||
|
||||
import de.sockenklaus.XmlStats.XmlStats;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class XmlWorker.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public abstract class XmlWorker implements HttpHandler {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.sun.net.httpserver.HttpHandler#handle(com.sun.net.httpserver.HttpExchange)
|
||||
*/
|
||||
public void handle(HttpExchange exchange) {
|
||||
Map<String, List<String>> parameters = new HashMap<String, List<String>>();
|
||||
|
||||
@@ -51,6 +72,13 @@ public abstract class XmlWorker implements HttpHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the parameters.
|
||||
*
|
||||
* @param queryString the query string
|
||||
* @return the map
|
||||
* @throws UnsupportedEncodingException the unsupported encoding exception
|
||||
*/
|
||||
public Map<String, List<String>> parseParameters(String queryString) throws UnsupportedEncodingException {
|
||||
Map<String, List<String>> result = new HashMap<String, List<String>>();
|
||||
|
||||
@@ -87,5 +115,11 @@ public abstract class XmlWorker implements HttpHandler {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the xML.
|
||||
*
|
||||
* @param parameters the parameters
|
||||
* @return the xML
|
||||
*/
|
||||
abstract String getXML(Map<String, List<String>> parameters);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) [2011] [Pascal K<>nig]
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
||||
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||
* 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.sockenklaus.XmlStats.XmlWorkers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class XmlWorkerMoney.
|
||||
*/
|
||||
public class XmlWorkerMoney extends XmlWorker {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see de.sockenklaus.XmlStats.XmlWorkers.XmlWorker#getXML(java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public String getXML(Map<String, List<String>> parameters) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) [2011] [Pascal K<>nig]
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
||||
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||
* 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.sockenklaus.XmlStats.XmlWorkers;
|
||||
|
||||
import java.io.StringWriter;
|
||||
@@ -19,8 +33,15 @@ import com.nidefawl.Stats.Stats;
|
||||
|
||||
import de.sockenklaus.XmlStats.Datasource.UsersDS;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class XmlWorkerUsers.
|
||||
*/
|
||||
public class XmlWorkerUsers extends XmlWorker {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see de.sockenklaus.XmlStats.XmlWorkers.XmlWorker#getXML(java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public String getXML(Map<String, List<String>> parameters) {
|
||||
UsersDS users = new UsersDS();
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) [2011] [Pascal K<>nig]
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
||||
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||
* 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.sockenklaus.XmlStats.XmlWorkers;
|
||||
|
||||
import java.io.File;
|
||||
@@ -24,9 +38,27 @@ import com.nidefawl.Stats.datasource.PlayerStat;
|
||||
|
||||
import de.sockenklaus.XmlStats.Datasource.StatsDS;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class XmlWorkerUserstats.
|
||||
*/
|
||||
public class XmlWorkerUserstats extends XmlWorker {
|
||||
|
||||
@Override
|
||||
/** The stats ds. */
|
||||
StatsDS statsDS = new StatsDS();
|
||||
|
||||
/**
|
||||
* Instantiates a new xml worker userstats.
|
||||
*/
|
||||
public XmlWorkerUserstats(){
|
||||
this.statsDS = new StatsDS();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see de.sockenklaus.XmlStats.XmlWorkers.XmlWorker#getXML(java.util.Map)
|
||||
*/
|
||||
public String getXML(Map<String, List<String>> parameters) {
|
||||
try {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
@@ -37,11 +69,6 @@ public class XmlWorkerUserstats extends XmlWorker {
|
||||
StreamResult result = new StreamResult(writer);
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
Transformer transformer = tf.newTransformer();
|
||||
StatsDS statsDS = new StatsDS();
|
||||
|
||||
hModItemResolver itemResolver = new hModItemResolver(new File(statsDS.getDataFolder(),"items.txt"));
|
||||
|
||||
String[] resolveCats = {"blockdestroy", "blockcreate", "itemdrop", "itempickup"};
|
||||
|
||||
Element root = doc.createElement("stats");
|
||||
doc.appendChild(root);
|
||||
@@ -51,37 +78,9 @@ public class XmlWorkerUserstats extends XmlWorker {
|
||||
*/
|
||||
|
||||
for(String playerName : statsDS.getStats().keySet()){
|
||||
PlayerStat player_stats = statsDS.getStats().get(playerName);
|
||||
|
||||
Element elem_player = doc.createElement("player");
|
||||
elem_player.setAttribute("name", playerName);
|
||||
|
||||
for(String catName : player_stats.getCats()){
|
||||
Category cat = player_stats.get(catName);
|
||||
Element elem_cat = doc.createElement("category");
|
||||
elem_cat.setAttribute("name", catName);
|
||||
|
||||
for(String valName : cat.stats.keySet()){
|
||||
int value = cat.get(valName);
|
||||
Element elem_value = doc.createElement("stat");
|
||||
|
||||
elem_value.setAttribute("name", valName);
|
||||
|
||||
if (Arrays.asList(resolveCats).contains(catName)){
|
||||
elem_value.setAttribute("id", String.valueOf(itemResolver.getItem(valName)));
|
||||
}
|
||||
elem_value.setAttribute("value", String.valueOf(value));
|
||||
|
||||
elem_cat.appendChild(elem_value);
|
||||
}
|
||||
|
||||
|
||||
elem_player.appendChild(elem_cat);
|
||||
}
|
||||
|
||||
root.appendChild(elem_player);
|
||||
root.appendChild(getPlayerElement(playerName, doc));
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* Hier endet der XML-Aufbau
|
||||
*/
|
||||
|
||||
@@ -96,5 +95,45 @@ public class XmlWorkerUserstats extends XmlWorker {
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build a XML subtree for the given player.
|
||||
*
|
||||
* @param playerName the player name
|
||||
* @param doc the doc
|
||||
* @return Returns a XML subtree for the given playerName.
|
||||
*/
|
||||
private Element getPlayerElement(String playerName, Document doc){
|
||||
hModItemResolver itemResolver = new hModItemResolver(new File(statsDS.getDataFolder(),"items.txt"));
|
||||
String[] resolveCats = {"blockdestroy", "blockcreate", "itemdrop", "itempickup"};
|
||||
|
||||
PlayerStat player_stats = statsDS.getStats().get(playerName);
|
||||
|
||||
Element elem_player = doc.createElement("player");
|
||||
elem_player.setAttribute("name", playerName);
|
||||
|
||||
for(String catName : player_stats.getCats()){
|
||||
Category cat = player_stats.get(catName);
|
||||
Element elem_cat = doc.createElement("category");
|
||||
elem_cat.setAttribute("name", catName);
|
||||
|
||||
for(String valName : cat.stats.keySet()){
|
||||
int value = cat.get(valName);
|
||||
Element elem_value = doc.createElement("stat");
|
||||
|
||||
elem_value.setAttribute("name", valName);
|
||||
|
||||
if (Arrays.asList(resolveCats).contains(catName)){
|
||||
elem_value.setAttribute("id", String.valueOf(itemResolver.getItem(valName)));
|
||||
}
|
||||
elem_value.setAttribute("value", String.valueOf(value));
|
||||
|
||||
elem_cat.appendChild(elem_value);
|
||||
}
|
||||
|
||||
|
||||
elem_player.appendChild(elem_cat);
|
||||
}
|
||||
return elem_player;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user