From 181b778a9c30c9584d3137563798a780e6832c3e Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 7 Aug 2015 07:39:40 +0200 Subject: [PATCH] Fixing some bugs and disallow MPS while disguised. --- .../src/mineplex/core/disguise/DisguiseManager.java | 12 +++++------- .../core/personalServer/HostEventServerCommand.java | 7 +++++++ .../core/personalServer/HostServerCommand.java | 7 +++++++ .../core/personalServer/PersonalServerManager.java | 5 +++++ .../src/mineplex/hub/commands/DisguiseCommand.java | 9 +++++---- .../game/arcade/command/DisguiseCommand.java | 2 +- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 92f499ab2..86a78df78 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -1143,22 +1143,20 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler EntityPlayer disguisedPlayer = (EntityPlayer) disguise.GetEntity(); - try - { - if (Bukkit.getPlayerExact(disguisedPlayer.getName()) == null || !disguisedPlayer.isAlive() || !disguisedPlayer.valid) + + if (Bukkit.getPlayerExact(disguisedPlayer.getName()) == null || !disguisedPlayer.isAlive() || !disguisedPlayer.valid) disguiseIterator.remove(); - } - catch(NullPointerException e) - { + try{ for (Iterator playerIterator = _disguisePlayerMap.get(disguise).iterator(); playerIterator.hasNext();) { Player player = playerIterator.next(); - + if (!player.isOnline() || !player.isValid()) playerIterator.remove(); } } + catch (Exception exception) {} } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java index 566c95a04..65d95c26a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java @@ -4,6 +4,8 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; public class HostEventServerCommand extends CommandBase @@ -19,6 +21,11 @@ public class HostEventServerCommand extends CommandBase if (!Recharge.Instance.use(caller, "Host Event", 30000, false, false)) return; + if(Plugin.getClients().Get(caller).isDisguised()) + { + UtilPlayer.message(caller, F.main("Disguise", "You cant host Servers while you are disguised!")); + return; + } Plugin.hostServer(caller, caller.getName(), true); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java index b09c4cc54..dbf091299 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java @@ -4,6 +4,8 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; public class HostServerCommand extends CommandBase @@ -19,6 +21,11 @@ public class HostServerCommand extends CommandBase if (!Recharge.Instance.use(caller, "Host Server", 30000, false, false)) return; + if(Plugin.getClients().Get(caller).isDisguised()) + { + UtilPlayer.message(caller, F.main("Disguise", "You cant host Servers while you are disguised!")); + return; + } Plugin.hostServer(caller, caller.getName(), false); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java index 466a26d50..2030044e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java @@ -177,4 +177,9 @@ public class PersonalServerManager extends MiniPlugin } }); } + + public CoreClientManager getClients() + { + return _clientManager; + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java index 9812d610c..0402366e7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -56,9 +56,10 @@ public class DisguiseCommand extends CommandBase implements Listener public DisguiseCommand(HubManager plugin) { super(plugin, Rank.JNR_DEV, new Rank[] - { Rank.YOUTUBE, Rank.TWITCH }, "disguise"); - plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); - new NCPDataManFix(); + { + Rank.YOUTUBE, Rank.TWITCH }, "disguise"); + plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); + new NCPDataManFix(); } @Override @@ -254,9 +255,9 @@ public class DisguiseCommand extends CommandBase implements Listener { _disguisedPlayers.remove(player); _disguisedPlayerDisguises.remove(player); - _disguisedPlayersNames.remove(player); Plugin.GetDisguise().undisguise(player); String playerName = _disguisedPlayersNames.get(player); + _disguisedPlayersNames.remove(player); CoreClient client = Plugin.GetClients().Get(player); client.setDisguisedRank(null); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java index 26ac74dec..7c32ed36a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java @@ -260,9 +260,9 @@ public class DisguiseCommand extends CommandBase implements Liste { _disguisedPlayers.remove(player); _disguisedPlayerDisguises.remove(player); - _disguisedPlayersNames.remove(player); Plugin.GetDisguise().undisguise(player); String playerName = _disguisedPlayersNames.get(player); + _disguisedPlayersNames.remove(player); CoreClient client = Plugin.GetClients().Get(player); client.setDisguisedRank(null);