From 317c2ac08efdd6c37d72b8cfd6cff09bd397e661 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 19 Apr 2018 22:23:07 +0100 Subject: [PATCH] Fix gadgets inside the glads arena --- .../src/mineplex/hub/hubgame/HubGame.java | 6 -- .../mineplex/hub/hubgame/HubGameManager.java | 28 ++---- .../src/mineplex/hub/hubgame/duel/Duels.java | 6 -- .../mineplex/hub/hubgame/duel/DuelsUI.java | 87 ------------------- .../mineplex/hub/hubgame/ui/HubGamePage.java | 77 ---------------- 5 files changed, 6 insertions(+), 198 deletions(-) delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/duel/DuelsUI.java delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/ui/HubGamePage.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/HubGame.java b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/HubGame.java index 150853d8a..8f739e712 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/HubGame.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/HubGame.java @@ -16,7 +16,6 @@ import mineplex.core.lifetimes.PhasedLifetime; import mineplex.core.newnpc.NPC; import mineplex.hub.hubgame.CycledGame.GameState; import mineplex.hub.hubgame.common.HubGameComponent; -import mineplex.hub.hubgame.ui.HubGamePage; import mineplex.hub.world.WorldDataModule; public abstract class HubGame extends PhasedLifetime implements Listener @@ -95,9 +94,4 @@ public abstract class HubGame extends PhasedLifetime implements Liste { getAlivePlayers().forEach(player -> player.sendMessage(F.main(getManager().getName(), message))); } - - public HubGamePage getInformationPage(Player player) - { - return new HubGamePage<>(getManager(), getManager().getShop(), getManager().getClientManager(), getManager().getDonationManager(), player, this); - } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/HubGameManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/HubGameManager.java index a34d9de3d..9d39112e8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/HubGameManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/HubGameManager.java @@ -28,6 +28,7 @@ import mineplex.core.gadget.types.GadgetType; import mineplex.core.newnpc.NPC; import mineplex.core.newnpc.NewNPCManager; import mineplex.core.newnpc.event.NPCInteractEvent; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; @@ -72,7 +73,7 @@ public class HubGameManager extends MiniPlugin _hubManager = require(HubManager.class); _hotbarManager = require(HubPlayerManager.class); _npcManager = require(NewNPCManager.class); - WorldDataModule worldData = require(WorldDataModule.class); + WorldDataModule worldData = require(WorldDataModule.class); _shop = new HubGameShop(this, _clientManager, _donationManager); _games = new ArrayList<>(); @@ -101,7 +102,7 @@ public class HubGameManager extends MiniPlugin @EventHandler public void npcInteract(NPCInteractEvent event) { - if (event.isCancelled()) + if (event.isCancelled() || !Recharge.Instance.use(event.getPlayer(), "Hub Game NPC Interact", 1000, false, false)) { return; } @@ -122,37 +123,20 @@ public class HubGameManager extends MiniPlugin CycledGame cycledGame = (CycledGame) game; List queuedPlayers = cycledGame.getQueuedPlayers(); - if (event.isLeftClick()) + if (queuedPlayers.contains(player)) { - if (queuedPlayers.contains(player)) - { - leaveQueue(cycledGame, player, false); - } - else - { - joinQueue(cycledGame, player); - } + leaveQueue(cycledGame, player, false); } else { - showInformationPage(game, player); + joinQueue(cycledGame, player); } } - else - { - showInformationPage(game, player); - } return; } } - @SuppressWarnings("unchecked") - private void showInformationPage(HubGame game, Player player) - { - _shop.openPageForPlayer(player, game.getInformationPage(player)); - } - private void disableGadgets(Player player, GadgetType type) { _gadgetManager.getGadgets(type).forEach(gadget -> gadget.disable(player)); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/duel/Duels.java b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/duel/Duels.java index b86489359..a95e70e1e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/duel/Duels.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/duel/Duels.java @@ -136,10 +136,4 @@ public class Duels extends CycledGame event.setCancelled(true); } } - -// @Override -// public HubGamePage getInformationPage(Player player) -// { -// return new DuelsUI(getManager(), getManager().getShop(), getManager().getClientManager(), getManager().getDonationManager(), player, this); -// } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/duel/DuelsUI.java b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/duel/DuelsUI.java deleted file mode 100644 index 3c2936e4f..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/duel/DuelsUI.java +++ /dev/null @@ -1,87 +0,0 @@ -package mineplex.hub.hubgame.duel; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilTime; -import mineplex.core.donation.DonationManager; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.hub.hubgame.HubGameManager; -import mineplex.hub.hubgame.common.damage.PVPTrackerComponent; -import mineplex.hub.hubgame.common.damage.PVPTrackerComponent.Match; -import mineplex.hub.hubgame.ui.HubGamePage; -import mineplex.hub.hubgame.ui.HubGameShop; - -public class DuelsUI extends HubGamePage -{ - - private static final ItemStack NO_MATCH = new ItemBuilder(Material.STAINED_GLASS_PANE, (byte) 14) - .setTitle(C.cRed + "No match info") - .build(); - private static final ItemStack EDIT_KIT = new ItemBuilder(Material.ANVIL) - .setTitle(C.cGreen + "Edit Kit") - .addLore("", "You can edit the order items are", "given to you in the game.", "", C.cRed + "Coming Soon") - .build(); - - public DuelsUI(HubGameManager plugin, HubGameShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, Duels game) - { - super(plugin, shop, clientManager, donationManager, player, game, 45); - } - - @Override - protected void buildPage() - { - super.buildPage(); - - PVPTrackerComponent tracker = _game.getComponent(PVPTrackerComponent.class); - int slot = 20; - int index = 0; - - for (Match match : tracker.getMatches()) - { - index++; - addButton(slot++, getMatchItem(match, getPlayer()), (player, clickType) -> - { - tracker.sendMatch(player, match); - player.closeInventory(); - }); - } - - for (; index < 5; index++) - { - addButtonNoAction(slot++, NO_MATCH); - } - - addButtonNoAction(31, EDIT_KIT); - } - - private ItemStack getMatchItem(Match match, Player player) - { - Player[] players = match.getPlayers(); - boolean playerGame = false; - - for (Player other : players) - { - // Player may relog, thus player objects won't be the same - if (other.getUniqueId().equals(player.getUniqueId())) - { - playerGame = true; - break; - } - } - - return new ItemBuilder(Material.IRON_SWORD) - .setTitle(C.cGreen + players[0].getName() + C.cWhiteB + " v " + C.cGreen + players[1].getName()) - .addLore( - "", - C.cWhite + "Match Time: " + C.mTime + UtilTime.MakeStr(System.currentTimeMillis() - match.getStart()) + C.cWhite + " ago.", - "", - C.cGreen + "Click to find out more information about this match" - ) - .setGlow(playerGame) - .build(); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/ui/HubGamePage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/ui/HubGamePage.java deleted file mode 100644 index c38cc7c6a..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/ui/HubGamePage.java +++ /dev/null @@ -1,77 +0,0 @@ -package mineplex.hub.hubgame.ui; - -import java.util.List; - -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.donation.DonationManager; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.shop.page.ShopPageBase; -import mineplex.hub.hubgame.CycledGame; -import mineplex.hub.hubgame.HubGame; -import mineplex.hub.hubgame.HubGameManager; -import mineplex.hub.hubgame.HubGameType; - -public class HubGamePage extends ShopPageBase -{ - - protected final T _game; - - public HubGamePage(HubGameManager plugin, HubGameShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, T game) - { - this(plugin, shop, clientManager, donationManager, player, game, 27); - } - - public HubGamePage(HubGameManager plugin, HubGameShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, T game, int slots) - { - super(plugin, shop, clientManager, donationManager, game.getGameType().getName(), player, slots); - - _game = game; - - buildPage(); - } - - @Override - protected void buildPage() - { - HubGameType gameType = _game.getGameType(); - ItemBuilder builder = new ItemBuilder(gameType.getItemStack()); - - builder.setTitle(C.cYellow + gameType.getName()); - builder.addLore(""); - builder.addLore(gameType.getDescription()); - builder.addLore("", "Alive Players: " + C.cYellow + _game.getAlivePlayers().size()); - - if (_game instanceof CycledGame) - { - List queue = ((CycledGame) _game).getQueuedPlayers(); - int index = queue.indexOf(getPlayer()); - - builder.addLore("", "Queue Position: " + C.cYellow + (index == -1 ? "Not in queue" : (index + 1) + C.cGray + "/" + C.cYellow + queue.size())); - builder.addLore("", C.cGreen + (index == -1 ? "Click to join the queue." : "Click to leave the queue.")); - } - - addButton(13, builder.build(), (player, clickType) -> - { - if (_game instanceof CycledGame) - { - CycledGame game = (CycledGame) _game; - List queue = game.getQueuedPlayers(); - int index = queue.indexOf(getPlayer()); - - if (index == -1) - { - _game.getManager().joinQueue(game, player); - } - else - { - _game.getManager().leaveQueue(game, player, false); - } - - player.closeInventory(); - } - }); - } -}