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/"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/iConomy.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="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<pathelement location="lib/Stats.jar" />
|
||||
<pathelement location="lib/iConomy.jar" />
|
||||
<pathelement location="lib/bukkit-0.0.1-SNAPSHOT.jar" />
|
||||
<pathelement location="lib/Register-1.5.jar" />
|
||||
</path>
|
||||
|
||||
<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 {
|
||||
|
||||
private XmlStats xmlstats = null;
|
||||
|
||||
public AchievementsDS(){
|
||||
this.xmlstats = (XmlStats)XmlStatsRegistry.get("xmlstats");
|
||||
}
|
||||
//HashMap<String, PlayerAchievement> playerAchievementsList;
|
||||
|
||||
public HashMap<String, AchievementListData> getAchievementsList(){
|
||||
Achievements ach = (Achievements)XmlStatsRegistry.get("achievements");
|
||||
|
||||
if(XmlStats.checkAchievements()){
|
||||
if(xmlstats.checkAchievements()){
|
||||
return ach.achievementList;
|
||||
}
|
||||
else return new HashMap<String, AchievementListData>();
|
||||
|
||||
@@ -18,9 +18,9 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.iConomy.iConomy;
|
||||
import com.iConomy.system.Account;
|
||||
import com.iConomy.system.Holdings;
|
||||
import com.nijikokun.register.payment.Method;
|
||||
import com.nijikokun.register.payment.Method.MethodAccount;
|
||||
import com.nijikokun.register.payment.Methods;
|
||||
|
||||
import de.sockenklaus.XmlStats.XmlStats;
|
||||
import de.sockenklaus.XmlStats.XmlStatsRegistry;
|
||||
@@ -30,12 +30,12 @@ import de.sockenklaus.XmlStats.XmlStatsRegistry;
|
||||
*/
|
||||
public class MoneyDS extends Datasource {
|
||||
|
||||
private iConomy iConomy;
|
||||
private ArrayList<String> allPlayers;
|
||||
private XmlStats xmlstats;
|
||||
|
||||
public MoneyDS(){
|
||||
this.iConomy = (iConomy)XmlStatsRegistry.get("iconomy");
|
||||
this.allPlayers = fetchAllPlayers();
|
||||
this.xmlstats = (XmlStats)XmlStatsRegistry.get("xmlstats");
|
||||
}
|
||||
|
||||
public HashMap<String, Double> getBalances(){
|
||||
@@ -48,24 +48,25 @@ public class MoneyDS extends Datasource {
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public Double getBalance(String playerName){
|
||||
Double result = 0.0;
|
||||
|
||||
if (XmlStats.checkiConomy()){
|
||||
if(this.iConomy.hasAccount(playerName)){
|
||||
Account account = this.iConomy.getAccount(playerName);
|
||||
|
||||
if (xmlstats.checkRegister()){
|
||||
|
||||
Method paymentMethod = Methods.getMethod();
|
||||
|
||||
if(paymentMethod.hasAccount(playerName)){
|
||||
MethodAccount account = paymentMethod.getAccount(playerName);
|
||||
|
||||
if (account != null){
|
||||
Holdings balance = account.getHoldings();
|
||||
result = balance.balance();
|
||||
result = account.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+"\" doesn't have a bank account and this action will return bad data");
|
||||
}
|
||||
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;
|
||||
|
||||
@@ -29,6 +29,7 @@ public class Webserver {
|
||||
|
||||
private InetSocketAddress address;
|
||||
private HttpServer server = null;
|
||||
private XmlStats xmlstats = null;
|
||||
|
||||
/**
|
||||
* Instantiates a new web server.
|
||||
@@ -38,7 +39,7 @@ public class Webserver {
|
||||
*/
|
||||
public Webserver() throws IOException {
|
||||
Settings settingsTemp = (Settings)XmlStatsRegistry.get("settings");
|
||||
|
||||
this.xmlstats = (XmlStats)XmlStatsRegistry.get("xmlstats");
|
||||
this.start(settingsTemp.getInt("options.webserver-port"));
|
||||
}
|
||||
|
||||
@@ -84,18 +85,18 @@ public class Webserver {
|
||||
XmlStats.LogDebug("Started webserver.");
|
||||
}
|
||||
|
||||
protected void startiConomy(){
|
||||
if (this.isRunning() && XmlStats.checkiConomy()){
|
||||
protected void startRegister(){
|
||||
if (this.isRunning() && xmlstats.checkRegister()){
|
||||
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 {
|
||||
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(){
|
||||
if(this.isRunning() && XmlStats.checkAchievements()){
|
||||
if(this.isRunning() && xmlstats.checkAchievements()){
|
||||
server.createContext("/user_achievements.xml", new UserAchievements());
|
||||
server.createContext("/achievements_list.xml", new AchievementsList());
|
||||
XmlStats.LogInfo("Achievements seems to be loaded correctly. Enabling /user_achievements.xml");
|
||||
@@ -106,7 +107,7 @@ public class Webserver {
|
||||
}
|
||||
|
||||
protected void startStats(){
|
||||
if(this.isRunning() && XmlStats.checkStats()){
|
||||
if(this.isRunning() && xmlstats.checkStats()){
|
||||
server.createContext("/user_stats.xml", new UserStats());
|
||||
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.java.JavaPlugin;
|
||||
|
||||
import com.iConomy.iConomy;
|
||||
import com.nidefawl.Achievements.Achievements;
|
||||
import com.nidefawl.Stats.Stats;
|
||||
import com.nijikokun.register.Register;
|
||||
import com.nijikokun.register.payment.Methods;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -143,21 +144,21 @@ public class XmlStats extends JavaPlugin {
|
||||
*/
|
||||
protected void hookPlugins(){
|
||||
this.hookAchievements();
|
||||
this.hookiConomy();
|
||||
this.hookRegister();
|
||||
this.hookStats();
|
||||
}
|
||||
|
||||
protected void hookiConomy(){
|
||||
Plugin iConomyTemp = getServer().getPluginManager().getPlugin("iConomy");
|
||||
protected void hookRegister(){
|
||||
Plugin registerTemp = getServer().getPluginManager().getPlugin("Register");
|
||||
Webserver webserver = (Webserver)XmlStatsRegistry.get("webserver");
|
||||
|
||||
if (iConomyTemp != null && iConomyTemp.isEnabled() && iConomyTemp.getClass().getName().equals("com.iConomy.iConomy")) {
|
||||
XmlStatsRegistry.put("iconomy", (iConomy)iConomyTemp);
|
||||
LogInfo("Hooked into iConomy");
|
||||
webserver.startiConomy();
|
||||
if (this.checkRegister()) {
|
||||
XmlStatsRegistry.put("register", (Register)registerTemp);
|
||||
LogInfo("Hooked into Register");
|
||||
webserver.startRegister();
|
||||
}
|
||||
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");
|
||||
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);
|
||||
LogInfo("Hooked into Achievements!");
|
||||
webserver.startAchievements();
|
||||
@@ -179,7 +180,7 @@ public class XmlStats extends JavaPlugin {
|
||||
Plugin StatsTemp = getServer().getPluginManager().getPlugin("Stats");
|
||||
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);
|
||||
LogInfo("Hooked into Stats!");
|
||||
webserver.startStats();
|
||||
@@ -194,8 +195,8 @@ public class XmlStats extends JavaPlugin {
|
||||
*
|
||||
* @return true, if is stats hooked
|
||||
*/
|
||||
public static boolean checkStats(){
|
||||
Stats StatsTemp = (Stats)XmlStatsRegistry.get("stats");
|
||||
public boolean checkStats(){
|
||||
Plugin StatsTemp = getServer().getPluginManager().getPlugin("Stats");
|
||||
|
||||
if(StatsTemp != null && StatsTemp.getClass().getName().equals("com.nidefawl.Stats.Stats") && StatsTemp.isEnabled()) return true;
|
||||
return false;
|
||||
@@ -206,10 +207,10 @@ public class XmlStats extends JavaPlugin {
|
||||
*
|
||||
* @return true, if is i conomy hooked
|
||||
*/
|
||||
public static boolean checkiConomy(){
|
||||
iConomy iConomyTemp = (iConomy)XmlStatsRegistry.get("iconomy");
|
||||
|
||||
if (iConomyTemp != null && iConomyTemp.getClass().getName().equals("com.iConomy.iConomy") && iConomyTemp.isEnabled()) return true;
|
||||
public boolean checkRegister(){
|
||||
Plugin registerTemp = getServer().getPluginManager().getPlugin("Register");
|
||||
|
||||
if (registerTemp != null && registerTemp.getClass().getName().equals("com.nijikokun.register.Register") && registerTemp.isEnabled() && Methods.hasMethod()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -218,8 +219,8 @@ public class XmlStats extends JavaPlugin {
|
||||
*
|
||||
* @return true, if is Achievements hooked
|
||||
*/
|
||||
public static boolean checkAchievements(){
|
||||
Achievements AchievementsTemp = (Achievements)XmlStatsRegistry.get("achievements");
|
||||
public boolean checkAchievements(){
|
||||
Plugin AchievementsTemp = getServer().getPluginManager().getPlugin("Achievements");
|
||||
|
||||
if(AchievementsTemp != null && AchievementsTemp.getClass().getName().equals("com.nidefawl.Achievements.Achievements") && AchievementsTemp.isEnabled()) return true;
|
||||
return false;
|
||||
|
||||
@@ -47,8 +47,8 @@ public class XmlStatsServerListener extends ServerListener {
|
||||
if(this.identifyPlugin(event, "achievements")){
|
||||
this.plugin.hookAchievements();
|
||||
}
|
||||
if(this.identifyPlugin(event, "iconomy")){
|
||||
this.plugin.hookiConomy();
|
||||
if(this.identifyPlugin(event, "register")){
|
||||
this.plugin.hookRegister();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user