From f82defb1db07e0d9f212c51accdad2c6b2a8553d Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 29 Jul 2015 13:27:26 +0100 Subject: [PATCH 1/3] Whitelist --- .../privateServer/page/EditRotationPage.java | 2 +- .../privateServer/page/GameVotingPage.java | 2 +- .../privateServer/page/WhitelistedPage.java | 33 +++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/WhitelistedPage.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/EditRotationPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/EditRotationPage.java index c2ed9bcdc..6a883e6e8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/EditRotationPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/EditRotationPage.java @@ -81,7 +81,7 @@ public class EditRotationPage extends BasePage for (GameCategory cat : _manager.getGames(getPlayer()).keySet()) { if (!allowedCats.contains(cat)) - return; + continue; for (GameType type : _manager.getGames(getPlayer()).get(cat)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/GameVotingPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/GameVotingPage.java index dea63c263..7c2cf8488 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/GameVotingPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/GameVotingPage.java @@ -59,7 +59,7 @@ public class GameVotingPage extends BasePage for (GameCategory cat : _manager.getGames(getPlayer()).keySet()) { if (!allowedCats.contains(cat)) - return; + continue; for (GameType type : _manager.getGames(getPlayer()).get(cat)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/WhitelistedPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/WhitelistedPage.java new file mode 100644 index 000000000..0b23a5be6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/WhitelistedPage.java @@ -0,0 +1,33 @@ +package nautilus.game.arcade.gui.privateServer.page; + +import org.bukkit.entity.Player; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.privateServer.PrivateServerShop; + +/** + * Created by WilliamTiger. + * All the code and any API's associated with it + * are not to be used anywhere else without written + * consent of William Burns. 2015. + * 29/07/15 + */ +public class WhitelistedPage extends BasePage +{ + public WhitelistedPage(ArcadeManager plugin, PrivateServerShop shop, Player player) + { + super(plugin, shop, "Whitelisted Players", player); + buildPage(); + } + + @Override + protected void buildPage() + { + + } + + private void addPlayerButton(Player p) + { + + } +} From 3bc66f16b652cb2b68f56c7d9f4e106a2ed824cb Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 29 Jul 2015 14:22:49 +0100 Subject: [PATCH 2/3] Woo a push --- .../game/games/smash/TeamSuperSmash.java | 2 +- .../privateServer/button/WhitelistButton.java | 34 +++++++++++++++++++ .../privateServer/page/EditRotationPage.java | 1 + .../privateServer/page/GameVotingPage.java | 1 + .../gui/privateServer/page/MenuPage.java | 8 +++-- .../gui/privateServer/page/OptionsPage.java | 2 ++ .../gui/privateServer/page/SetGamePage.java | 1 + .../privateServer/page/WhitelistedPage.java | 20 ++++++++--- .../game/arcade/managers/GameHostManager.java | 13 ++++--- 9 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/WhitelistButton.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java index 1b8097c13..6aa1dbcef 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java @@ -47,7 +47,7 @@ public class TeamSuperSmash extends SuperSmash this.PlayersPerTeam = 2; this.FillTeamsInOrderToCount = 2; - this.SpawnNearAlliesz = true; + this.SpawnNearAllies = true; this.DamageTeamSelf = false; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/WhitelistButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/WhitelistButton.java new file mode 100644 index 000000000..768b4013f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/WhitelistButton.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.gui.privateServer.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.privateServer.PrivateServerShop; +import nautilus.game.arcade.gui.privateServer.page.WhitelistedPage; + +/** + * Created by WilliamTiger. + * All the code and any API's associated with it + * are not to be used anywhere else without written + * consent of William Burns. 2015. + * 29/07/15 + */ +public class WhitelistButton implements IButton +{ + private ArcadeManager _arcadeManager; + private PrivateServerShop _shop; + + public WhitelistButton(ArcadeManager arcadeManager, PrivateServerShop shop) + { + _shop = shop; + _arcadeManager = arcadeManager; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _shop.openPageForPlayer(player, new WhitelistedPage(_arcadeManager, _shop, player)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/EditRotationPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/EditRotationPage.java index 6a883e6e8..c9013e742 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/EditRotationPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/EditRotationPage.java @@ -76,6 +76,7 @@ public class EditRotationPage extends BasePage allowedCats.add(GameCategory.SURVIVAL); allowedCats.add(GameCategory.CHAMPIONS); allowedCats.add(GameCategory.EXTRA); + allowedCats.add(GameCategory.TEAM_VARIANT); int gameSlot = 9; for (GameCategory cat : _manager.getGames(getPlayer()).keySet()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/GameVotingPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/GameVotingPage.java index 7c2cf8488..dbb24a7b1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/GameVotingPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/GameVotingPage.java @@ -54,6 +54,7 @@ public class GameVotingPage extends BasePage allowedCats.add(GameCategory.SURVIVAL); allowedCats.add(GameCategory.CHAMPIONS); allowedCats.add(GameCategory.EXTRA); + allowedCats.add(GameCategory.TEAM_VARIANT); int gameSlot = 9; for (GameCategory cat : _manager.getGames(getPlayer()).keySet()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java index 615d8552b..c24a31d78 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java @@ -26,6 +26,7 @@ import nautilus.game.arcade.gui.privateServer.button.OptionsButton; import nautilus.game.arcade.gui.privateServer.button.StartGameButton; import nautilus.game.arcade.gui.privateServer.button.StopGameButton; import nautilus.game.arcade.gui.privateServer.button.UnbanButton; +import nautilus.game.arcade.gui.privateServer.button.WhitelistButton; public class MenuPage extends BasePage { @@ -94,11 +95,14 @@ public class MenuPage extends BasePage addButton(4 + 18, new ShopItem(Material.GOLD_SWORD, "Remove Admin", new String[]{}, 1, false), removeAdminButton); KillButton killButton = new KillButton(getPlugin()); - addButton(4 + 27, new ShopItem(Material.TNT, "Kill Private Server", + addButton(8 + 18, new ShopItem(Material.TNT, "Kill Private Server", new String[]{ChatColor.RESET + C.cGray + "Shift-Right Click to Kill Private Server"}, 1, false), killButton); GameVotingButton votingButton = new GameVotingButton(getPlugin(), getShop()); - addButton(8 + 18, new ShopItem(Material.BOOKSHELF, "Game Voting", new String[]{}, 1, false), votingButton); + addButton(3 + 27, new ShopItem(Material.BOOKSHELF, "Game Voting", new String[]{}, 1, false), votingButton); + + WhitelistButton whitelistButton = new WhitelistButton(getPlugin(), getShop()); + addButton(5 + 27, new ShopItem(Material.PAPER, "Whitelisted Players", new String[]{}, 1, false), whitelistButton); } OptionsButton optionsButton = new OptionsButton(getPlugin(), getShop()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/OptionsPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/OptionsPage.java index 8b7c5b0e0..1b2eebcc5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/OptionsPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/OptionsPage.java @@ -117,6 +117,8 @@ public class OptionsPage extends BasePage private void toggleWhitelist() { _config.PlayerServerWhitelist = !_config.PlayerServerWhitelist; + if (_config.PlayerServerWhitelist == true) + _config.PublicServer = false; refresh(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/SetGamePage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/SetGamePage.java index d2d0b4092..b17e0009e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/SetGamePage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/SetGamePage.java @@ -72,6 +72,7 @@ public class SetGamePage extends BasePage allowedCats.add(GameCategory.SURVIVAL); allowedCats.add(GameCategory.CHAMPIONS); allowedCats.add(GameCategory.EXTRA); + allowedCats.add(GameCategory.TEAM_VARIANT); int gameSlot = 9; for (GameCategory cat : _manager.getGames(getPlayer()).keySet()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/WhitelistedPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/WhitelistedPage.java index 0b23a5be6..4643fa21b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/WhitelistedPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/WhitelistedPage.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.gui.privateServer.page; import org.bukkit.entity.Player; +import mineplex.core.common.util.F; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.gui.privateServer.PrivateServerShop; @@ -12,7 +13,7 @@ import nautilus.game.arcade.gui.privateServer.PrivateServerShop; * consent of William Burns. 2015. * 29/07/15 */ -public class WhitelistedPage extends BasePage +public class WhitelistedPage extends PlayerPage { public WhitelistedPage(ArcadeManager plugin, PrivateServerShop shop, Player player) { @@ -21,13 +22,24 @@ public class WhitelistedPage extends BasePage } @Override - protected void buildPage() + public boolean showPlayer(Player player) { - + if (getPlugin().GetGameHostManager().getWhitelist().contains(player.getName())) + return true; + return false; } - private void addPlayerButton(Player p) + @Override + public void clicked(int slot, Player player) { + getPlugin().GetGameHostManager().getWhitelist().remove(player.getName()); + getPlugin().GetPortal().sendToHub(player, "You are no longer whitelisted."); + getPlayer().sendMessage(F.main("Whitelist", "§e" + player.getName() + " §7is no longer whitelisted.")); + } + @Override + public String getDisplayString(Player player) + { + return "Click to remove from whitelist"; } } 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 6c8bb6276..3b5ccc485 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 @@ -109,10 +109,6 @@ public class GameHostManager implements Listener legendGames.add(GameType.Build); legendGames.add(GameType.UHC); legendGames.add(GameType.MineStrike); - legendGames.add(GameType.SnowFight); - legendGames.add(GameType.Gravity); - legendGames.add(GameType.Barbarians); - legendGames.add(GameType.SmashDomination); legendGames.add(GameType.Skywars); // Team variants - Currently being remade. /* @@ -128,6 +124,13 @@ public class GameHostManager implements Listener legendGames.add(GameType.MilkCow); legendGames.add(GameType.SearchAndDestroy); legendGames.add(GameType.ZombieSurvival); + legendGames.add(GameType.SurvivalGamesTeams); + legendGames.add(GameType.SkywarsTeams); + legendGames.add(GameType.SmashTeams); + legendGames.add(GameType.SnowFight); + legendGames.add(GameType.Gravity); + legendGames.add(GameType.Barbarians); + legendGames.add(GameType.SmashDomination); //Config Defaults if (Manager.GetHost() != null && Manager.GetHost().length() > 0) @@ -223,6 +226,8 @@ public class GameHostManager implements Listener Player p = event.getPlayer(); if (Manager.GetServerConfig().PlayerServerWhitelist){ if (!getWhitelist().contains(p.getName())){ + if (_host == p) + return; Manager.GetPortal().sendToHub(p, "You aren't on the whitelist of this Mineplex Private Server."); } } From 2b3fec754f32baaca17003a5177f0fcdb22decde Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 29 Jul 2015 14:25:38 +0100 Subject: [PATCH 3/3] Colour change cause colour! --- .../game/arcade/managers/GameHostManager.java | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) 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 3b5ccc485..d8c11b81c 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 @@ -190,31 +190,13 @@ public class GameHostManager implements Listener if (_voteNotificationStage == 1) { - UtilTextBottom.display("§e§l> §6§lUse §e§l/vote §6§lto vote for a game! §e§l<", UtilServer.getPlayers()); + UtilTextBottom.display("§e§l> §e§lUse §6§l/vote §e§lto vote for a game! §e§l<", UtilServer.getPlayers()); _voteNotificationStage++; return; } else if (_voteNotificationStage == 2) { - UtilTextBottom.display("§a§l> §2§lUse §a§l/vote §2§lto vote for a game! §a§l<", UtilServer.getPlayers()); - _voteNotificationStage++; - return; - } - else if (_voteNotificationStage == 3) - { - UtilTextBottom.display("§c§l> §4§lUse §c§l/vote §4§lto vote for a game! §c§l<", UtilServer.getPlayers()); - _voteNotificationStage++; - return; - } - else if (_voteNotificationStage == 4) - { - UtilTextBottom.display("§b§l> §3§lUse §b§l/vote §3§lto vote for a game! §b§l<", UtilServer.getPlayers()); - _voteNotificationStage++; - return; - } - else if (_voteNotificationStage == 5) - { - UtilTextBottom.display("§d§l> §5§lUse §d§l/vote §5§lto vote for a game! §d§l<", UtilServer.getPlayers()); + UtilTextBottom.display("§6§l> §6§lUse §e§l/vote §6§lto vote for a game! §6§l<", UtilServer.getPlayers()); _voteNotificationStage = 1; return; }