From 644d6c9914ccb7add4588fc524ff1d8a306e38fe Mon Sep 17 00:00:00 2001 From: William Burns Date: Tue, 4 Aug 2015 11:21:58 +0100 Subject: [PATCH 1/3] Whitelist fixes. Implemented MapSource. --- .../privateServer/button/ChooseMapButton.java | 2 +- .../privateServer/button/WhitelistButton.java | 7 +-- .../gui/privateServer/page/OptionsPage.java | 5 ++ .../gui/privateServer/page/PlayerPage.java | 2 +- .../privateServer/page/WhitelistedPage.java | 48 +++++++++++-------- .../game/arcade/managers/GameGemManager.java | 36 +++++++------- .../game/arcade/managers/GameHostManager.java | 8 +++- 7 files changed, 63 insertions(+), 45 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java index d350f9389..5282a03f6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java @@ -33,8 +33,8 @@ public class ChooseMapButton implements IButton @Override public void onClick(Player player, ClickType clickType) { - _arcadeManager.GetGameCreationManager().MapPref = _map; _arcadeManager.GetGameCreationManager().MapSource = _gameType.GetName(); + _arcadeManager.GetGameCreationManager().MapPref = _map; _arcadeManager.GetGame().setGame(_gameType, player, true); player.closeInventory(); return; 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 index 5da1d273d..30a48c15e 100644 --- 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 @@ -32,11 +32,6 @@ public class WhitelistButton implements IButton @Override public void onClick(Player player, ClickType clickType) { - List strings = new ArrayList<>(); - for (String s : _arcadeManager.GetGameHostManager().getWhitelist()) - { - strings.add(s); - } - _shop.openPageForPlayer(player, new WhitelistedPage(_arcadeManager, _shop, player, strings)); + _shop.openPageForPlayer(player, new WhitelistedPage(_arcadeManager, _shop, player)); } } 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 1b2eebcc5..e68206e2f 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 @@ -124,6 +124,11 @@ public class OptionsPage extends BasePage private void togglePublic() { + if (_config.PlayerServerWhitelist==true) + { + _config.PublicServer = false; + return; + } _config.PublicServer = !_config.PublicServer; refresh(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/PlayerPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/PlayerPage.java index 7254e2cb7..c2f6f2817 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/PlayerPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/PlayerPage.java @@ -38,7 +38,7 @@ public abstract class PlayerPage extends BasePage { addBackButton(4); - List players = null; + List players = new ArrayList<>(); if (useOtherList) { players = new ArrayList<>(); 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 4ad9980bb..101ba9a18 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,9 +2,14 @@ package nautilus.game.arcade.gui.privateServer.page; import java.util.List; +import org.bukkit.Bukkit; 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.F; +import mineplex.core.shop.item.IButton; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.gui.privateServer.PrivateServerShop; @@ -15,33 +20,38 @@ import nautilus.game.arcade.gui.privateServer.PrivateServerShop; * consent of William Burns. 2015. * 29/07/15 */ -public class WhitelistedPage extends PlayerPage +public class WhitelistedPage extends BasePage { - public WhitelistedPage(ArcadeManager plugin, PrivateServerShop shop, Player player, List players) + public WhitelistedPage(ArcadeManager plugin, PrivateServerShop shop, Player player) { - super(plugin, shop, "Whitelisted Players", player, players); + super(plugin, shop, "Whitelisted Players", player); buildPage(); } @Override - public boolean showPlayer(Player player) + protected void buildPage() { - if (getPlugin().GetGameHostManager().getWhitelist().contains(player.getName())) - return true; - return false; - } + addBackButton(4); - @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.")); - } + int slot = 9; + for (final String s : getPlugin().GetGameHostManager().getWhitelist()) + { + ItemStack head = getPlayerHead(s, C.cGreen + C.Bold + s, new String[]{C.cGray + "Click to un-whitelist player"}); + final int i = slot; + addButton(slot, head, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getPlugin().GetGameHostManager().getWhitelist().remove(s); + removeButton(i); + getPlayer().sendMessage(F.main("Whitelist", "§e" + s + " §7is no longer whitelisted.")); + if (Bukkit.getPlayer(s)!=null) + getPlugin().GetPortal().sendToHub(Bukkit.getPlayer(s), "You are no longer whitelisted."); + } + }); - @Override - public String getDisplayString(Player player) - { - return "Click to remove from whitelist"; + slot++; + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java index 844b78975..dce24d8da 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java @@ -117,9 +117,6 @@ public class GameGemManager implements Listener @EventHandler(priority = EventPriority.MONITOR) public void GameStateChange(GameStateChangeEvent event) { - if (!Manager.IsRewardGems()) - return; - if (event.GetState() != GameState.Dead) return; @@ -129,12 +126,12 @@ public class GameGemManager implements Listener public void RewardGems(Game game, Player player, boolean give) { - if (!Manager.IsRewardGems()) - return; - //Inform Gems AnnounceGems(game, player, game.GetPlayerGems().get(player), give); + if (!Manager.IsRewardGems()) + return; + //Give Gems if (give) GiveGems(game, player, game.GetPlayerGems().remove(player), game.GemMultiplier); @@ -145,7 +142,7 @@ public class GameGemManager implements Listener if (!Manager.IsRewardGems()) return; - if (gems == null) + if (gems == null) return; int earned = 0; @@ -167,7 +164,7 @@ public class GameGemManager implements Listener //Gem Finder if (game.GemHunterEnabled) { - int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel(); + int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel(); if (gemFinder > 0) { total += (int)(earned * (gemFinder * 0.25)); @@ -184,9 +181,9 @@ public class GameGemManager implements Listener Manager.GetStatsManager().incrementStat(player, game.GetName()+".GemsEarned", total); } - public void AnnounceGems(Game game, Player player, HashMap gems, boolean give) + public void AnnounceGems(Game game, Player player, HashMap gems, boolean give) { - if (gems == null) + if (gems == null) return; player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f); @@ -211,7 +208,7 @@ public class GameGemManager implements Listener String amountStr = ""; if (amount > 0) amountStr = amount + " "; - + String out = ""; if (Manager.IsRewardGems()) out += F.elem(C.cGreen + "+" + (int)(gemCount * game.GemMultiplier) + " Gems") + " for "; @@ -219,9 +216,14 @@ public class GameGemManager implements Listener UtilPlayer.message(player, out); } - + if (!Manager.IsRewardGems()) + { + UtilPlayer.message(player, ""); + UtilPlayer.message(player, ArcadeFormat.Line); return; + } + earnedGems = (int) (earnedGems * game.GemMultiplier); @@ -230,7 +232,7 @@ public class GameGemManager implements Listener //Gem Booster if (game.GetGemBoostAmount() > 0 && game.GemBoosterEnabled) { - UtilPlayer.message(player, F.elem(C.cGreen + "+" + (int)(earnedGems*game.GetGemBoostAmount()) + " Gems") + " for " + + UtilPlayer.message(player, F.elem(C.cGreen + "+" + (int)(earnedGems*game.GetGemBoostAmount()) + " Gems") + " for " + F.elem(game.GemBoosters.size() + " Gem Boosters " + C.cGreen + "+" + (int)(game.GetGemBoostAmount()*100) + "%")); totalGems += earnedGems * game.GetGemBoostAmount(); @@ -242,7 +244,7 @@ public class GameGemManager implements Listener int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel(); if (gemFinder > 0) { - UtilPlayer.message(player, F.elem(C.cGreen + "+" + ((int)(earnedGems*(gemFinder * 0.25)) + " Gems")) + " for " + + UtilPlayer.message(player, F.elem(C.cGreen + "+" + ((int)(earnedGems*(gemFinder * 0.25)) + " Gems")) + " for " + F.elem("Gem Hunter " + gemFinder + C.cGreen + " +" + (gemFinder*25) + "%")); totalGems += earnedGems * (gemFinder * 0.25); @@ -261,7 +263,7 @@ public class GameGemManager implements Listener UtilPlayer.message(player, ""); if (give) { - UtilPlayer.message(player, F.elem(C.cWhite + "§lYou now have " + + UtilPlayer.message(player, F.elem(C.cWhite + "§lYou now have " + C.cGreen + C.Bold + (Manager.GetDonation().Get(player.getName()).GetGems() + totalGems) + " Gems")); } else @@ -270,8 +272,8 @@ public class GameGemManager implements Listener UtilPlayer.message(player, F.elem(C.cWhite + "§lYou may earn more " + C.cGreen + C.Bold + "Gems" + C.cWhite + C.Bold + " when its completed.")); } - UtilPlayer.message(player, ArcadeFormat.Line); + UtilPlayer.message(player, ArcadeFormat.Line); } -} +} \ No newline at end of file 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 fcd792096..2dfc1c151 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 @@ -48,6 +48,7 @@ public class GameHostManager implements Listener ArcadeManager Manager; private Player _host; + private String _hostName; private Rank _hostRank; private long _serverStartTime = System.currentTimeMillis(); private long _serverExpireTime = 21600000; @@ -208,8 +209,10 @@ public class GameHostManager implements Listener Player p = event.getPlayer(); if (Manager.GetServerConfig().PlayerServerWhitelist){ if (!getWhitelist().contains(p.getName())){ - if (_host == p) + if ((Manager.GetHost() != null) && (Manager.GetHost().equalsIgnoreCase(p.getName()))) + { return; + } event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "This MPS is whitelisted."); } } @@ -368,6 +371,9 @@ public class GameHostManager implements Listener event.setCancelled(true); + if (!isPrivateServer()) + return; + if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.JNR_DEV, true)) return; From ec3bc7cc38125cbf74749f47e0bdd1a0a76de852 Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 4 Aug 2015 17:04:49 +0200 Subject: [PATCH 2/3] Try fixing the map selection. --- .../arcade/gui/privateServer/button/ChooseMapButton.java | 2 ++ .../game/arcade/gui/privateServer/page/ChooseMapPage.java | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java index 5282a03f6..37a38e6f8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java @@ -34,6 +34,8 @@ public class ChooseMapButton implements IButton public void onClick(Player player, ClickType clickType) { _arcadeManager.GetGameCreationManager().MapSource = _gameType.GetName(); + if(_gameType.getMapSource() != null) + _arcadeManager.GetGameCreationManager().MapSource = _gameType.getMapSource()[0].GetName(); _arcadeManager.GetGameCreationManager().MapPref = _map; _arcadeManager.GetGame().setGame(_gameType, player, true); player.closeInventory(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/ChooseMapPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/ChooseMapPage.java index 88914ff5d..551616b8c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/ChooseMapPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/ChooseMapPage.java @@ -34,7 +34,13 @@ public class ChooseMapPage extends BasePage addBackToSetGamePage(); int slot = 9; - for (String cur : getPlugin().LoadFiles(_gameType.GetName())){ + String loadMaps = _gameType.GetName(); + if(_gameType.getMapSource() != null) + { + loadMaps = _gameType.getMapSource()[0].GetName(); + } + for(String cur : getPlugin().LoadFiles(loadMaps)) + { ChooseMapButton btn = new ChooseMapButton(getPlugin(), getShop(), _gameType, cur); addButton(slot, new ShopItem(Material.PAPER, cur.split("_")[1], new String[]{"§7Click to select map."}, 1, false), btn); slot++; From 1fd5c51f033263c0e1e0e2812f6430d031471dc6 Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Tue, 4 Aug 2015 17:33:23 +0200 Subject: [PATCH 3/3] DINGO ATE MY BABY --- .../src/nautilus/game/arcade/game/Game.java | 8 +++++++- .../arcade/gui/privateServer/button/ChooseMapButton.java | 1 + .../game/arcade/managers/GameCreationManager.java | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index a59565071..dd86eead8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -294,6 +294,8 @@ public abstract class Game implements Listener } if (Manager.GetGameCreationManager().MapPref != null) { + System.out.println("Map Preference: " + Manager.GetGameCreationManager().MapPref); + HashMap> matches = new HashMap>(); for (GameType game : _files.keySet()) { @@ -302,7 +304,7 @@ public abstract class Game implements Listener { if (cur.toLowerCase().contains(Manager.GetGameCreationManager().MapPref.toLowerCase())) { - if(game.toString().toLowerCase().contains(Manager.GetGameCreationManager().MapSource.toLowerCase())) + if(game.GetName().toLowerCase().contains(Manager.GetGameCreationManager().MapSource.toLowerCase())) { list.add(cur); System.out.print("Map Preference: " + cur); @@ -318,6 +320,10 @@ public abstract class Game implements Listener Manager.GetGameCreationManager().MapPref = null; Manager.GetGameCreationManager().MapSource = null; } + else + { + System.out.println("Map Preference: None"); + } WorldData = new WorldData(this); //Stat Trackers diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java index 37a38e6f8..a56b7e67e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/ChooseMapButton.java @@ -36,6 +36,7 @@ public class ChooseMapButton implements IButton _arcadeManager.GetGameCreationManager().MapSource = _gameType.GetName(); if(_gameType.getMapSource() != null) _arcadeManager.GetGameCreationManager().MapSource = _gameType.getMapSource()[0].GetName(); + _arcadeManager.GetGameCreationManager().MapPref = _map; _arcadeManager.GetGame().setGame(_gameType, player, true); player.closeInventory(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java index 955a6e8f8..1e51b1d42 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java @@ -167,6 +167,9 @@ public class GameCreationManager implements Listener HashMap pastTeams = null; + System.out.println(_nextGame == null ? "Next Game = null" : "Next Game = " + _nextGame.GetName()); + System.out.println(MapPref == null ? "Map Pref = null" : "Map Pref = " + MapPref); + //Chosen Game if (_nextGame != null) {