From 800ce686370c685cda4d929a209f4cbce88a96b5 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Sun, 10 May 2015 16:58:04 -0500 Subject: [PATCH] Add Beta Games and Player Servers to Quick game menu (text probably needs tweaking) --- .../mineplex/hub/server/ServerManager.java | 16 +++++- .../hub/server/ui/ServerGameMenu.java | 56 +++++++++++++++---- .../server/ui/button/SelectBETAButton.java | 23 ++++++++ .../server/ui/button/SelectPLAYERButton.java | 23 ++++++++ 4 files changed, 103 insertions(+), 15 deletions(-) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBETAButton.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectPLAYERButton.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index c1a058b9c..013ebce6e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -413,7 +413,7 @@ public class ServerManager extends MiniPlugin public void run(Collection serverStatusList) { _serverPlayerCounts.clear(); - + for (MinecraftServer serverStatus : serverStatusList) { if (!_serverInfoMap.containsKey(serverStatus.getName())) @@ -454,10 +454,10 @@ public class ServerManager extends MiniPlugin if (_serverKeyTagMap.containsKey(tag)) { _serverKeyInfoMap.get(_serverKeyTagMap.get(tag)).add(serverInfo); - + if (!_serverPlayerCounts.containsKey(tag)) _serverPlayerCounts.put(tag, 0); - + _serverPlayerCounts.put(tag, _serverPlayerCounts.get(tag) + serverInfo.CurrentPlayers); } } @@ -709,6 +709,16 @@ public class ServerManager extends MiniPlugin { return _serverNpcShopMap.get("Block Hunt"); } + + public ServerNpcShop getBetaShop() + { + return _serverNpcShopMap.get("Beta Games"); + } + + public ServerNpcShop getPlayerGamesShop() + { + return _serverNpcShopMap.get("Mineplex Player Servers"); + } private Vector ParseVector(String vectorString) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 6c8cbe089..49b2ccaed 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -14,6 +14,7 @@ import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.shop.page.ShopPageBase; import mineplex.hub.server.ServerManager; +import mineplex.hub.server.ui.button.SelectBETAButton; import mineplex.hub.server.ui.button.SelectBHButton; import mineplex.hub.server.ui.button.SelectBLDButton; import mineplex.hub.server.ui.button.SelectBRButton; @@ -22,6 +23,7 @@ import mineplex.hub.server.ui.button.SelectDMTButton; import mineplex.hub.server.ui.button.SelectDOMButton; import mineplex.hub.server.ui.button.SelectMINButton; import mineplex.hub.server.ui.button.SelectMSButton; +import mineplex.hub.server.ui.button.SelectPLAYERButton; import mineplex.hub.server.ui.button.SelectSGButton; import mineplex.hub.server.ui.button.SelectSSMButton; import mineplex.hub.server.ui.button.SelectTDMButton; @@ -82,14 +84,14 @@ public class ServerGameMenu extends ShopPageBase setItem(6, _superSmashCycle.get(_ssmIndex)); - setItem(8, ItemStackFactory.Instance.CreateStack(Material.BLAZE_ROD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Wizards " + C.cGray + "Last Man Standing", new String[] - { - ChatColor.RESET + "", - ChatColor.RESET + "Wield powerful spells to fight", - ChatColor.RESET + "against other players in this", - ChatColor.RESET + "exciting free-for-all brawl!", - ChatColor.RESET + "", - ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("WIZ") + ChatColor.RESET + " other players!", + setItem(8, ItemStackFactory.Instance.CreateStack(Material.BLAZE_ROD.getId(), (byte) 0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Wizards " + C.cGray + "Last Man Standing", new String[] + { + ChatColor.RESET + "", + ChatColor.RESET + "Wield powerful spells to fight", + ChatColor.RESET + "against other players in this", + ChatColor.RESET + "exciting free-for-all brawl!", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("WIZ") + ChatColor.RESET + " other players!", })); setItem(18, ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Draw My Thing " + C.cGray + "Pictionary!", new String[] @@ -142,7 +144,7 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BH") + ChatColor.RESET + " other players!", })); - setItem(36, ItemStackFactory.Instance.CreateStack(Material.WOOD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Master Builders " + C.cGray + "Creative Build", new String[] + setItem(37, ItemStackFactory.Instance.CreateStack(Material.WOOD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Master Builders " + C.cGray + "Creative Build", new String[] { ChatColor.RESET + "", ChatColor.RESET + "Players are given a Build Theme and ", @@ -152,7 +154,25 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BLD") + ChatColor.RESET + " other players!", })); - setItem(44, _minigameCycle.get(_minigameIndex)); + setItem(39, _minigameCycle.get(_minigameIndex)); + + setItem(41, ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM.getId(), (byte) 3, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Player Servers " + C.cGray + "Player Hosted Games", new String[] + { + ChatColor.RESET + "", + ChatColor.RESET + "Join your friends in their own ", + ChatColor.RESET + "Mineplex Player Server. You can play", + ChatColor.RESET + "the games you want, when you want.", + ChatColor.RESET + "", + })); + + setItem(43, ItemStackFactory.Instance.CreateStack(Material.ANVIL.getId(), (byte) 0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Beta Games " + C.cGray + "Play Unreleased Games", new String[] + { + ChatColor.RESET + "", + ChatColor.RESET + "Help test and improve our ", + ChatColor.RESET + "unreleased games.", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BETA") + ChatColor.RESET + " other players!", + })); getButtonMap().put(0, new SelectBRButton(this)); getButtonMap().put(2, new SelectSGButton(this)); @@ -165,8 +185,10 @@ public class ServerGameMenu extends ShopPageBase getButtonMap().put(22, new SelectDOMButton(this)); getButtonMap().put(24, new SelectTDMButton(this)); getButtonMap().put(26, new SelectBHButton(this)); - getButtonMap().put(36, new SelectBLDButton(this)); - getButtonMap().put(44, new SelectMINButton(this)); + getButtonMap().put(37, new SelectBLDButton(this)); + getButtonMap().put(39, new SelectMINButton(this)); + getButtonMap().put(41, new SelectPLAYERButton(this)); + getButtonMap().put(43, new SelectBETAButton(this)); } @SuppressWarnings("deprecation") @@ -493,4 +515,14 @@ public class ServerGameMenu extends ShopPageBase { getPlugin().getBuildShop().attemptShopOpen(player); } + + public void openBeta(Player player) + { + getPlugin().getBetaShop().attemptShopOpen(player); + } + + public void openPlayerGames(Player player) + { + getPlugin().getPlayerGamesShop().attemptShopOpen(player); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBETAButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBETAButton.java new file mode 100644 index 000000000..8e062b27a --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBETAButton.java @@ -0,0 +1,23 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectBETAButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectBETAButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openBeta(player); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectPLAYERButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectPLAYERButton.java new file mode 100644 index 000000000..0359ebcbf --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectPLAYERButton.java @@ -0,0 +1,23 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectPLAYERButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectPLAYERButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openPlayerGames(player); + } +}