From 7f98157890853d005b8bd35da0b581d00c6ed357 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 14 Jul 2015 20:38:30 -0500 Subject: [PATCH] More work/fixes --- .../core/account/command/UpdateRank.java | 2 +- .../src/mineplex/core/shop/ShopBase.java | 2 - .../core/shop/page/ConfirmationPage.java | 55 +++++++++++++++---- .../teleport/command/TeleportCommand.java | 2 +- .../game/clans/clans/ClanEnergyManager.java | 2 +- .../game/clans/clans/ClansDisplay.java | 2 +- .../game/clans/clans/ClansManager.java | 2 +- .../clans/clans/commands/ClansCommand.java | 2 +- .../game/clans/clans/map/ItemMapManager.java | 8 ++- .../game/clans/clans/map/ItemMapRenderer.java | 17 ++++-- .../elements/ScoreboardElementClan.java | 2 +- .../clans/worldevent/WorldEventManager.java | 5 ++ .../game/clans/economy/GoldManager.java | 5 +- .../mineplex/game/clans/items/CustomItem.java | 6 +- .../game/clans/items/GearManager.java | 2 +- .../game/clans/shop/farming/FarmingPage.java | 14 ++--- 16 files changed, 88 insertions(+), 40 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java index 8a7efe8fe..8ba37d68a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java @@ -52,7 +52,7 @@ public class UpdateRank extends CommandBase final Rank rank = tempRank; - if (rank == Rank.ADMIN || rank == Rank.YOUTUBE || rank == Rank.TWITCH || rank == Rank.MODERATOR || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR) + if (rank == Rank.ADMIN || rank == Rank.YOUTUBE || rank == Rank.JNR_DEV || rank == Rank.TWITCH || rank == Rank.MODERATOR || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR) { if (rank == Rank.ADMIN && !Plugin.hasRank(caller, Rank.LT)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java index b08f2098a..08037eae5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java @@ -173,8 +173,6 @@ public abstract class ShopBase implements Listene @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInventoryOpen(InventoryOpenEvent event) { - System.out.println("On Inventory Open"); - if (true) return; if (_playerPageMap.containsKey(event.getPlayer().getName()) && _playerPageMap.get(event.getPlayer().getName()).getTitle() != null && _playerPageMap.get(event.getPlayer().getName()).getTitle().equalsIgnoreCase(event.getInventory().getTitle())) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java index 0d462ce87..6e4ec5264 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java @@ -128,26 +128,57 @@ public class ConfirmationPage() + int goldCount = getDonationManager().Get(getPlayer()).getGold(); + int cost = _salesItem.GetCost(getCurrencyType()); + + if (cost > goldCount) + showResultsPage(TransactionResponse.InsufficientFunds); + else { - public void run(TransactionResponse response) + getDonationManager().RewardGold(new Callback() { - showResultsPage(response); - } - }, getPlayer().getName(), getPlayer().getUniqueId(), _salesItem.GetCost(getCurrencyType()), _salesItem.GetSalesPackageId()); + @Override + public void run(Boolean data) + { + if (data) + { + showResultsPage(TransactionResponse.Success); + } + else + { + showResultsPage(TransactionResponse.Failed); + } + } + }, "Energy Purchase", getPlayer().getName(), getClientManager().Get(getPlayer()).getAccountId(), -cost); + + } + } else { - getDonationManager().PurchaseUnknownSalesPackage(new Callback() + if (_salesItem.IsKnown()) { - public void run(TransactionResponse response) + getDonationManager().PurchaseKnownSalesPackage(new Callback() { - showResultsPage(response); - } - }, getPlayer().getName(), getClientManager().Get(getPlayer()).getAccountId(), _salesItem.GetName(), getCurrencyType(), _salesItem.GetCost(getCurrencyType()), _salesItem.OneTimePurchase()); + public void run(TransactionResponse response) + { + showResultsPage(response); + } + }, getPlayer().getName(), getPlayer().getUniqueId(), _salesItem.GetCost(getCurrencyType()), _salesItem.GetSalesPackageId()); + } + else + { + getDonationManager().PurchaseUnknownSalesPackage(new Callback() + { + public void run(TransactionResponse response) + { + showResultsPage(response); + } + }, getPlayer().getName(), getClientManager().Get(getPlayer()).getAccountId(), _salesItem.GetName(), getCurrencyType(), _salesItem.GetCost(getCurrencyType()), _salesItem.OneTimePurchase()); + } } _taskId = getPlugin().getScheduler().scheduleSyncRepeatingTask(getPlugin().getPlugin(), this, 2L, 2L); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java index 7ca0a1f23..33674f94b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java @@ -12,7 +12,7 @@ public class TeleportCommand extends MultiCommandBase { public TeleportCommand(Teleport plugin) { - super(plugin, Rank.MODERATOR, "tp", "teleport"); + super(plugin, Rank.ADMIN, "tp", "teleport"); AddCommand(new AllCommand(plugin)); AddCommand(new BackCommand(plugin)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java index efc843af6..38ccfd24f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java @@ -96,6 +96,6 @@ public class ClanEnergyManager extends MiniPlugin implements Runnable public int convertEnergyToGold(int energy) { - return (energy / 4) + (energy % 4 == 0 ? 0 : 1); + return (energy / 8) + (energy % 8 == 0 ? 0 : 1); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java index 8f3cf6089..1d2ce4a91 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java @@ -119,7 +119,7 @@ public class ClansDisplay extends MiniPlugin } UtilTextMiddle.display("", ownerString, 0, 25, 10, player); - UtilPlayer.message(player, F.main("Clans", ownerString)); + UtilPlayer.message(player, F.main("Territory", ownerString)); } public int width = 8; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 254a48b46..2ee137ed8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -150,7 +150,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat _clanDisplay = new ClansDisplay(plugin, this); _clanGame = new ClansGame(plugin, this); _clanUtility = new ClansUtility(this); - _itemMapManager = new ItemMapManager(this); + _itemMapManager = new ItemMapManager(this, _worldEvent); Energy energy = new Energy(plugin); // TODO: Re-enable customtagfix with NCP update? diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 4d6f28a55..dbf12ee99 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -29,7 +29,7 @@ public class ClansCommand extends CommandBase public ClansCommand(ClansManager plugin) { - super(plugin, Rank.ALL, "c", "clans", "f", "factions"); + super(plugin, Rank.ALL, "c", "clans", "factions"); _manager = plugin; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java index 5ebff8a0c..9560beae7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java @@ -27,6 +27,8 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility; +import mineplex.game.clans.clans.worldevent.WorldEventManager; + import net.minecraft.server.v1_7_R4.Block; import net.minecraft.server.v1_7_R4.Blocks; import net.minecraft.server.v1_7_R4.MaterialMapColor; @@ -73,12 +75,14 @@ public class ItemMapManager extends MiniPlugin private HashMap _scale = new HashMap(); private ArrayList> _scanList = new ArrayList>(); private World _world; + private WorldEventManager _eventManager; - public ItemMapManager(ClansManager clansManager) + public ItemMapManager(ClansManager clansManager, WorldEventManager eventManager) { super("ItemMapManager", clansManager.getPlugin()); _clansUtility = clansManager.getClanUtility(); + _eventManager = eventManager; _comparator = new Comparator>() { @@ -233,7 +237,7 @@ public class ItemMapManager extends MiniPlugin view.removeRenderer(renderer); } - view.addRenderer(new ItemMapRenderer(this)); + view.addRenderer(new ItemMapRenderer(this, _eventManager)); } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java index 2a3926a6a..97f00b479 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java @@ -3,6 +3,9 @@ package mineplex.game.clans.clans.map; import java.awt.Color; import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.clans.worldevent.event.EventState; +import mineplex.game.clans.clans.worldevent.event.WorldEvent; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -17,12 +20,14 @@ import org.bukkit.map.MapView; public class ItemMapRenderer extends MapRenderer { private ItemMapManager _manager; + private WorldEventManager _eventManager; - public ItemMapRenderer(ItemMapManager itemMapManager) + public ItemMapRenderer(ItemMapManager itemMapManager, WorldEventManager eventManager) { super(true); _manager = itemMapManager; + _eventManager = eventManager; } @Override @@ -187,8 +192,12 @@ public class ItemMapRenderer extends MapRenderer cursors.removeCursor(cursors.getCursor(0)); } - /*for (Location point : points) + for (WorldEvent event : _eventManager.getEvents()) { + if (event.getState() != EventState.LIVE) + continue; + + Location point = event.getCenterLocation(); double mapX = (point.getX() - info.getX()) / zoom; double mapZ = (point.getZ() - info.getZ()) / zoom; @@ -198,7 +207,7 @@ public class ItemMapRenderer extends MapRenderer byte b0 = (byte) (int) Math.min(127, (double) (mapX * 2.0F) + 0.5D); byte b1 = (byte) (int) Math.max(-127, (double) (mapZ * 2.0F) + 0.5D); - byte cursorType = 5; // http://i.imgur.com/wpH6PT8.png + byte cursorType = 4; // http://i.imgur.com/wpH6PT8.png // Those are byte 5 and 6 byte rotation = (byte) (int) ((point.getYaw() * 16D) / 360D); @@ -206,7 +215,7 @@ public class ItemMapRenderer extends MapRenderer cursors.addCursor(cursor); } - }*/ + } for (Player other : Bukkit.getOnlinePlayers()) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java index 0f6a689fc..be1b0d97f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/elements/ScoreboardElementClan.java @@ -38,7 +38,7 @@ public class ScoreboardElementClan implements ScoreboardElement } else { - output.add(C.cGreen + "You are not in a clan"); + output.add(C.cGreen + "You are not in a Clan"); } return output; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index 56f2cbd83..15c5d6bfa 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -245,6 +245,11 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return _blockRestore; } + public List getEvents() + { + return _events; + } + @EventHandler public void gear(PlayerCommandPreprocessEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java index 51c710292..aa3ff2130 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java @@ -40,7 +40,7 @@ import mineplex.minecraft.game.core.condition.ConditionManager; public class GoldManager extends MiniPlugin { - public static final int GEM_CONVERSION_RATE = 50; // The number of gold coins when converted from a single gem + public static final int GEM_CONVERSION_RATE = 5; // The number of gold coins when converted from a single gem public static final double DEATH_TAX = 0.04d; // Percentage of gold lost on death public static final String META_STRING = "clans.goldAmount"; @@ -155,7 +155,8 @@ public class GoldManager extends MiniPlugin { deductGems(player, gemAmount); addGold(player, goldCount); - notify(player, String.format("You have transferred %d gems into %d gold coins!", gemCount, goldCount)); + _transferTracker.insertTransfer(player); + notify(player, String.format("You have transferred %d gems into %d gold coins!", gemAmount, goldCount)); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java index ca1ff7dcb..71f371d27 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java @@ -131,7 +131,7 @@ public class CustomItem public void onInteract(PlayerInteractEvent event) { - System.out.println("Triggered interact!"); +// System.out.println("Triggered interact!"); for (ItemAttribute attribute : getAttributes()) { attribute.onInteract(event); @@ -140,7 +140,7 @@ public class CustomItem public void onAttack(CustomDamageEvent event) { - System.out.println("Triggered attack!"); +// System.out.println("Triggered attack!"); for (ItemAttribute attribute : getAttributes()) { attribute.onAttack(event); @@ -149,7 +149,7 @@ public class CustomItem public void onAttacked(CustomDamageEvent event) { - System.out.println("Triggered damage!"); +// System.out.println("Triggered damage!"); for (ItemAttribute attribute : getAttributes()) { attribute.onAttacked(event); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index 569291616..c2e016591 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -368,7 +368,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable if (packet instanceof PacketPlayOutSetSlot) { - System.out.println("Item slot packet!"); +// System.out.println("Item slot packet!"); PacketPlayOutSetSlot slotPacket = (PacketPlayOutSetSlot) packet; net.minecraft.server.v1_7_R4.ItemStack original = slotPacket.c; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/farming/FarmingPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/farming/FarmingPage.java index 8f5973fe3..04e0d96ae 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/farming/FarmingPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/farming/FarmingPage.java @@ -22,13 +22,13 @@ public class FarmingPage extends ShopPageBase @Override protected void buildPage() { - addShopItem(1, Material.POTATO, 10, 5); - addShopItem(2, Material.MELON, 10, 5); - addShopItem(3, Material.BREAD, 30, 20); - addShopItem(4, Material.COOKED_BEEF, 50, 35); - addShopItem(5, Material.COOKED_CHICKEN, 50, 35); - addShopItem(6, Material.FEATHER, 50, 25); - addShopItem(7, Material.CARROT, 6, 3); + addShopItem(1, Material.POTATO, 15, 3); + addShopItem(2, Material.MELON, 5, 1); + addShopItem(3, Material.BREAD, 30, 6); + addShopItem(4, Material.COOKED_BEEF, 50, 10); + addShopItem(5, Material.COOKED_CHICKEN, 35, 7); + addShopItem(6, Material.FEATHER, 50, 10); + addShopItem(7, Material.CARROT, 10, 2); } public void addShopItem(int slot, Material material, int buyPrice, int sellPrice)