Implemented "Register" support and canceled support for iConomy (see:
Issue #20). Did some Refactoring.
This commit is contained in:
@@ -7,8 +7,8 @@
|
|||||||
<attribute name="javadoc_location" value="http://jd.bukkit.org/apidocs/"/>
|
<attribute name="javadoc_location" value="http://jd.bukkit.org/apidocs/"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="lib" path="lib/iConomy.jar"/>
|
|
||||||
<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="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
<pathelement location="lib/Stats.jar" />
|
<pathelement location="lib/Stats.jar" />
|
||||||
<pathelement location="lib/iConomy.jar" />
|
<pathelement location="lib/iConomy.jar" />
|
||||||
<pathelement location="lib/bukkit-0.0.1-SNAPSHOT.jar" />
|
<pathelement location="lib/bukkit-0.0.1-SNAPSHOT.jar" />
|
||||||
|
<pathelement location="lib/Register-1.5.jar" />
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
<buildnumber file=".build.number" />
|
<buildnumber file=".build.number" />
|
||||||
|
|||||||
BIN
lib/Register-1.5.jar
Normal file
BIN
lib/Register-1.5.jar
Normal file
Binary file not shown.
BIN
lib/iConomy.jar
BIN
lib/iConomy.jar
Binary file not shown.
@@ -20,13 +20,17 @@ import de.sockenklaus.XmlStats.XmlStatsRegistry;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AchievementsDS extends Datasource {
|
public class AchievementsDS extends Datasource {
|
||||||
|
private XmlStats xmlstats = null;
|
||||||
|
|
||||||
|
public AchievementsDS(){
|
||||||
|
this.xmlstats = (XmlStats)XmlStatsRegistry.get("xmlstats");
|
||||||
|
}
|
||||||
//HashMap<String, PlayerAchievement> playerAchievementsList;
|
//HashMap<String, PlayerAchievement> playerAchievementsList;
|
||||||
|
|
||||||
public HashMap<String, AchievementListData> getAchievementsList(){
|
public HashMap<String, AchievementListData> getAchievementsList(){
|
||||||
Achievements ach = (Achievements)XmlStatsRegistry.get("achievements");
|
Achievements ach = (Achievements)XmlStatsRegistry.get("achievements");
|
||||||
|
|
||||||
if(XmlStats.checkAchievements()){
|
if(xmlstats.checkAchievements()){
|
||||||
return ach.achievementList;
|
return ach.achievementList;
|
||||||
}
|
}
|
||||||
else return new HashMap<String, AchievementListData>();
|
else return new HashMap<String, AchievementListData>();
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.iConomy.iConomy;
|
import com.nijikokun.register.payment.Method;
|
||||||
import com.iConomy.system.Account;
|
import com.nijikokun.register.payment.Method.MethodAccount;
|
||||||
import com.iConomy.system.Holdings;
|
import com.nijikokun.register.payment.Methods;
|
||||||
|
|
||||||
import de.sockenklaus.XmlStats.XmlStats;
|
import de.sockenklaus.XmlStats.XmlStats;
|
||||||
import de.sockenklaus.XmlStats.XmlStatsRegistry;
|
import de.sockenklaus.XmlStats.XmlStatsRegistry;
|
||||||
@@ -30,12 +30,12 @@ import de.sockenklaus.XmlStats.XmlStatsRegistry;
|
|||||||
*/
|
*/
|
||||||
public class MoneyDS extends Datasource {
|
public class MoneyDS extends Datasource {
|
||||||
|
|
||||||
private iConomy iConomy;
|
|
||||||
private ArrayList<String> allPlayers;
|
private ArrayList<String> allPlayers;
|
||||||
|
private XmlStats xmlstats;
|
||||||
|
|
||||||
public MoneyDS(){
|
public MoneyDS(){
|
||||||
this.iConomy = (iConomy)XmlStatsRegistry.get("iconomy");
|
|
||||||
this.allPlayers = fetchAllPlayers();
|
this.allPlayers = fetchAllPlayers();
|
||||||
|
this.xmlstats = (XmlStats)XmlStatsRegistry.get("xmlstats");
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Double> getBalances(){
|
public HashMap<String, Double> getBalances(){
|
||||||
@@ -48,24 +48,25 @@ public class MoneyDS extends Datasource {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
|
||||||
public Double getBalance(String playerName){
|
public Double getBalance(String playerName){
|
||||||
Double result = 0.0;
|
Double result = 0.0;
|
||||||
|
|
||||||
if (XmlStats.checkiConomy()){
|
if (xmlstats.checkRegister()){
|
||||||
if(this.iConomy.hasAccount(playerName)){
|
|
||||||
Account account = this.iConomy.getAccount(playerName);
|
Method paymentMethod = Methods.getMethod();
|
||||||
|
|
||||||
|
if(paymentMethod.hasAccount(playerName)){
|
||||||
|
MethodAccount account = paymentMethod.getAccount(playerName);
|
||||||
|
|
||||||
if (account != null){
|
if (account != null){
|
||||||
Holdings balance = account.getHoldings();
|
result = account.balance();
|
||||||
result = balance.balance();
|
|
||||||
}
|
}
|
||||||
else XmlStats.LogWarn("The player \""+playerName+"\" has an account but it isn't valid. Bad data will return.");
|
else XmlStats.LogWarn("The player \""+playerName+"\" has an account but it isn't valid. Bad data will return.");
|
||||||
}
|
}
|
||||||
else XmlStats.LogWarn("The player \""+playerName+"\" doesn't have a bank account and this action will return bad data");
|
else XmlStats.LogWarn("The player \""+playerName+"\" doesn't have a bank account and this action will return bad data");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
XmlStats.LogError("Something went wrong! /money.xml shouldn't be enabled but it's datasource was called! This will return bad results.");
|
XmlStats.LogError("Something went wrong! /user_balances.xml shouldn't be enabled but it's datasource was called! This will return bad results.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public class Webserver {
|
|||||||
|
|
||||||
private InetSocketAddress address;
|
private InetSocketAddress address;
|
||||||
private HttpServer server = null;
|
private HttpServer server = null;
|
||||||
|
private XmlStats xmlstats = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new web server.
|
* Instantiates a new web server.
|
||||||
@@ -38,7 +39,7 @@ public class Webserver {
|
|||||||
*/
|
*/
|
||||||
public Webserver() throws IOException {
|
public Webserver() throws IOException {
|
||||||
Settings settingsTemp = (Settings)XmlStatsRegistry.get("settings");
|
Settings settingsTemp = (Settings)XmlStatsRegistry.get("settings");
|
||||||
|
this.xmlstats = (XmlStats)XmlStatsRegistry.get("xmlstats");
|
||||||
this.start(settingsTemp.getInt("options.webserver-port"));
|
this.start(settingsTemp.getInt("options.webserver-port"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,18 +85,18 @@ public class Webserver {
|
|||||||
XmlStats.LogDebug("Started webserver.");
|
XmlStats.LogDebug("Started webserver.");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void startiConomy(){
|
protected void startRegister(){
|
||||||
if (this.isRunning() && XmlStats.checkiConomy()){
|
if (this.isRunning() && xmlstats.checkRegister()){
|
||||||
server.createContext("/user_balances.xml", new UserBalances());
|
server.createContext("/user_balances.xml", new UserBalances());
|
||||||
XmlStats.LogInfo("iConomy seems to be loaded correctly. Enabling /user_balances.xml");
|
XmlStats.LogInfo("Register seems to be loaded correctly. Enabling /user_balances.xml");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
XmlStats.LogWarn("iConomy or webserver not loaded correctly. Disabling /users_balances.xml");
|
XmlStats.LogWarn("Register or webserver not loaded correctly. Disabling /users_balances.xml");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void startAchievements(){
|
protected void startAchievements(){
|
||||||
if(this.isRunning() && XmlStats.checkAchievements()){
|
if(this.isRunning() && xmlstats.checkAchievements()){
|
||||||
server.createContext("/user_achievements.xml", new UserAchievements());
|
server.createContext("/user_achievements.xml", new UserAchievements());
|
||||||
server.createContext("/achievements_list.xml", new AchievementsList());
|
server.createContext("/achievements_list.xml", new AchievementsList());
|
||||||
XmlStats.LogInfo("Achievements seems to be loaded correctly. Enabling /user_achievements.xml");
|
XmlStats.LogInfo("Achievements seems to be loaded correctly. Enabling /user_achievements.xml");
|
||||||
@@ -106,7 +107,7 @@ public class Webserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void startStats(){
|
protected void startStats(){
|
||||||
if(this.isRunning() && XmlStats.checkStats()){
|
if(this.isRunning() && xmlstats.checkStats()){
|
||||||
server.createContext("/user_stats.xml", new UserStats());
|
server.createContext("/user_stats.xml", new UserStats());
|
||||||
XmlStats.LogInfo("Stats seems to be loaded correctly. Enabling /user_stats.xml");
|
XmlStats.LogInfo("Stats seems to be loaded correctly. Enabling /user_stats.xml");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,10 @@ import org.bukkit.event.Event.Type;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.iConomy.iConomy;
|
|
||||||
import com.nidefawl.Achievements.Achievements;
|
import com.nidefawl.Achievements.Achievements;
|
||||||
import com.nidefawl.Stats.Stats;
|
import com.nidefawl.Stats.Stats;
|
||||||
|
import com.nijikokun.register.Register;
|
||||||
|
import com.nijikokun.register.payment.Methods;
|
||||||
|
|
||||||
// TODO: Auto-generated Javadoc
|
// TODO: Auto-generated Javadoc
|
||||||
/**
|
/**
|
||||||
@@ -143,21 +144,21 @@ public class XmlStats extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
protected void hookPlugins(){
|
protected void hookPlugins(){
|
||||||
this.hookAchievements();
|
this.hookAchievements();
|
||||||
this.hookiConomy();
|
this.hookRegister();
|
||||||
this.hookStats();
|
this.hookStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void hookiConomy(){
|
protected void hookRegister(){
|
||||||
Plugin iConomyTemp = getServer().getPluginManager().getPlugin("iConomy");
|
Plugin registerTemp = getServer().getPluginManager().getPlugin("Register");
|
||||||
Webserver webserver = (Webserver)XmlStatsRegistry.get("webserver");
|
Webserver webserver = (Webserver)XmlStatsRegistry.get("webserver");
|
||||||
|
|
||||||
if (iConomyTemp != null && iConomyTemp.isEnabled() && iConomyTemp.getClass().getName().equals("com.iConomy.iConomy")) {
|
if (this.checkRegister()) {
|
||||||
XmlStatsRegistry.put("iconomy", (iConomy)iConomyTemp);
|
XmlStatsRegistry.put("register", (Register)registerTemp);
|
||||||
LogInfo("Hooked into iConomy");
|
LogInfo("Hooked into Register");
|
||||||
webserver.startiConomy();
|
webserver.startRegister();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogWarn("iConomy not found! Can't hook into it.");
|
LogWarn("Register or no payment method found! Can't hook into it.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +166,7 @@ public class XmlStats extends JavaPlugin {
|
|||||||
Plugin AchievementsTemp = getServer().getPluginManager().getPlugin("Achievements");
|
Plugin AchievementsTemp = getServer().getPluginManager().getPlugin("Achievements");
|
||||||
Webserver webserver = (Webserver)XmlStatsRegistry.get("webserver");
|
Webserver webserver = (Webserver)XmlStatsRegistry.get("webserver");
|
||||||
|
|
||||||
if(AchievementsTemp != null && AchievementsTemp.isEnabled() && AchievementsTemp.getClass().getName().equals("com.nidefawl.Achievements.Achievements")){
|
if(this.checkAchievements()){
|
||||||
XmlStatsRegistry.put("achievements", (Achievements)AchievementsTemp);
|
XmlStatsRegistry.put("achievements", (Achievements)AchievementsTemp);
|
||||||
LogInfo("Hooked into Achievements!");
|
LogInfo("Hooked into Achievements!");
|
||||||
webserver.startAchievements();
|
webserver.startAchievements();
|
||||||
@@ -179,7 +180,7 @@ public class XmlStats extends JavaPlugin {
|
|||||||
Plugin StatsTemp = getServer().getPluginManager().getPlugin("Stats");
|
Plugin StatsTemp = getServer().getPluginManager().getPlugin("Stats");
|
||||||
Webserver webserver = (Webserver)XmlStatsRegistry.get("webserver");
|
Webserver webserver = (Webserver)XmlStatsRegistry.get("webserver");
|
||||||
|
|
||||||
if(StatsTemp != null && StatsTemp.isEnabled() && StatsTemp.getClass().getName().equals("com.nidefawl.Stats.Stats")){
|
if(this.checkStats()){
|
||||||
XmlStatsRegistry.put("stats", (Stats)StatsTemp);
|
XmlStatsRegistry.put("stats", (Stats)StatsTemp);
|
||||||
LogInfo("Hooked into Stats!");
|
LogInfo("Hooked into Stats!");
|
||||||
webserver.startStats();
|
webserver.startStats();
|
||||||
@@ -194,8 +195,8 @@ public class XmlStats extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return true, if is stats hooked
|
* @return true, if is stats hooked
|
||||||
*/
|
*/
|
||||||
public static boolean checkStats(){
|
public boolean checkStats(){
|
||||||
Stats StatsTemp = (Stats)XmlStatsRegistry.get("stats");
|
Plugin StatsTemp = getServer().getPluginManager().getPlugin("Stats");
|
||||||
|
|
||||||
if(StatsTemp != null && StatsTemp.getClass().getName().equals("com.nidefawl.Stats.Stats") && StatsTemp.isEnabled()) return true;
|
if(StatsTemp != null && StatsTemp.getClass().getName().equals("com.nidefawl.Stats.Stats") && StatsTemp.isEnabled()) return true;
|
||||||
return false;
|
return false;
|
||||||
@@ -206,10 +207,10 @@ public class XmlStats extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return true, if is i conomy hooked
|
* @return true, if is i conomy hooked
|
||||||
*/
|
*/
|
||||||
public static boolean checkiConomy(){
|
public boolean checkRegister(){
|
||||||
iConomy iConomyTemp = (iConomy)XmlStatsRegistry.get("iconomy");
|
Plugin registerTemp = getServer().getPluginManager().getPlugin("Register");
|
||||||
|
|
||||||
if (iConomyTemp != null && iConomyTemp.getClass().getName().equals("com.iConomy.iConomy") && iConomyTemp.isEnabled()) return true;
|
if (registerTemp != null && registerTemp.getClass().getName().equals("com.nijikokun.register.Register") && registerTemp.isEnabled() && Methods.hasMethod()) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,8 +219,8 @@ public class XmlStats extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return true, if is Achievements hooked
|
* @return true, if is Achievements hooked
|
||||||
*/
|
*/
|
||||||
public static boolean checkAchievements(){
|
public boolean checkAchievements(){
|
||||||
Achievements AchievementsTemp = (Achievements)XmlStatsRegistry.get("achievements");
|
Plugin AchievementsTemp = getServer().getPluginManager().getPlugin("Achievements");
|
||||||
|
|
||||||
if(AchievementsTemp != null && AchievementsTemp.getClass().getName().equals("com.nidefawl.Achievements.Achievements") && AchievementsTemp.isEnabled()) return true;
|
if(AchievementsTemp != null && AchievementsTemp.getClass().getName().equals("com.nidefawl.Achievements.Achievements") && AchievementsTemp.isEnabled()) return true;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ public class XmlStatsServerListener extends ServerListener {
|
|||||||
if(this.identifyPlugin(event, "achievements")){
|
if(this.identifyPlugin(event, "achievements")){
|
||||||
this.plugin.hookAchievements();
|
this.plugin.hookAchievements();
|
||||||
}
|
}
|
||||||
if(this.identifyPlugin(event, "iconomy")){
|
if(this.identifyPlugin(event, "register")){
|
||||||
this.plugin.hookiConomy();
|
this.plugin.hookRegister();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user