Merge branch 'stats2.0' into v0.4
Conflicts: .build.number src/de/sockenklaus/XmlStats/Datasource/StatsDS.java src/de/sockenklaus/XmlStats/Datasource/UsersDS.java src/de/sockenklaus/XmlStats/Objects/NodeCategories.java src/de/sockenklaus/XmlStats/Objects/NodeItems.java src/de/sockenklaus/XmlStats/Settings.java src/de/sockenklaus/XmlStats/XmlStats.java src/de/sockenklaus/XmlStats/XmlStatsServerListener.java src/de/sockenklaus/XmlStats/XmlWorkers/UserStats.java Merged stats2.0 into v0.4
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Fri Oct 14 01:25:23 CEST 2011
|
#Fri Feb 03 16:29:04 CET 2012
|
||||||
build.number=66
|
build.number=72
|
||||||
|
|||||||
@@ -2,13 +2,9 @@
|
|||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="lib" path="lib/Stats.jar"/>
|
<classpathentry kind="lib" path="lib/Stats.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/bukkit-0.0.1-SNAPSHOT.jar">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="javadoc_location" value="http://jd.bukkit.org/apidocs/"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="lib" path="lib/Achievements.jar"/>
|
<classpathentry kind="lib" path="lib/Achievements.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/Register-1.5.jar"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="lib" path="lib/bukkit-1.1-R3.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/Register.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#Sat Aug 27 14:58:29 CEST 2011
|
#Fri Feb 03 00:30:05 CET 2012
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.source=1.6
|
org.eclipse.jdt.core.compiler.source=1.7
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
This plugin for the Bukkit Minecraft Server API ([Homepage](http://bukkit.org) | [Github](https://github.com/Bukkit/Bukkit )) offers the possibility to access some playerstats via xml files. The provided data is basically generated by [Stats](https://github.com/nidefawl/Stats).
|
This plugin for the Bukkit Minecraft Server API ([Homepage](http://bukkit.org) | [Github](https://github.com/Bukkit/Bukkit )) offers the possibility to access some playerstats via xml files. The provided data is basically generated by [Stats](https://github.com/nidefawl/Stats).
|
||||||
|
|
||||||
|
[](https://flattr.com/submit/auto?user_id=socke&url=https://github.com/sockenklaus/XmlStats&title=XmlStats&language=&tags=github&category=software)
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
To install the plugin, simply place the compiled **XmlStats.jar** in your servers plugin directory and execute the /reload-command on your server. The plugin will create it's config file in the /plugins/XmlStats directory.
|
To install the plugin, simply place the compiled **XmlStats.jar** in your servers plugin directory and execute the /reload-command on your server. The plugin will create it's config file in the /plugins/XmlStats directory.
|
||||||
|
|||||||
@@ -13,9 +13,8 @@
|
|||||||
<path id="classpath">
|
<path id="classpath">
|
||||||
<pathelement location="lib/Achievements.jar" />
|
<pathelement location="lib/Achievements.jar" />
|
||||||
<pathelement location="lib/Stats.jar" />
|
<pathelement location="lib/Stats.jar" />
|
||||||
<pathelement location="lib/iConomy.jar" />
|
<pathelement location="lib/bukkit-1.1-R3.jar" />
|
||||||
<pathelement location="lib/bukkit-0.0.1-SNAPSHOT.jar" />
|
<pathelement location="lib/Register.jar" />
|
||||||
<pathelement location="lib/Register-1.5.jar" />
|
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
<buildnumber file=".build.number" />
|
<buildnumber file=".build.number" />
|
||||||
|
|||||||
Binary file not shown.
BIN
lib/Stats.jar
BIN
lib/Stats.jar
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) [2011] [Pascal K<EFBFBD>nig]
|
* Copyright (C) [2011] [Pascal Koenig]
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
* 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
|
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) [2011] [Pascal K<EFBFBD>nig]
|
* Copyright (C) [2011] [Pascal Koenig]
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
* 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
|
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) [2011] [Pascal K<EFBFBD>nig]
|
* Copyright (C) [2011] [Pascal Koenig]
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
* 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
|
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||||
@@ -17,13 +17,16 @@ package de.sockenklaus.XmlStats.Datasource;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import terranetworkorg.Stats.Stats;
|
||||||
|
import terranetworkorg.Stats.Storage.PlayerCache;
|
||||||
|
import terranetworkorg.Stats.Storage.PlayerControl;
|
||||||
|
import terranetworkorg.Stats.Storage.PlayerStats;
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
/*import com.nidefawl.Stats.Stats;
|
||||||
|
|
||||||
import com.nidefawl.Stats.Stats;
|
|
||||||
import com.nidefawl.Stats.datasource.Category;
|
import com.nidefawl.Stats.datasource.Category;
|
||||||
import com.nidefawl.Stats.datasource.PlayerStat;
|
import com.nidefawl.Stats.datasource.PlayerStat;
|
||||||
import com.nidefawl.Stats.datasource.PlayerStatSQL;
|
import com.nidefawl.Stats.datasource.PlayerStatSQL;*/
|
||||||
|
|
||||||
import de.sockenklaus.XmlStats.Util;
|
import de.sockenklaus.XmlStats.Util;
|
||||||
import de.sockenklaus.XmlStats.Webserver;
|
import de.sockenklaus.XmlStats.Webserver;
|
||||||
@@ -67,48 +70,83 @@ public class StatsDS extends Datasource {
|
|||||||
public File getDataFolder(){
|
public File getDataFolder(){
|
||||||
return this.stats.getDataFolder();
|
return this.stats.getDataFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Category> getAddedStats(List<String> playerList){
|
public static HashMap<String, HashMap<String, Integer>> getAddedStats(List<String> playerList){
|
||||||
HashMap <String, Category> result = new HashMap<String, Category>();
|
HashMap <String, HashMap<String, Integer>> result = new HashMap<String, HashMap<String, Integer>>();
|
||||||
|
|
||||||
for(String playerName : playerList){
|
for(String playerName : playerList){
|
||||||
PlayerStat player = getPlayerStat(playerName);
|
PlayerCache player = getPlayerCache(playerName);
|
||||||
|
|
||||||
for(String catName : player.getCats()){
|
for(PlayerStats ps : player.getStats()){
|
||||||
Category cat = player.get(catName);
|
if(!result.containsKey(ps.getCat())){
|
||||||
|
/*
|
||||||
for(String entryName : cat.getEntries()){
|
* Fall 1:
|
||||||
Integer entry = cat.get(entryName);
|
* Result enthaelt schon die Kat nicht
|
||||||
|
*/
|
||||||
|
HashMap<String, Integer> tmpMap = new HashMap<String, Integer>();
|
||||||
|
tmpMap.put(ps.getName(), ps.getValue());
|
||||||
|
result.put(ps.getCat(), tmpMap);
|
||||||
|
}
|
||||||
|
else if(!result.get(ps.getCat()).containsKey(ps.getName())){
|
||||||
|
/*
|
||||||
|
* Fall 2: Result enthaelt Cat aber Stat nicht.
|
||||||
|
*/
|
||||||
|
result.get(ps.getCat()).put(ps.getName(), ps.getValue());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/*
|
||||||
|
* Fall 3: Es ist beides schon vorhanden
|
||||||
|
*/
|
||||||
|
Integer currVal = result.get(ps.getCat()).get(ps.getName());
|
||||||
|
|
||||||
if(result.containsKey(catName)){
|
if(ps.getName().equals("lastlogin") || ps.getName().equals("lastlogout")){
|
||||||
|
result.get(ps.getCat()).put(ps.getName(), Math.max(ps.getValue(), currVal));
|
||||||
if(entryName.equals("lastlogin") || entryName.equals("lastlogout")){
|
|
||||||
result.get(catName).put(entryName, Math.max(result.get(catName).get(entryName), entry));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
result.get(catName).add(entryName, entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Category tempCat = new Category();
|
result.get(ps.getCat()).put(ps.getName(), currVal + ps.getValue());
|
||||||
tempCat.add(entryName, entry);
|
|
||||||
result.put(catName, tempCat);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerStat getPlayerStat(String playerName){
|
public static HashMap<String, HashMap<String, Integer>> getStats(String playerName){
|
||||||
|
HashMap<String, HashMap<String, Integer>> result = new HashMap<String, HashMap<String, Integer>>();
|
||||||
PlayerStat result = new PlayerStatSQL(playerName, this.getStats());
|
|
||||||
|
|
||||||
result.load();
|
PlayerCache player = getPlayerCache(playerName);
|
||||||
|
|
||||||
|
for(PlayerStats ps : player.getStats()){
|
||||||
|
if(!result.containsKey(ps.getCat())){
|
||||||
|
/*
|
||||||
|
* Fall 1: Result enthaelt die Kategorie nicht.
|
||||||
|
*/
|
||||||
|
HashMap<String, Integer> tmpMap = new HashMap<String, Integer>();
|
||||||
|
tmpMap.put(ps.getName(), ps.getValue());
|
||||||
|
result.put(ps.getCat(), tmpMap);
|
||||||
|
}
|
||||||
|
else if(!result.get(ps.getCat()).containsKey(ps.getName())){
|
||||||
|
/*
|
||||||
|
* Fall 2: Result kennt Kategorie, aber nicht den Stat.
|
||||||
|
*/
|
||||||
|
result.get(ps.getCat()).put(ps.getName(), ps.getValue());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/*
|
||||||
|
* Fall 3 (sollte nicht auftreten): Result kennt beides schon.
|
||||||
|
* Im Zweifel ueberschreiben...
|
||||||
|
*/
|
||||||
|
result.get(ps.getCat()).put(ps.getName(), ps.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PlayerCache getPlayerCache(String playerName){
|
||||||
|
return PlayerControl.getPlayerCache(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hookStats(){
|
private void hookStats(){
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.sockenklaus.XmlStats.Objects;
|
package de.sockenklaus.XmlStats.Objects;
|
||||||
|
|
||||||
import com.nidefawl.Stats.datasource.PlayerStat;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import de.sockenklaus.XmlStats.Datasource.StatsDS;
|
import de.sockenklaus.XmlStats.Datasource.StatsDS;
|
||||||
|
|
||||||
@@ -21,9 +21,10 @@ public class NodeCategories extends NodeArray {
|
|||||||
*/
|
*/
|
||||||
public NodeCategories(String userName) {
|
public NodeCategories(String userName) {
|
||||||
this();
|
this();
|
||||||
PlayerStat userStat = StatsDS.getInstance().getPlayerStat(userName);
|
|
||||||
|
HashMap<String, HashMap<String, Integer>> userStat = UserstatsDS.getStats(userName);
|
||||||
|
|
||||||
for(String catName : userStat.getCats()){
|
for(String catName : userStat.keySet()){
|
||||||
NodeCategory node_cat = new NodeCategory(catName, userStat.get(catName));
|
NodeCategory node_cat = new NodeCategory(catName, userStat.get(catName));
|
||||||
this.appendChild(node_cat);
|
this.appendChild(node_cat);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.sockenklaus.XmlStats.Objects;
|
package de.sockenklaus.XmlStats.Objects;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import com.nidefawl.Stats.datasource.Category;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author socrates
|
* @author socrates
|
||||||
@@ -16,14 +14,11 @@ public class NodeCategory extends NodeList {
|
|||||||
/**
|
/**
|
||||||
* @param category
|
* @param category
|
||||||
*/
|
*/
|
||||||
public NodeCategory(String catName, Category category) {
|
public NodeCategory(String catName, HashMap<String, Integer> category) {
|
||||||
super("category");
|
super("category");
|
||||||
|
|
||||||
String[] resolveCats = new String[]{"blockdestroy", "blockcreate", "itemdrop", "itempickup"};
|
|
||||||
Boolean resolve = Arrays.asList(resolveCats).contains(catName);
|
|
||||||
|
|
||||||
this.appendChild(new NodeText("name", catName));
|
this.appendChild(new NodeText("name", catName));
|
||||||
this.appendChild(new NodeItems(category, resolve));
|
this.appendChild(new NodeItems(category));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.sockenklaus.XmlStats.Objects;
|
package de.sockenklaus.XmlStats.Objects;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import com.nidefawl.Stats.ItemResolver.hModItemResolver;
|
|
||||||
import com.nidefawl.Stats.datasource.Category;
|
|
||||||
|
|
||||||
import de.sockenklaus.XmlStats.Datasource.StatsDS;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author socrates
|
* @author socrates
|
||||||
@@ -19,18 +14,10 @@ public class NodeItems extends NodeArray {
|
|||||||
/**
|
/**
|
||||||
* @param category
|
* @param category
|
||||||
*/
|
*/
|
||||||
public NodeItems(Category category, Boolean resolve) {
|
public NodeItems(HashMap<String, Integer> category) {
|
||||||
super("items");
|
super("items");
|
||||||
|
|
||||||
hModItemResolver itemResolver = new hModItemResolver(new File(StatsDS.getInstance().getDataFolder(),"items.txt"));
|
|
||||||
|
|
||||||
for(String varName : category.getEntries()){
|
for(String varName : category.keySet()){
|
||||||
NodeItem node_item = new NodeItem(varName, category.get(varName));
|
|
||||||
|
|
||||||
if(resolve){
|
|
||||||
node_item.setAttribute("id", itemResolver.getItem(varName));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.appendChild(new NodeItem(varName, category.get(varName)));
|
this.appendChild(new NodeItem(varName, category.get(varName)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) [2011] [Pascal K<EFBFBD>nig]
|
* Copyright (C) [2011] [Pascal Koenig]
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
* 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
|
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||||
@@ -15,8 +15,9 @@
|
|||||||
package de.sockenklaus.XmlStats;
|
package de.sockenklaus.XmlStats;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
// TODO: Auto-generated Javadoc
|
// TODO: Auto-generated Javadoc
|
||||||
/**
|
/**
|
||||||
@@ -25,8 +26,8 @@ import org.bukkit.util.config.Configuration;
|
|||||||
public class Settings {
|
public class Settings {
|
||||||
|
|
||||||
private static final String configFilename = "config.yml";
|
private static final String configFilename = "config.yml";
|
||||||
private static Settings instance;
|
|
||||||
private Configuration conf;
|
private YamlConfiguration conf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new settings.
|
* Instantiates a new settings.
|
||||||
@@ -35,16 +36,19 @@ public class Settings {
|
|||||||
*/
|
*/
|
||||||
private Settings(){
|
private Settings(){
|
||||||
File f = new File(XmlStats.getInstance().getDataFolder(), configFilename);
|
File f = new File(XmlStats.getInstance().getDataFolder(), configFilename);
|
||||||
|
|
||||||
this.conf = new Configuration(f);
|
|
||||||
if(f.exists()){
|
if(f.exists()){
|
||||||
this.conf.load();
|
conf = YamlConfiguration.loadConfiguration(f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.conf.setProperty("options.webserver-enabled", true);
|
conf.set("options.webserver-enabled", true);
|
||||||
this.conf.setProperty("options.webserver-port", 9123);
|
conf.set("options.webserver-port", 9123);
|
||||||
this.conf.setProperty("options.verbose-enabled", true);
|
conf.set("options.verbose-enabled", true);
|
||||||
this.conf.save();
|
try {
|
||||||
|
conf.save(f);
|
||||||
|
}catch(IOException e){
|
||||||
|
XmlStats.LogError("Something went wrong with the conf-file: "+e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +94,7 @@ public class Settings {
|
|||||||
* @param value the value
|
* @param value the value
|
||||||
*/
|
*/
|
||||||
public void setProperty(String path, Object value){
|
public void setProperty(String path, Object value){
|
||||||
this.conf.setProperty(path, value);
|
conf.set(path, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) [2011] [Pascal K<EFBFBD>nig]
|
* Copyright (C) [2011] [Pascal Koenig]
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
* 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
|
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) [2011] [Pascal K<EFBFBD>nig]
|
* Copyright (C) [2011] [Pascal Koenig]
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
* 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
|
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||||
@@ -19,13 +19,14 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.event.Event.Priority;
|
|
||||||
import org.bukkit.event.Event.Type;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import de.sockenklaus.XmlStats.Datasource.AchievementsDS;
|
import com.nidefawl.Achievements.Achievements;
|
||||||
import de.sockenklaus.XmlStats.Datasource.RegisterDS;
|
import terranetworkorg.Stats.Stats;
|
||||||
import de.sockenklaus.XmlStats.Datasource.StatsDS;
|
import com.nijikokun.register.Register;
|
||||||
|
import com.nijikokun.register.payment.Methods;
|
||||||
|
|
||||||
// TODO: Auto-generated Javadoc
|
// TODO: Auto-generated Javadoc
|
||||||
/**
|
/**
|
||||||
@@ -145,6 +146,53 @@ public class XmlStats extends JavaPlugin {
|
|||||||
if(Util.checkRegister()) RegisterDS.getInstance();
|
if(Util.checkRegister()) RegisterDS.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void hookAchievements(){
|
||||||
|
Plugin AchievementsTemp = getServer().getPluginManager().getPlugin("Achievements");
|
||||||
|
Webserver webserver = (Webserver)XmlStatsRegistry.get("webserver");
|
||||||
|
|
||||||
|
if(this.checkAchievements()){
|
||||||
|
XmlStatsRegistry.put("achievements", (Achievements)AchievementsTemp);
|
||||||
|
LogInfo("Hooked into Achievements!");
|
||||||
|
webserver.startAchievements();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LogWarn("Achievements not found! Can't hook into it.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void hookStats(){
|
||||||
|
Plugin StatsTemp = getServer().getPluginManager().getPlugin("Stats 2.0");
|
||||||
|
LogDebug("Got Plugin \"Stats 2.0\"");
|
||||||
|
Webserver webserver = (Webserver)XmlStatsRegistry.get("webserver");
|
||||||
|
LogDebug("Got webserver-object");
|
||||||
|
|
||||||
|
if(this.checkStats()){
|
||||||
|
XmlStatsRegistry.put("stats", (Stats)StatsTemp);
|
||||||
|
LogInfo("Hooked into Stats!");
|
||||||
|
webserver.startStats();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LogWarn("Stats not found! Can't hook into it.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is stats hooked.
|
||||||
|
*
|
||||||
|
* @return true, if is stats hooked
|
||||||
|
*/
|
||||||
|
public boolean checkStats(){
|
||||||
|
LogDebug("Stats 2.0? Are you there?");
|
||||||
|
Plugin StatsTemp = getServer().getPluginManager().getPlugin("Stats 2.0");
|
||||||
|
LogDebug("Got object \"Stats 2.0\"");
|
||||||
|
|
||||||
|
if(StatsTemp != null && StatsTemp.getClass().getName().equals("terranetworkorg.Stats.Stats") && StatsTemp.isEnabled()){
|
||||||
|
LogDebug("terranetworkorg.Stats.Stats is enabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
LogDebug("terranetworkorg.Stats.Stats is not enabled.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* (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[])
|
||||||
@@ -174,11 +222,14 @@ public class XmlStats extends JavaPlugin {
|
|||||||
protected void reload() {
|
protected void reload() {
|
||||||
this.onDisable();
|
this.onDisable();
|
||||||
this.onEnable();
|
this.onEnable();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerEvents(){
|
private void registerEvents(){
|
||||||
XmlStatsServerListener listener = new XmlStatsServerListener();
|
LogDebug("Trying to register ServerListener");
|
||||||
|
XmlStatsServerListener listener = new XmlStatsServerListener(this);
|
||||||
|
LogDebug("Listener-object created.");
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, listener, Priority.Monitor, this);
|
getServer().getPluginManager().registerEvents(listener, this);
|
||||||
|
LogDebug("Event registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,10 @@
|
|||||||
*/
|
*/
|
||||||
package de.sockenklaus.XmlStats;
|
package de.sockenklaus.XmlStats;
|
||||||
|
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
import org.bukkit.event.server.PluginEnableEvent;
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
import org.bukkit.event.server.ServerListener;
|
|
||||||
|
|
||||||
import de.sockenklaus.XmlStats.Datasource.AchievementsDS;
|
import de.sockenklaus.XmlStats.Datasource.AchievementsDS;
|
||||||
import de.sockenklaus.XmlStats.Datasource.RegisterDS;
|
import de.sockenklaus.XmlStats.Datasource.RegisterDS;
|
||||||
@@ -14,11 +16,43 @@ import de.sockenklaus.XmlStats.Datasource.StatsDS;
|
|||||||
* @author socrates
|
* @author socrates
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class XmlStatsServerListener extends ServerListener {
|
public class XmlStatsServerListener implements Listener {
|
||||||
|
private XmlStats plugin;
|
||||||
|
|
||||||
|
public XmlStatsServerListener(XmlStats plugin){
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPluginDisable(PluginDisableEvent event){
|
||||||
|
/*
|
||||||
|
* TODO
|
||||||
|
* Not implemented yet!
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*Plugin iConomy = (Plugin)XmlStatsRegistry.get("iconomy");
|
||||||
|
Plugin Stats = (Plugin)XmlStatsRegistry.get("stats");
|
||||||
|
Plugin Achievements = (Plugin)XmlStatsRegistry.get("achievements");
|
||||||
|
|
||||||
|
if (!XmlStats.checkAchievements()){
|
||||||
|
|
||||||
|
}
|
||||||
|
if(!XmlStats.checkiConomy()){
|
||||||
|
|
||||||
|
}
|
||||||
|
if(!XmlStats.checkStats()){
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
public void onPluginEnable(PluginEnableEvent event){
|
public void onPluginEnable(PluginEnableEvent event){
|
||||||
if(this.identifyPlugin(event, "stats") && Util.checkStats()){
|
|
||||||
StatsDS.getInstance();
|
XmlStats.LogDebug("onPluginEnable fired");
|
||||||
|
|
||||||
|
if(this.identifyPlugin(event, "stats 2.0")){
|
||||||
|
XmlStats.LogDebug("Stats 2.0 fired the event");
|
||||||
|
this.plugin.hookStats();
|
||||||
}
|
}
|
||||||
if(this.identifyPlugin(event, "achievements") && Util.checkAchievements()){
|
if(this.identifyPlugin(event, "achievements") && Util.checkAchievements()){
|
||||||
AchievementsDS.getInstance();
|
AchievementsDS.getInstance();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) [2011] [Pascal K<EFBFBD>nig]
|
* Copyright (C) [2011] [Pascal Koenig]
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
* 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
|
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) [2011] [Pascal K<EFBFBD>nig]
|
* Copyright (C) [2011] [Pascal Koenig]
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
* 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
|
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) [2011] [Pascal K<EFBFBD>nig]
|
* Copyright (C) [2011] [Pascal Koenig]
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
* 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
|
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||||
@@ -20,9 +20,13 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
import com.nidefawl.Stats.datasource.Category;
|
import com.nidefawl.Stats.datasource.Category;
|
||||||
|
|
||||||
import de.sockenklaus.XmlStats.Datasource.StatsDS;
|
import de.sockenklaus.XmlStats.Datasource.StatsDS;
|
||||||
|
=======
|
||||||
|
import de.sockenklaus.XmlStats.Datasource.UserstatsDS;
|
||||||
|
>>>>>>> stats2.0
|
||||||
import de.sockenklaus.XmlStats.Exceptions.XmlStatsException;
|
import de.sockenklaus.XmlStats.Exceptions.XmlStatsException;
|
||||||
import de.sockenklaus.XmlStats.Objects.NodeCategories;
|
import de.sockenklaus.XmlStats.Objects.NodeCategories;
|
||||||
import de.sockenklaus.XmlStats.Objects.NodeCategory;
|
import de.sockenklaus.XmlStats.Objects.NodeCategory;
|
||||||
@@ -59,7 +63,11 @@ public class UserStats extends XmlWorker {
|
|||||||
node_users.appendChild(new NodeUser(userName));
|
node_users.appendChild(new NodeUser(userName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
HashMap<String, Category> addedStats = StatsDS.getInstance().getAddedStats(playerList);
|
HashMap<String, Category> addedStats = StatsDS.getInstance().getAddedStats(playerList);
|
||||||
|
=======
|
||||||
|
HashMap<String, HashMap<String, Integer>> addedStats = UserstatsDS.getAddedStats(playerList);
|
||||||
|
>>>>>>> stats2.0
|
||||||
|
|
||||||
for(String catName : addedStats.keySet()){
|
for(String catName : addedStats.keySet()){
|
||||||
NodeCategory node_cat = new NodeCategory(catName, addedStats.get(catName));
|
NodeCategory node_cat = new NodeCategory(catName, addedStats.get(catName));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) [2011] [Pascal K<EFBFBD>nig]
|
* Copyright (C) [2011] [Pascal Koenig]
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of
|
* 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
|
* the GNU General Public License as published by the Free Software Foundation; either version
|
||||||
|
|||||||
Reference in New Issue
Block a user