diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index 59db640d0..72494f2ed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -101,6 +101,22 @@ public class InventoryManager extends MiniDbClientPlugin }, player.getUniqueId().toString(), category, item, count); } + public boolean validCategory(String category) + { + synchronized (_inventoryLock) + { + return _categories.containsKey(category); + } + } + + public boolean validItem(String item) + { + synchronized (_inventoryLock) + { + return _items.containsKey(item); + } + } + public Item getItem(String itemName) { Item item = null; @@ -111,8 +127,6 @@ public class InventoryManager extends MiniDbClientPlugin if (name.equalsIgnoreCase(itemName)) item = entry.getValue(); - - System.out.println(name + " " + entry.getValue().Category); } return item; diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index 4e78dedf0..c9dcd8d79 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -3,6 +3,8 @@ package mineplex.staffServer; import mineplex.core.account.CoreClientManager; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; +import mineplex.core.common.util.ProfileLoader; +import mineplex.core.common.util.UUIDFetcher; import mineplex.core.creature.Creature; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; @@ -21,8 +23,10 @@ import mineplex.staffServer.customerSupport.CustomerSupport; import mineplex.staffServer.password.Password; import mineplex.staffServer.salespackage.SalesPackageManager; import net.minecraft.server.v1_7_R4.MinecraftServer; +import net.minecraft.util.com.mojang.authlib.GameProfile; import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_7_R4.CraftServer; import org.bukkit.plugin.java.JavaPlugin; public class StaffServer extends JavaPlugin @@ -58,7 +62,7 @@ public class StaffServer extends JavaPlugin new FileUpdater(this, portal); new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this, clientManager), new StatsManager(this, clientManager))); - new Password(this, serverStatusManager.getCurrentServerName()); + //new Password(this, serverStatusManager.getCurrentServerName()); //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); @@ -66,5 +70,10 @@ public class StaffServer extends JavaPlugin MinecraftServer.getServer().getPropertyManager().setProperty("debug", true); Bukkit.getWorlds().get(0).setSpawnLocation(0, 102, 0); + + ((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("dooskee").toString(), "dooskee").loadProfile()); + ((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("Morenaa").toString(), "Morenaa").loadProfile()); + ((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("Revolark").toString(), "Revolark").loadProfile()); + ((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("EvilEsther").toString(), "EvilEsther").loadProfile()); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index af0a95c17..296498fb9 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -14,8 +14,10 @@ import mineplex.staffServer.salespackage.command.DisplayPackageCommand; import mineplex.staffServer.salespackage.command.Sales; import mineplex.staffServer.salespackage.salespackages.ApplyKits; import mineplex.staffServer.salespackage.salespackages.Coins; +import mineplex.staffServer.salespackage.salespackages.FrostLord; import mineplex.staffServer.salespackage.salespackages.GemHunter; import mineplex.staffServer.salespackage.salespackages.LifetimeHero; +import mineplex.staffServer.salespackage.salespackages.LifetimeLegend; import mineplex.staffServer.salespackage.salespackages.LifetimeUltra; import mineplex.staffServer.salespackage.salespackages.MonthlyHero; import mineplex.staffServer.salespackage.salespackages.MonthlyUltra; @@ -48,11 +50,13 @@ public class SalesPackageManager extends MiniPlugin AddSalesPackage(new MonthlyHero(this)); AddSalesPackage(new LifetimeUltra(this)); AddSalesPackage(new LifetimeHero(this)); + AddSalesPackage(new LifetimeLegend(this)); AddSalesPackage(new GemHunter(this, 4)); AddSalesPackage(new GemHunter(this, 8)); AddSalesPackage(new ApplyKits(this)); AddSalesPackage(new TreasureChests(this)); AddSalesPackage(new TreasureKeys(this)); + AddSalesPackage(new FrostLord(this)); } private void AddSalesPackage(SalesPackageBase salesPackage) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureChestCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java similarity index 58% rename from Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureChestCommand.java rename to Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java index b442868db..fa59c5699 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureChestCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java @@ -13,34 +13,48 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.server.util.TransactionResponse; import mineplex.staffServer.salespackage.SalesPackageManager; -public class TreasureChestCommand extends CommandBase +public class ItemCommand extends CommandBase { - public TreasureChestCommand(SalesPackageManager plugin) + public ItemCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "chest"); + super(plugin, Rank.MODERATOR, "item"); } @Override public void Execute(final Player caller, String[] args) { - if (args == null || args.length != 2) + if (args == null) return; final String playerName = args[0]; int amountSpecified = Integer.parseInt(args[1]); + final String category = args[2]; + String tempName = args[3]; + for (int i = 4; i < args.length; i++) + { + tempName += " " + args[i]; + } + + final String itemName = tempName; final UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName); if (uuid == null) UUIDFetcher.getUUIDOf(playerName); - if (Math.abs(amountSpecified) != 10) + final int amount = amountSpecified; + + if (!Plugin.getInventoryManager().validCategory(category)) { - UtilPlayer.message(caller, F.main(Plugin.getName(), "You have specified an invalid amount of chests.")); - amountSpecified = 0; + caller.sendMessage(F.main(Plugin.getName(), "You have entered an invalid Category.")); + return; } - final int amount = amountSpecified; + if (!Plugin.getInventoryManager().validItem(itemName)) + { + caller.sendMessage(F.main(Plugin.getName(), "You have entered an invalid Item.")); + return; + } Plugin.getDonationManager().PurchaseUnknownSalesPackage(new Callback() { @@ -51,15 +65,14 @@ public class TreasureChestCommand extends CommandBase public void run(Boolean success) { if (success) - UtilPlayer.message(caller, F.main(Plugin.getName(), playerName + " received " + amount + " Treasure Chests" + ".")); + UtilPlayer.message(caller, F.main(Plugin.getName(), playerName + " received " + amount + " " + itemName + ".")); else { - UtilPlayer.message(caller, F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " Treasure Chests.")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " " + itemName + ".")); } } - }, uuid.toString(), "Utility", "Treasure Chest", amount); + }, uuid.toString(), category, itemName, amount); } - }, playerName, uuid, "Treasure Chest " + amount, false, 0, false); - + }, playerName, uuid, (amount == 1 ? itemName : itemName + " " + amount), false, 0, false); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeLegendCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeLegendCommand.java new file mode 100644 index 000000000..540f19304 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeLegendCommand.java @@ -0,0 +1,27 @@ +package mineplex.staffServer.salespackage.command; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.staffServer.salespackage.SalesPackageManager; + +public class LifetimeLegendCommand extends CommandBase +{ + public LifetimeLegendCommand(SalesPackageManager plugin) + { + super(plugin, Rank.MODERATOR, "lifetimelegend"); + } + + @Override + public void Execute(Player caller, String[] args) + { + resetCommandCharge(caller); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " LEGEND true")); + + resetCommandCharge(caller); + Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 60000")); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java index bd155a57f..88a90a113 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java @@ -26,7 +26,7 @@ public class RankCommand extends CommandBase final Rank rankEnum = Rank.valueOf(rank); - if (rankEnum == Rank.HERO || rankEnum == Rank.ULTRA) + if (rankEnum == Rank.HERO || rankEnum == Rank.ULTRA || rankEnum == Rank.LEGEND) { Plugin.getClientManager().SaveRank(playerName, mineplex.core.common.Rank.valueOf(rank), perm); caller.sendMessage(F.main(Plugin.getName(), playerName + "'s rank has been updated to " + rank + "!")); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java index 02eb10fa0..6cc6cab0a 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java @@ -14,13 +14,13 @@ public class Sales extends MultiCommandBase AddCommand(new RankCommand(plugin)); AddCommand(new CoinCommand(plugin)); - AddCommand(new TreasureChestCommand(plugin)); - AddCommand(new TreasureKeyCommand(plugin)); + AddCommand(new ItemCommand(plugin)); AddCommand(new GemHunterCommand(plugin)); AddCommand(new UltraCommand(plugin)); AddCommand(new HeroCommand(plugin)); AddCommand(new LifetimeUltraCommand(plugin)); AddCommand(new LifetimeHeroCommand(plugin)); + AddCommand(new LifetimeLegendCommand(plugin)); AddCommand(new KitsCommand(plugin)); } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureKeyCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureKeyCommand.java deleted file mode 100644 index 73fa64ff7..000000000 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/TreasureKeyCommand.java +++ /dev/null @@ -1,64 +0,0 @@ -package mineplex.staffServer.salespackage.command; - -import java.util.UUID; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UUIDFetcher; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.server.util.TransactionResponse; -import mineplex.staffServer.salespackage.SalesPackageManager; - -public class TreasureKeyCommand extends CommandBase -{ - public TreasureKeyCommand(SalesPackageManager plugin) - { - super(plugin, Rank.MODERATOR, "key"); - } - - @Override - public void Execute(final Player caller, String[] args) - { - if (args == null || args.length != 2) - return; - - final String playerName = args[0]; - int amountSpecified = Integer.parseInt(args[1]); - - final UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName); - - if (uuid == null) - UUIDFetcher.getUUIDOf(playerName); - - if (Math.abs(amountSpecified) != 5) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "You have specified an invalid amount of keys.")); - amountSpecified = 0; - } - - final int amount = amountSpecified; - - Plugin.getDonationManager().PurchaseUnknownSalesPackage(new Callback() - { - public void run(TransactionResponse data) - { - Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback() - { - public void run(Boolean success) - { - if (success) - UtilPlayer.message(caller, F.main(Plugin.getName(), playerName + " received " + amount + " Treasure Keys" + ".")); - else - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " Treasure Keys.")); - } - } - }, uuid.toString(), "Treasure", "Treasure Key", amount); - } - }, playerName, uuid, "Treasure Key " + amount, false, 0, false); - } -} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/FrostLord.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/FrostLord.java new file mode 100644 index 000000000..e999327d4 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/FrostLord.java @@ -0,0 +1,20 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; + +import org.bukkit.entity.Player; + +public class FrostLord extends SalesPackageBase +{ + public FrostLord(SalesPackageManager manager) + { + super(manager, "Frost Lord"); + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Particle Frost Lord", "Give Frost Lord Particle."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeLegend.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeLegend.java new file mode 100644 index 000000000..c82b236d4 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeLegend.java @@ -0,0 +1,22 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; + +import org.bukkit.entity.Player; + +public class LifetimeLegend extends SalesPackageBase +{ + public LifetimeLegend(SalesPackageManager manager) + { + super(manager, "Lifetime Legend"); + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales coin " + playerName + " 60000", " 60,000 Coins"); + addButton(agent, "/sales rank " + playerName + " LEGEND true", " Lifetime Legend."); + addButton(agent, "Apply All", "/sales lifetimelegend " + playerName, " Apply all above."); + 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/TreasureChests.java index 952c39cd3..6b6fff23c 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TreasureChests.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TreasureChests.java @@ -13,7 +13,7 @@ public class TreasureChests extends SalesPackageBase public void displayToAgent(Player agent, String playerName) { - addButton(agent, "/sales chest " + playerName + " 10", "Give 10 Treasure Chests."); + addButton(agent, "/sales item " + playerName + " 10 Utility Treasure Chest", "Give 10 Treasure Chests."); agent.sendMessage(" "); addBackButton(agent, playerName); } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TreasureKeys.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TreasureKeys.java index 588a255fb..2dbb40fe7 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TreasureKeys.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/TreasureKeys.java @@ -13,7 +13,7 @@ public class TreasureKeys extends SalesPackageBase public void displayToAgent(Player agent, String playerName) { - addButton(agent, "/sales key " + playerName + " 5", "Give 5 Treasure Keys."); + addButton(agent, "/sales item " + playerName + " 5 Treasure Treasure Key", "Give 5 Treasure Keys."); agent.sendMessage(" "); addBackButton(agent, playerName); }