From 83218c9a7320d44ce5cfe0aceae7985b4e6647a4 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 16 Dec 2014 11:42:06 -0600 Subject: [PATCH] Pushing unfinished code for laptop --- .../core/account/CoreClientManager.java | 8 +- .../src/mineplex/core/chat/Chat.java | 2 +- .../core/shop/item/ComplexButton.java | 14 +- .../mineplex/core/shop/page/ShopPageBase.java | 8 +- .../game/arcade/gui/GameHostShop.java | 30 ++++ .../game/arcade/gui/button/BanButton.java | 27 ++++ .../arcade/gui/button/EditRotationButton.java | 7 + .../arcade/gui/button/GiveAdminButton.java | 27 ++++ .../game/arcade/gui/button/SetGameButton.java | 7 + .../arcade/gui/button/ToggleOpenButton.java | 7 + .../game/arcade/gui/button/UnbanButton.java | 28 ++++ .../game/arcade/gui/page/BanPage.java | 71 ++++++++++ .../arcade/gui/page/GameHostMenuPage.java | 61 ++++++++ .../game/arcade/gui/page/GameHostPage.java | 68 +++++++++ .../game/arcade/gui/page/GiveAdminPage.java | 67 +++++++++ .../game/arcade/gui/page/UnbanPage.java | 69 +++++++++ .../game/arcade/managers/GameChatManager.java | 2 +- .../game/arcade/managers/GameHostManager.java | 132 +++++++++++++----- 18 files changed, 588 insertions(+), 47 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/GameHostShop.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/BanButton.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/EditRotationButton.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/GiveAdminButton.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/SetGameButton.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/ToggleOpenButton.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/UnbanButton.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/BanPage.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/GameHostMenuPage.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/GameHostPage.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/GiveAdminPage.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/UnbanPage.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 0981410ef..575e2f07e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -446,10 +446,10 @@ public class CoreClientManager extends MiniPlugin if (event.getType() != UpdateType.SLOWER) return; - System.out.println("====="); - System.out.println("Connecting : " + _clientsConnecting.get()); - System.out.println("Processing : " + _clientsProcessing.get()); - System.out.println("====="); +// System.out.println("====="); +// System.out.println("Connecting : " + _clientsConnecting.get()); +// System.out.println("Processing : " + _clientsProcessing.get()); +// System.out.println("====="); } public void addStoredProcedureLoginProcessor(ILoginProcessor processor) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index 00cb2f4d9..23dc80f2c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -110,7 +110,7 @@ public class Chat extends MiniPlugin @EventHandler public void preventMe(PlayerCommandPreprocessEvent event) { - if (event.getMessage().toLowerCase().startsWith("/me") + if (event.getMessage().toLowerCase().startsWith("/me ") || event.getMessage().toLowerCase().startsWith("/bukkit")) { event.getPlayer().sendMessage(F.main(getName(), "No, you!")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ComplexButton.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ComplexButton.java index c4105948c..7c67e9d5f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ComplexButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ComplexButton.java @@ -1,6 +1,8 @@ package mineplex.core.shop.item; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.InventoryClickEvent; public abstract class ComplexButton implements IButton @@ -8,6 +10,8 @@ public abstract class ComplexButton implements IButton @Override public void Clicked(InventoryClickEvent event) { + Clicked(((Player) event.getWhoClicked()), event.getClick()); + if (event.isLeftClick()) { if (event.isShiftClick()) @@ -24,8 +28,10 @@ public abstract class ComplexButton implements IButton } } - public abstract void ClickedLeft(Player player); - public abstract void ClickedShiftLeft(Player player); - public abstract void ClickedRight(Player player); - public abstract void ClickedShiftRight(Player player); + public void ClickedLeft(Player player) { }; + public void ClickedShiftLeft(Player player) { }; + public void ClickedRight(Player player) { }; + public void ClickedShiftRight(Player player) { }; + + public void Clicked(Player player, ClickType clickType) { }; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java index 67d0843ea..5a77661c3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java @@ -77,7 +77,7 @@ public abstract class ShopPageBase inventory.getSize() - 1) { @@ -85,7 +85,7 @@ public abstract class ShopPageBase= (inventory.getSize() + 27) ? slot - (inventory.getSize() + 27) : slot - (inventory.getSize() - 9); } - protected void AddButton(int slot, ShopItem item, IButton button) + protected void AddButton(int slot, ItemStack item, IButton button) { AddItem(slot, item); ButtonMap.put(slot, button); } - + protected void addGlow(int slot) { UtilInv.addDullEnchantment(getItem(slot)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/GameHostShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/GameHostShop.java new file mode 100644 index 000000000..9bdc7809c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/GameHostShop.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.gui; + +import java.util.Arrays; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.page.GameHostMenuPage; + +public class GameHostShop extends ShopBase +{ + public GameHostShop(ArcadeManager plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super(plugin, clientManager, donationManager, "Private Server Menu"); + } + + @Override + protected ShopPageBase> BuildPagesFor(Player player) + { + return new GameHostMenuPage(Plugin, this, player); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/BanButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/BanButton.java new file mode 100644 index 000000000..0dd6a98e9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/BanButton.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.gui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.ComplexButton; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.GameHostShop; +import nautilus.game.arcade.gui.page.BanPage; + +public class BanButton extends ComplexButton +{ + private ArcadeManager _arcadeManager; + private GameHostShop _shop; + + public BanButton(ArcadeManager arcadeManager, GameHostShop shop) + { + _shop = shop; + _arcadeManager = arcadeManager; + } + + @Override + public void Clicked(Player player, ClickType clickType) + { + _shop.OpenPageForPlayer(player, new BanPage(_arcadeManager, _shop, player)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/EditRotationButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/EditRotationButton.java new file mode 100644 index 000000000..7ed685dab --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/EditRotationButton.java @@ -0,0 +1,7 @@ +package nautilus.game.arcade.gui.button; + +import mineplex.core.shop.item.ComplexButton; + +public class EditRotationButton extends ComplexButton +{ +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/GiveAdminButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/GiveAdminButton.java new file mode 100644 index 000000000..66182b06c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/GiveAdminButton.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.gui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.ComplexButton; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.GameHostShop; +import nautilus.game.arcade.gui.page.GiveAdminPage; + +public class GiveAdminButton extends ComplexButton +{ + private ArcadeManager _arcadeManager; + private GameHostShop _shop; + + public GiveAdminButton(ArcadeManager arcadeManager, GameHostShop shop) + { + _shop = shop; + _arcadeManager = arcadeManager; + } + + @Override + public void Clicked(Player player, ClickType clickType) + { + _shop.OpenPageForPlayer(player, new GiveAdminPage(_arcadeManager, _shop, player)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/SetGameButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/SetGameButton.java new file mode 100644 index 000000000..bfc3d4290 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/SetGameButton.java @@ -0,0 +1,7 @@ +package nautilus.game.arcade.gui.button; + +import mineplex.core.shop.item.ComplexButton; + +public class SetGameButton extends ComplexButton +{ +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/ToggleOpenButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/ToggleOpenButton.java new file mode 100644 index 000000000..5b40e769f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/ToggleOpenButton.java @@ -0,0 +1,7 @@ +package nautilus.game.arcade.gui.button; + +import mineplex.core.shop.item.ComplexButton; + +public class ToggleOpenButton extends ComplexButton +{ +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/UnbanButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/UnbanButton.java new file mode 100644 index 000000000..22b10335d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/button/UnbanButton.java @@ -0,0 +1,28 @@ +package nautilus.game.arcade.gui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.ComplexButton; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.GameHostShop; +import nautilus.game.arcade.gui.page.BanPage; +import nautilus.game.arcade.gui.page.UnbanPage; + +public class UnbanButton extends ComplexButton +{ + private ArcadeManager _arcadeManager; + private GameHostShop _shop; + + public UnbanButton(ArcadeManager arcadeManager, GameHostShop shop) + { + _shop = shop; + _arcadeManager = arcadeManager; + } + + @Override + public void Clicked(Player player, ClickType clickType) + { + _shop.OpenPageForPlayer(player, new UnbanPage(_arcadeManager, _shop, player)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/BanPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/BanPage.java new file mode 100644 index 000000000..947ca2bf8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/BanPage.java @@ -0,0 +1,71 @@ +package nautilus.game.arcade.gui.page; + +import java.util.HashSet; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; +import mineplex.core.shop.item.ComplexButton; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.GameHostShop; + +public class BanPage extends GameHostPage +{ + private int _currentPage; + + public BanPage(ArcadeManager plugin, GameHostShop shop, Player player) + { + super(plugin, shop, "Unban Players", player); + + _currentPage = 0; + } + + @Override + protected void BuildPage() + { + addBackButton(4); + + HashSet blackList = _manager.getBlacklist(); + Player[] players = UtilServer.getPlayers(); + + int slot = 9; + for (Player player : players) + { + if (!_manager.isAdmin(player)) + { + ItemStack head = getPlayerHead(player.getName(), C.cGreen + C.Bold + player.getName(), new String[]{ChatColor.RESET + C.cGray + "Click to Ban"}); + AddButton(slot, head, getBanButton(slot, player.getName())); + + slot++; + } + } + + +// int arrayModifier = _currentPage * 9 * 4; +// for (int i = 0; i < _currentPage; i++) +// { +// int slot = 9 + i; +// ItemStack head = getPlayerHead(blackList.) +// +// } + } + + private IButton getBanButton(final int slot, final String playerName) + { + return new ComplexButton() + { + @Override + public void Clicked(Player player, ClickType clickType) + { + _manager.getBlacklist().add(playerName); + RemoveButton(slot); + } + }; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/GameHostMenuPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/GameHostMenuPage.java new file mode 100644 index 000000000..da6db0d2c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/GameHostMenuPage.java @@ -0,0 +1,61 @@ +package nautilus.game.arcade.gui.page; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.GameHostShop; +import nautilus.game.arcade.gui.button.BanButton; +import nautilus.game.arcade.gui.button.EditRotationButton; +import nautilus.game.arcade.gui.button.GiveAdminButton; +import nautilus.game.arcade.gui.button.SetGameButton; +import nautilus.game.arcade.gui.button.ToggleOpenButton; +import nautilus.game.arcade.gui.button.UnbanButton; +import nautilus.game.arcade.managers.GameHostManager; + +public class GameHostMenuPage extends GameHostPage +{ + private GameHostManager _manager; + + public GameHostMenuPage(ArcadeManager plugin, GameHostShop shop, Player player) + { + super(plugin, shop, "Private Server Menu", player, 9*3); + } + + @Override + protected void BuildPage() + { + ItemStack ownerHead = getOwnerHead(); + setItem(4, ownerHead); + + SetGameButton setGameButton = new SetGameButton(); + AddButton(1 + 9, new ShopItem(Material.BOOK_AND_QUILL, "Set Game", new String[] {}, 1, false), setGameButton); + + EditRotationButton editRotationButton = new EditRotationButton(); + AddButton(1 + 18, new ShopItem(Material.BOOK, "Edit Game Rotation", new String[]{}, 1, false), editRotationButton); + + ToggleOpenButton toggleOpenButton = new ToggleOpenButton(); + AddButton(3 + 9, new ShopItem(Material.LEVER, "Toggle Open/Closed", new String[] {}, 1, false), toggleOpenButton); + + GiveAdminButton giveAdminButton = new GiveAdminButton(Plugin, Shop); + AddButton(5 + 9, new ShopItem(Material.ENDER_CHEST, "Give Admin", new String[] {}, 1, false), giveAdminButton); + + BanButton banButton = new BanButton(Plugin, Shop); + AddButton(7 + 9, new ShopItem(Material.MONSTER_EGG, "Ban Player", new String[] {}, 1, false), banButton); + + UnbanButton unbanButton = new UnbanButton(Plugin, Shop); + AddButton(7 + 18, new ShopItem(Material.PAPER, "Unban Player", new String[] {}, 1, false), unbanButton); + } + + private ItemStack getOwnerHead() + { + return getPlayerHead(Plugin.GetHost(), ChatColor.RESET + "Host: " + ChatColor.YELLOW + Plugin.GetHost()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/GameHostPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/GameHostPage.java new file mode 100644 index 000000000..f558339f9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/GameHostPage.java @@ -0,0 +1,68 @@ +package nautilus.game.arcade.gui.page; + +import java.util.Arrays; +import java.util.function.Consumer; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.item.SingleButton; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.GameHostShop; +import nautilus.game.arcade.managers.GameHostManager; + +public abstract class GameHostPage extends ShopPageBase +{ + protected GameHostManager _manager; + + public GameHostPage(ArcadeManager plugin, GameHostShop shop, String pageName, Player player) + { + this(plugin, shop, pageName, player, 54); + } + + public GameHostPage(ArcadeManager plugin, GameHostShop shop, String pageName, Player player, int slots) + { + super(plugin, shop, plugin.GetClients(), plugin.GetDonation(), pageName, player, slots); + + _manager = plugin.GetGameHostManager(); + BuildPage(); + } + + public void addBackButton(int slot) + { + AddButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] { }, 1, false), new SingleButton() + { + @Override + public void Clicked(Player player) + { + Shop.OpenPageForPlayer(player, new GameHostMenuPage(Plugin, Shop, player)); + } + }); + } + + public ItemStack getPlayerHead(String playerName, String title) + { + return getPlayerHead(playerName, title, null); + } + + public ItemStack getPlayerHead(String playerName, String title, String[] lore) + { + ItemStack is = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3); + + SkullMeta meta = ((SkullMeta) is.getItemMeta()); + meta.setOwner(playerName); + meta.setDisplayName(title); + if (lore != null) + meta.setLore(Arrays.asList(lore)); + is.setItemMeta(meta); + + return is; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/GiveAdminPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/GiveAdminPage.java new file mode 100644 index 000000000..27f4c49e6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/GiveAdminPage.java @@ -0,0 +1,67 @@ +package nautilus.game.arcade.gui.page; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; +import mineplex.core.shop.item.ComplexButton; +import mineplex.core.shop.item.IButton; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.GameHostShop; + +public class GiveAdminPage extends GameHostPage +{ + private int _currentPage; + + public GiveAdminPage(ArcadeManager plugin, GameHostShop shop, Player player) + { + super(plugin, shop, "Give Admin", player); + + _currentPage = 0; + } + + @Override + protected void BuildPage() + { + addBackButton(4); + + Player[] players = UtilServer.getPlayers(); + + int slot = 9; + for (Player player : players) + { + if (!_manager.isAdmin(player)) + { + ItemStack head = getPlayerHead(player.getName(), C.cGreen + C.Bold + player.getName(), new String[]{ChatColor.RESET + C.cGray + "Click to Give Admin"}); + AddButton(slot, head, getBanButton(slot, player.getName())); + + slot++; + } + } + + +// int arrayModifier = _currentPage * 9 * 4; +// for (int i = 0; i < _currentPage; i++) +// { +// int slot = 9 + i; +// ItemStack head = getPlayerHead(blackList.) +// +// } + } + + private IButton getBanButton(final int slot, final String playerName) + { + return new ComplexButton() + { + @Override + public void Clicked(Player player, ClickType clickType) + { + _manager.getAdminList().add(playerName); + RemoveButton(slot); + } + }; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/UnbanPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/UnbanPage.java new file mode 100644 index 000000000..16f46d52e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/UnbanPage.java @@ -0,0 +1,69 @@ +package nautilus.game.arcade.gui.page; + +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.shop.item.ComplexButton; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.GameHostShop; + +public class UnbanPage extends GameHostPage +{ + private int _currentPage; + + public UnbanPage(ArcadeManager plugin, GameHostShop shop, Player player) + { + super(plugin, shop, "Unban Players", player); + + _currentPage = 0; + } + + @Override + protected void BuildPage() + { + addBackButton(4); + + HashSet blackList = _manager.getBlacklist(); + Iterator iterator = blackList.iterator(); + + int slot = 9; + while (iterator.hasNext()) + { + String name = iterator.next(); + ItemStack head = getPlayerHead(name, C.cGreen + C.Bold + name, new String[] {ChatColor.RESET + C.cGray + "Click to Unban"}); + AddButton(slot, head, getUnbanButton(slot, name)); + + slot++; + } + + +// int arrayModifier = _currentPage * 9 * 4; +// for (int i = 0; i < _currentPage; i++) +// { +// int slot = 9 + i; +// ItemStack head = getPlayerHead(blackList.) +// +// } + } + + private IButton getUnbanButton(final int slot, final String playerName) + { + return new ComplexButton() + { + @Override + public void Clicked(Player player, ClickType clickType) + { + _manager.getBlacklist().remove(playerName); + RemoveButton(slot); + } + }; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java index ef4efe307..c0b377012 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java @@ -32,7 +32,7 @@ public class GameChatManager implements Listener @EventHandler public void MeCancel(PlayerCommandPreprocessEvent event) { - if (event.getMessage().startsWith("/me")) + if (event.getMessage().startsWith("/me ")) { event.getPlayer().sendMessage(F.main("Mirror", "You can't see /me messages, are you a vampire?")); event.setCancelled(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index b6bcd1803..8c8d2bced 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.managers; import java.util.HashSet; +import com.sun.org.apache.xpath.internal.SourceTree; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilGear; @@ -13,6 +14,7 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.gui.GameHostShop; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -27,6 +29,10 @@ import org.bukkit.event.player.PlayerQuitEvent; public class GameHostManager implements Listener { + private HashSet ultraGames = new HashSet(); + private HashSet heroGames = new HashSet(); + private HashSet legendGames = new HashSet(); + ArcadeManager Manager; private Player _host; @@ -34,17 +40,52 @@ public class GameHostManager implements Listener private long _serverExpireTime = 43200000; private long _lastOnline = System.currentTimeMillis(); private long _expireTime = 300000; - + + private HashSet _onlineAdmins = new HashSet(); + private HashSet _adminList = new HashSet(); private HashSet _whitelist = new HashSet(); private HashSet _blacklist = new HashSet(); + + private GameHostShop _shop; public GameHostManager(ArcadeManager manager) { Manager = manager; - + _shop = new GameHostShop(manager, manager.GetClients(), manager.GetDonation()); Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin()); + + //Ultra Games + ultraGames.add(GameType.Smash); + ultraGames.add(GameType.BaconBrawl); + ultraGames.add(GameType.DeathTag); + ultraGames.add(GameType.DragonEscape); + ultraGames.add(GameType.Dragons); + ultraGames.add(GameType.Micro); + ultraGames.add(GameType.Paintball); + ultraGames.add(GameType.Quiver); + ultraGames.add(GameType.Runner); + ultraGames.add(GameType.Sheep); + ultraGames.add(GameType.Snake); + ultraGames.add(GameType.SneakyAssassins); + ultraGames.add(GameType.TurfWars); + + //Hero Games + heroGames.add(GameType.ChampionsDominate); + heroGames.add(GameType.ChampionsTDM); + heroGames.add(GameType.HideSeek); + heroGames.add(GameType.Draw); + + //Legend Games + legendGames.add(GameType.Bridge); + legendGames.add(GameType.SurvivalGames); + legendGames.add(GameType.CastleSiege); + legendGames.add(GameType.MineStrike); + + _blacklist.add("Chiss"); + _blacklist.add("defek7"); + _blacklist.add("Ayreloc"); } -/* + @EventHandler public void updateHost(UpdateEvent event) { @@ -58,37 +99,51 @@ public class GameHostManager implements Listener //Host Update if (_host != null) { - giveHostItem(); + giveAdminItem(_host); _lastOnline = System.currentTimeMillis(); } + + // Admins update + for (Player admin : _onlineAdmins) + { + giveAdminItem(admin); + } } @EventHandler - public void hostJoin(PlayerJoinEvent event) + public void adminJoin(PlayerJoinEvent event) { - if (Manager.GetHost() == null || Manager.GetHost().length() == 0) + if (!isPrivateServer()) return; - + if (Manager.GetHost().equals(event.getPlayer().getName())) { - System.out.println("Game Host Joined."); _host = event.getPlayer(); + System.out.println("Game Host Joined."); + } + else if (isAdmin(event.getPlayer())) + { + System.out.println("Admin Joined."); + _onlineAdmins.add(event.getPlayer()); } - } @EventHandler - public void hostQuit(PlayerQuitEvent event) + public void adminQuit(PlayerQuitEvent event) { - if (Manager.GetHost() == null || Manager.GetHost().length() == 0) + if (!isPrivateServer()) return; - if (Manager.GetHost().equals(event.getPlayer().getName())) + if (isHost(event.getPlayer())) { System.out.println("Game Host Quit."); _host = null; } + else if (isAdmin(event.getPlayer())) + { + _onlineAdmins.remove(event.getPlayer()); + } } public boolean isHostExpired() @@ -99,18 +154,15 @@ public class GameHostManager implements Listener return UtilTime.elapsed(_lastOnline, _expireTime) || UtilTime.elapsed(_serverStartTime, _serverExpireTime); } - private void giveHostItem() + private void giveAdminItem(Player player) { if (Manager.GetGame() == null) return; - - if (_host == null) + + if (UtilGear.isMat(player.getInventory().getItem(5), Material.BOOK_AND_QUILL)) return; - if (UtilGear.isMat(_host.getInventory().getItem(5), Material.BOOK_AND_QUILL)) - return; - - _host.getInventory().setItem(5, ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte)0, 1, C.cGreen + C.Bold + "/menu")); + player.getInventory().setItem(5, ItemStackFactory.Instance.CreateStack(Material.BOOK, (byte)0, 1, C.cGreen + C.Bold + "/menu")); } public HashSet getWhitelist() @@ -122,39 +174,55 @@ public class GameHostManager implements Listener { return _blacklist; } + + public HashSet getAdminList() + { + return _adminList; + } @EventHandler public void menuCommand(PlayerCommandPreprocessEvent event) { - if (_host == null || !event.getPlayer().equals(_host)) + if (!isAdmin(event.getPlayer())) return; if (!event.getMessage().toLowerCase().startsWith("/menu")) return; - openMenu(); + openMenu(event.getPlayer()); } @EventHandler public void menuInteract(PlayerInteractEvent event) { - if (_host == null || !event.getPlayer().equals(_host)) + if (!isAdmin(event.getPlayer())) return; - if (!UtilGear.isMat(_host.getItemInHand(), Material.BOOK_AND_QUILL)) + if (!UtilGear.isMat(_host.getItemInHand(), Material.BOOK)) return; - openMenu(); + openMenu(event.getPlayer()); + event.setCancelled(true); + } + + private void openMenu(Player player) + { + _shop.attemptShopOpen(_host); } - - private void openMenu() + public boolean isAdmin(Player player) { - if (_host == null) - return; - - - //XXX OPEN GUI HERE + return player.equals(_host) || _adminList.contains(player.getName()); + } + + public boolean isHost(Player player) + { + return player.equals(Manager.GetHost()); + } + + public boolean isPrivateServer() + { + return Manager.GetHost() != null || Manager.GetHost().length() > 0; } @EventHandler @@ -250,6 +318,4 @@ public class GameHostManager implements Listener Manager.GetGame().Announce(C.cGreen + C.Bold + _host.getName() + " has stopped the game."); } - -*/ }