From 17543910b5f90ab8fe9e4a6e7671ca7497fce769 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 14 Feb 2015 15:09:42 -0800 Subject: [PATCH] Added Chest packages to support server. Fixed Punish not loading. --- .../mineplex/core/common/util/UtilSystem.java | 10 ++++- .../core/server/remotecall/JsonWebCall.java | 2 + .../src/mineplex/staffServer/StaffServer.java | 6 ++- .../customerSupport/CustomerSupport.java | 39 ++++++++++++------- .../salespackage/SalesPackageManager.java | 18 ++++++--- .../{TreasureKeys.java => AncientChest.java} | 8 ++-- ...TreasureChests.java => MythicalChest.java} | 8 ++-- .../salespackage/salespackages/OldChest.java | 20 ++++++++++ .../salespackages/SalesPackageBase.java | 1 - 9 files changed, 81 insertions(+), 31 deletions(-) rename Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/{TreasureKeys.java => AncientChest.java} (55%) rename Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/{TreasureChests.java => MythicalChest.java} (54%) create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/OldChest.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSystem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSystem.java index 36141923f..58621a78f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSystem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSystem.java @@ -2,11 +2,19 @@ package mineplex.core.common.util; public class UtilSystem { - public static void PrintStackTrace() + public static void printStackTrace() { for (StackTraceElement trace : Thread.currentThread().getStackTrace()) { System.out.println(trace.toString()); } } + + public static void printStackTrace(StackTraceElement[] stackTrace) + { + for (StackTraceElement trace : stackTrace) + { + System.out.println(trace.toString()); + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/server/remotecall/JsonWebCall.java b/Plugins/Mineplex.Core/src/mineplex/core/server/remotecall/JsonWebCall.java index 412f7e7f4..fb07a0d82 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/server/remotecall/JsonWebCall.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/server/remotecall/JsonWebCall.java @@ -7,6 +7,7 @@ import java.io.InputStreamReader; import java.lang.reflect.Type; import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UtilSystem; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; @@ -312,6 +313,7 @@ public class JsonWebCall catch (Exception ex) { System.out.println("Error executing JsonWebCall: \n" + ex.getMessage()); + UtilSystem.printStackTrace(ex.getStackTrace()); System.out.println("Result: \n" + result); } finally diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index 8872962c6..290de3835 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -1,6 +1,7 @@ package mineplex.staffServer; import mineplex.core.account.CoreClientManager; +import mineplex.core.antihack.AntiHack; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; import mineplex.core.common.util.ProfileLoader; @@ -50,7 +51,7 @@ public class StaffServer extends JavaPlugin DonationManager donationManager = new DonationManager(this, clientManager, webServerAddress); - new Punish(this, webServerAddress, clientManager); + Punish punish = new Punish(this, webServerAddress, clientManager); new NpcManager(this, new Creature(this)); ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager); @@ -60,7 +61,8 @@ public class StaffServer extends JavaPlugin new Chat(this, clientManager, preferenceManager, serverStatusManager.getCurrentServerName()); new MemoryFix(this); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - + AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); + new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this, clientManager), new StatsManager(this, clientManager))); //new Password(this, serverStatusManager.getCurrentServerName()); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 9e7ea2545..ead4f7611 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -106,8 +106,9 @@ public class CustomerSupport extends MiniPlugin int coinTransactionTotal = 0; int enjinCoinsReceived = 0; int coinSpentTotal = 0; - int chestsReceived = 0; - int keysReceived = 0; + int oldChestsReceived = 0; + int ancientChestsReceived = 0; + int mythicalChestsReceived = 0; for (CoinTransactionToken transaction : donor.getCoinTransactions()) { @@ -124,35 +125,45 @@ public class CustomerSupport extends MiniPlugin { coinSpentTotal += transaction.Coins; - if (transaction.SalesPackageName.startsWith("Treasure Chest")) + if (transaction.SalesPackageName.startsWith("Old Chest")) { if (transaction.Coins == 0 && transaction.Gems == 0) { if (transaction.SalesPackageName.split(" ").length == 3) - chestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]); + oldChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]); else if (transaction.SalesPackageName.split(" ").length == 2) - chestsReceived += Integer.parseInt(transaction.SalesPackageName.replace("Treasure Chest", "")); + oldChestsReceived += 1; } } - else if (transaction.SalesPackageName.startsWith("Treasure Key")) + if (transaction.SalesPackageName.startsWith("Ancient Chest")) { - if (transaction.SalesPackageName.split(" ").length == 3) - keysReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]); - else if (transaction.SalesPackageName.split(" ").length == 2) + if (transaction.Coins == 0 && transaction.Gems == 0) { - String modifiedString = transaction.SalesPackageName.replace("Treasure Key", ""); + if (transaction.SalesPackageName.split(" ").length == 3) + ancientChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]); + else if (transaction.SalesPackageName.split(" ").length == 2) + ancientChestsReceived += 1; + } - if (modifiedString.length() > 0) - keysReceived += Integer.parseInt(modifiedString); + } + if (transaction.SalesPackageName.startsWith("Mythical Chest")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 3) + mythicalChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]); + else if (transaction.SalesPackageName.split(" ").length == 2) + mythicalChestsReceived += 1; } } } caller.sendMessage(C.cBlue + "Enjin Coin Total Received : " + C.cYellow + enjinCoinsReceived); - caller.sendMessage(C.cBlue + "Treasure Chests Received : " + C.cYellow + chestsReceived); - caller.sendMessage(C.cBlue + "Treasure Keys Received : " + C.cYellow + keysReceived); + caller.sendMessage(C.cBlue + "Old Chests Received : " + C.cYellow + oldChestsReceived); + caller.sendMessage(C.cBlue + "Ancient Chests Received : " + C.cYellow + ancientChestsReceived); + caller.sendMessage(C.cBlue + "Mythical Chests Received : " + C.cYellow + mythicalChestsReceived); int coinsMissing = coinTransactionTotal - (donor.getCoins() + coinSpentTotal); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index 296498fb9..9f59f9c50 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -12,6 +12,7 @@ import mineplex.core.inventory.InventoryManager; import mineplex.core.stats.StatsManager; import mineplex.staffServer.salespackage.command.DisplayPackageCommand; import mineplex.staffServer.salespackage.command.Sales; +import mineplex.staffServer.salespackage.salespackages.AncientChest; import mineplex.staffServer.salespackage.salespackages.ApplyKits; import mineplex.staffServer.salespackage.salespackages.Coins; import mineplex.staffServer.salespackage.salespackages.FrostLord; @@ -21,9 +22,9 @@ import mineplex.staffServer.salespackage.salespackages.LifetimeLegend; import mineplex.staffServer.salespackage.salespackages.LifetimeUltra; import mineplex.staffServer.salespackage.salespackages.MonthlyHero; import mineplex.staffServer.salespackage.salespackages.MonthlyUltra; +import mineplex.staffServer.salespackage.salespackages.MythicalChest; import mineplex.staffServer.salespackage.salespackages.SalesPackageBase; -import mineplex.staffServer.salespackage.salespackages.TreasureChests; -import mineplex.staffServer.salespackage.salespackages.TreasureKeys; +import mineplex.staffServer.salespackage.salespackages.OldChest; public class SalesPackageManager extends MiniPlugin { @@ -54,8 +55,9 @@ public class SalesPackageManager extends MiniPlugin AddSalesPackage(new GemHunter(this, 4)); AddSalesPackage(new GemHunter(this, 8)); AddSalesPackage(new ApplyKits(this)); - AddSalesPackage(new TreasureChests(this)); - AddSalesPackage(new TreasureKeys(this)); + AddSalesPackage(new OldChest(this)); + AddSalesPackage(new AncientChest(this)); + AddSalesPackage(new MythicalChest(this)); AddSalesPackage(new FrostLord(this)); } @@ -98,7 +100,8 @@ public class SalesPackageManager extends MiniPlugin public void displaySalesPackages(Player caller, String playerName) { JsonMessage coinBuilder = new JsonMessage("Coins : ").color("blue"); - JsonMessage packageBuilder = new JsonMessage("Rank Packages : ").color("blue"); + JsonMessage packageBuilder = new JsonMessage("Rank Packages : ").color("blue"); + JsonMessage chestBuilder = new JsonMessage("Chest Packages : ").color("blue"); for (SalesPackageBase salesPackage : _salesPackages.values()) { @@ -106,6 +109,10 @@ public class SalesPackageManager extends MiniPlugin { coinBuilder = coinBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); } + else if (salesPackage instanceof MythicalChest || salesPackage instanceof AncientChest || salesPackage instanceof OldChest) + { + chestBuilder = chestBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); + } else { packageBuilder = packageBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); @@ -113,6 +120,7 @@ public class SalesPackageManager extends MiniPlugin } coinBuilder.sendToPlayer(caller); + chestBuilder.sendToPlayer(caller); packageBuilder.sendToPlayer(caller); } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TreasureKeys.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/AncientChest.java similarity index 55% rename from Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TreasureKeys.java rename to Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/AncientChest.java index 2dbb40fe7..f35b2089e 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TreasureKeys.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/AncientChest.java @@ -4,16 +4,16 @@ import mineplex.staffServer.salespackage.SalesPackageManager; import org.bukkit.entity.Player; -public class TreasureKeys extends SalesPackageBase +public class AncientChest extends SalesPackageBase { - public TreasureKeys(SalesPackageManager manager) + public AncientChest(SalesPackageManager manager) { - super(manager, "5 Treasure Keys"); + super(manager, "1 Ancient Chest"); } public void displayToAgent(Player agent, String playerName) { - addButton(agent, "/sales item " + playerName + " 5 Treasure Treasure Key", "Give 5 Treasure Keys."); + addButton(agent, "/sales item " + playerName + " 1 Item Ancient Chest", "Give 1 Ancient Chest."); agent.sendMessage(" "); addBackButton(agent, playerName); } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TreasureChests.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/MythicalChest.java similarity index 54% rename from Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TreasureChests.java rename to Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/MythicalChest.java index 6b6fff23c..b71abb007 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TreasureChests.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/MythicalChest.java @@ -4,16 +4,16 @@ import mineplex.staffServer.salespackage.SalesPackageManager; import org.bukkit.entity.Player; -public class TreasureChests extends SalesPackageBase +public class MythicalChest extends SalesPackageBase { - public TreasureChests(SalesPackageManager manager) + public MythicalChest(SalesPackageManager manager) { - super(manager, "10 Treasure Chests"); + super(manager, "1 Mythical Chest"); } public void displayToAgent(Player agent, String playerName) { - addButton(agent, "/sales item " + playerName + " 10 Utility Treasure Chest", "Give 10 Treasure Chests."); + addButton(agent, "/sales item " + playerName + " 1 Item Mythical Chest", "Give 1 Mythical Chest."); agent.sendMessage(" "); addBackButton(agent, playerName); } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/OldChest.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/OldChest.java new file mode 100644 index 000000000..566bbe211 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/OldChest.java @@ -0,0 +1,20 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; + +import org.bukkit.entity.Player; + +public class OldChest extends SalesPackageBase +{ + public OldChest(SalesPackageManager manager) + { + super(manager, "1 Old Chest"); + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Item Old Chest", "Give 1 Old Chest."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/SalesPackageBase.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/SalesPackageBase.java index dd0f3b588..eb8f49529 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/SalesPackageBase.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/SalesPackageBase.java @@ -1,7 +1,6 @@ package mineplex.staffServer.salespackage.salespackages; import mineplex.core.common.jsonchat.JsonMessage; -import mineplex.core.common.util.UtilServer; import mineplex.staffServer.salespackage.SalesPackageManager; import org.bukkit.entity.Player;