From 25f93bac2e3824cd195ceee6a121aef217cfbefd Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Sat, 15 Aug 2015 12:27:11 +0200 Subject: [PATCH 1/7] fixed logic on setgame --- .../arcade/game/games/event/EventModule.java | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java index 83c0c0801..8962ceaf8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -82,13 +82,30 @@ public class EventModule extends MiniPlugin if (!event.getMessage().toLowerCase().startsWith("/sethost ")) return; - boolean eventTestServer = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1"); - - if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.JNR_DEV, true) - && !event.getPlayer().isOp() && - (!eventTestServer && !Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.SNR_MODERATOR, true))) - return; - + //Player isnt OP! Check if allowed. + if (!event.getPlayer().isOp()) + { + //Not JNR Dev either + if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.JNR_DEV, true)) + { + boolean eventTestServer = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1"); + + //NOT EVENT TEST! + if (!eventTestServer) + { + return; + } + else + { + //Not Snr Mod + if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.SNR_MODERATOR, true)) + { + return; + } + } + } + } + Manager.GetServerConfig().HostName = event.getMessage().split(" ")[1]; event.getPlayer().sendMessage("Set host to: " + event.getMessage().split(" ")[1]); From ba6806935db39c58fd5f4fe9c9441c2c9929c674 Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Sat, 15 Aug 2015 12:31:19 +0200 Subject: [PATCH 2/7] fixed better --- .../arcade/game/games/event/EventModule.java | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java index 8962ceaf8..7c289e1d5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -81,30 +81,25 @@ public class EventModule extends MiniPlugin { if (!event.getMessage().toLowerCase().startsWith("/sethost ")) return; + + boolean allowed = Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.JNR_DEV, true); - //Player isnt OP! Check if allowed. - if (!event.getPlayer().isOp()) + + boolean eventTestServer = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1"); + + //NOT EVENT TEST! NOT ALLOWED! + if (!allowed) { - //Not JNR Dev either - if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.JNR_DEV, true)) - { - boolean eventTestServer = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1"); - - //NOT EVENT TEST! - if (!eventTestServer) - { - return; - } - else - { - //Not Snr Mod - if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.SNR_MODERATOR, true)) - { - return; - } - } - } + allowed = eventTestServer && + Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.SNR_MODERATOR, true); + } + + if (!allowed) + { + return; + } + Manager.GetServerConfig().HostName = event.getMessage().split(" ")[1]; From 8584e0355acf3a32db8ba152f5d88f70363f4912 Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Sat, 15 Aug 2015 12:32:03 +0200 Subject: [PATCH 3/7] final fix! --- .../game/arcade/game/games/event/EventModule.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java index 7c289e1d5..4b5585f8d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -84,15 +84,11 @@ public class EventModule extends MiniPlugin boolean allowed = Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.JNR_DEV, true); - - boolean eventTestServer = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1"); - - //NOT EVENT TEST! NOT ALLOWED! + if (!allowed) { - allowed = eventTestServer && + allowed = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1") && Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.SNR_MODERATOR, true); - } if (!allowed) From 91ce9cfba748f1cec06d9f27d38111af81d97297 Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Sun, 16 Aug 2015 08:39:03 +0200 Subject: [PATCH 4/7] fixed a crash with fireworks --- .../Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java index 3fde170ec..ab3b37f02 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java @@ -10,6 +10,7 @@ import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Bat; import org.bukkit.entity.Entity; +import org.bukkit.entity.Firework; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Slime; @@ -358,7 +359,7 @@ public class SoccerManager extends MiniPlugin if (inPlayerArena(ent)) { - if (ent instanceof Bat || ent instanceof WitherSkull || ent instanceof TNTPrimed) + if (ent instanceof Bat || ent instanceof WitherSkull || ent instanceof TNTPrimed || ent instanceof Firework) { ent.remove(); continue; From 8cc5ff042c240f65309b54f93dac4df583c4fc07 Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Sun, 16 Aug 2015 09:33:15 +0200 Subject: [PATCH 5/7] fixed block hunt gem exploits --- .../game/arcade/game/games/hideseek/HideSeek.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index 28bc955d8..bb7fa45b0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -837,6 +837,9 @@ public class HideSeek extends TeamGame @EventHandler public void UseBoost(PlayerInteractEvent event) { + if (!IsLive()) + return; + Player player = event.getPlayer(); if (!UtilEvent.isAction(event, ActionType.R)) @@ -901,6 +904,9 @@ public class HideSeek extends TeamGame @EventHandler public void UseMeow(PlayerInteractEvent event) { + if (!IsLive()) + return; + Player player = event.getPlayer(); if (!UtilEvent.isAction(event, ActionType.R)) @@ -927,6 +933,9 @@ public class HideSeek extends TeamGame @EventHandler public void UseFirework(PlayerInteractEvent event) { + if (!IsLive()) + return; + Player player = event.getPlayer(); if (!UtilEvent.isAction(event, ActionType.R)) From 7a7543886f154b6bd8a6970e81d64a35798dfa25 Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Mon, 17 Aug 2015 09:04:39 +0200 Subject: [PATCH 6/7] fixed a ton of commands NPEing on no args --- .../achievement/command/StatsCommand.java | 2 +- .../bonuses/commands/AnimationCommand.java | 19 +- .../core/chat/command/ChatSlowCommand.java | 2 +- .../mineplex/core/command/CommandCenter.java | 2 +- .../core/creature/command/MobCommand.java | 2 +- .../core/message/commands/AdminCommand.java | 2 +- .../message/commands/AdminMessageCommand.java | 2 +- .../message/commands/AnnounceCommand.java | 2 +- .../core/message/commands/GlobalCommand.java | 2 +- .../message/commands/MessageAdminCommand.java | 2 +- .../core/message/commands/MessageCommand.java | 2 +- .../message/commands/ResendAdminCommand.java | 2 +- .../core/message/commands/ResendCommand.java | 2 +- .../mineplex/core/npc/command/AddCommand.java | 2 +- .../core/npc/command/ClearCommand.java | 2 +- .../core/npc/command/DeleteCommand.java | 2 +- .../core/npc/command/HomeCommand.java | 2 +- .../core/npc/command/RefreshCommand.java | 2 +- .../fields/commands/FieldBlockCommand.java | 2 +- .../hub/commands/DisguiseCommand.java | 548 ++++++++-------- .../game/arcade/command/DisguiseCommand.java | 596 +++++++++--------- .../game/arcade/command/SetCommand.java | 2 +- .../game/arcade/command/StartCommand.java | 2 +- 23 files changed, 600 insertions(+), 603 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java index 147b33d59..d7d3fabb3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java @@ -17,7 +17,7 @@ public class StatsCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null || args.length == 0) + if (args.length == 0) { Plugin.openShop(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java index c3356c9b7..f3b20f8f8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java @@ -9,9 +9,9 @@ import mineplex.core.reward.RewardType; import mineplex.core.bonuses.BonusManager; public class AnimationCommand extends CommandBase{ - + private BonusManager _plugin; - + public AnimationCommand(BonusManager plugin) { super(plugin, Rank.DEVELOPER, "animation"); @@ -21,17 +21,14 @@ public class AnimationCommand extends CommandBase{ @Override public void Execute(Player caller, String[] args) { - - if(args != null) - { - caller = Bukkit.getPlayer(args[0]); - _plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SpinnerFiller, true)); - } - if(args.length >= 2) + caller = Bukkit.getPlayer(args[0]); + _plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SpinnerFiller, true)); + + if (args.length >= 2) { _plugin.addPendingExplosion(caller, args[1]); } - + } - + } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java index 8bd788fc8..d15fc0f72 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java @@ -18,7 +18,7 @@ public class ChatSlowCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args != null && args.length == 1) + if (args.length == 1) { try { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java index 2b4d8f81b..8ba516512 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java @@ -48,7 +48,7 @@ public class CommandCenter implements Listener public void OnPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { String commandName = event.getMessage().substring(1); - String[] args = null; + String[] args = new String[] {}; if (commandName.contains(" ")) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java index d43ccccbf..e98a0699d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java @@ -37,7 +37,7 @@ public class MobCommand extends MultiCommandBase @Override protected void Help(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { HashMap entMap = new HashMap(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java index 8534424dc..3e1c6944c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java @@ -21,7 +21,7 @@ public class AdminCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java index f2336f543..3715bc60f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminMessageCommand.java @@ -18,7 +18,7 @@ public class AdminMessageCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java index e4c8865fb..c82cdd800 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java @@ -22,7 +22,7 @@ public class AnnounceCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/GlobalCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/GlobalCommand.java index fae3d2a36..9c9f12e62 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/GlobalCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/GlobalCommand.java @@ -20,7 +20,7 @@ public class GlobalCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java index 89a459c36..4cacd70e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java @@ -18,7 +18,7 @@ public class MessageAdminCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java index 405c4bf4d..53db5de4e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java @@ -18,7 +18,7 @@ public class MessageCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java index a1a4f21c3..752372a82 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java @@ -18,7 +18,7 @@ public class ResendAdminCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java index 4a9c9b6a4..65baece24 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java @@ -18,7 +18,7 @@ public class ResendCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) { Plugin.Help(caller); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java index 08beeb4fe..5de1e1525 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java @@ -19,7 +19,7 @@ public class AddCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null) + if (args == null || args.length == 0) Plugin.help(caller); else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java index ff1a59bbf..aae8c26a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java @@ -20,7 +20,7 @@ public class ClearCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args != null) + if (args.length > 0) Plugin.help(caller); else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java index 4b7ab183b..71dce58c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java @@ -18,7 +18,7 @@ public class DeleteCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args != null) + if (args.length > 0) Plugin.help(caller); else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java index 03382bf95..51e8a622e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java @@ -18,7 +18,7 @@ public class HomeCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args != null) + if (args.length > 0) Plugin.help(caller); else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java index f77033b26..465b8ee02 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java @@ -20,7 +20,7 @@ public class RefreshCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args != null) + if (args.length > 0) Plugin.help(caller); else { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldBlockCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldBlockCommand.java index e7cebc87e..9c55bf6d1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldBlockCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldBlockCommand.java @@ -19,7 +19,7 @@ public class FieldBlockCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null || args[0].equalsIgnoreCase("help")) + if (args.length == 0 || args[0].equalsIgnoreCase("help")) { Plugin.help(caller); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java index 0402366e7..30b45e375 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -49,307 +49,307 @@ import com.mysql.jdbc.BalanceStrategy; public class DisguiseCommand extends CommandBase implements Listener { - private NautHashMap _disguisedPlayers = new NautHashMap<>(); - private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); - private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); + private NautHashMap _disguisedPlayers = new NautHashMap<>(); + private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); + private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); - public DisguiseCommand(HubManager plugin) - { - super(plugin, Rank.JNR_DEV, new Rank[] - { - Rank.YOUTUBE, Rank.TWITCH }, "disguise"); + public DisguiseCommand(HubManager plugin) + { + super(plugin, Rank.JNR_DEV, new Rank[] + { + Rank.YOUTUBE, Rank.TWITCH }, "disguise"); plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); new NCPDataManFix(); - } + } - @Override - public void Execute(final Player caller, final String[] args) - { - if(args == null) + @Override + public void Execute(final Player caller, final String[] args) { - if(!Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); - return; - } - try - { - _disguisedPlayers.remove(caller); - _disguisedPlayerDisguises.remove(caller); - Plugin.GetDisguise().undisguise(caller); - String playerName = _disguisedPlayersNames.get(caller); - - CoreClient client = Plugin.GetClients().Get(caller); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(caller, playerName); - - for(Player other : UtilServer.getPlayers()) + if(args == null || args.length == 0) { - for(Team team : other.getScoreboard().getTeams()) - { - if(team.hasPlayer(caller)) + if(!Plugin.GetDisguise().isDisguised(caller)) { - team.removePlayer(caller); + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; } - } - other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); - } + try + { + _disguisedPlayers.remove(caller); + _disguisedPlayerDisguises.remove(caller); + Plugin.GetDisguise().undisguise(caller); + String playerName = _disguisedPlayersNames.get(caller); - UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); - return; - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - if(args != null && args.length > 1) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); - return; - } + CoreClient client = Plugin.GetClients().Get(caller); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); - Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() - { - @Override - public void run() - { - if(Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); - return; + changeName(caller, playerName); + + for(Player other : UtilServer.getPlayers()) + { + for(Team team : other.getScoreboard().getTeams()) + { + if(team.hasPlayer(caller)) + { + team.removePlayer(caller); + } + } + other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); + } + + UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); + return; + } catch(Exception ex) + { + ex.printStackTrace(); + } } - for(Player other : UtilServer.getPlayers()) + if(args != null && args.length > 1) { - if(other.getName().equalsIgnoreCase(args[0])) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); return; - } - } - if(_disguisedPlayersNames.containsValue(args[0])) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); - return; - } - if(args[0].length() > 16) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); - return; } + Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() + { + @Override + public void run() + { + if(Plugin.GetDisguise().isDisguised(caller)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; + } + for(Player other : UtilServer.getPlayers()) + { + if(other.getName().equalsIgnoreCase(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + } + if(_disguisedPlayersNames.containsValue(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + if(args[0].length() > 16) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + + try + { + CoreClient client = Plugin.GetClients().Get(caller); + UUID uuid = UUIDFetcher.getUUIDOf(args[0]); + GameProfile profile = null; + try + { + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } catch(Exception e) + { + uuid = UUIDFetcher.getUUIDOf("Alex"); + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } + + Rank otherRank = Rank.ALL; + try + { + CoreClient other = new CoreClient(args[0]); + Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); + otherRank = other.GetRank(); + } catch(NullPointerException exception) + {} + if(otherRank.Has(Rank.TWITCH)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); + return; + } + _disguisedPlayers.put(caller, profile); + _disguisedPlayersNames.put(caller, caller.getName()); + client.setDisguisedRank(otherRank); + client.setDisguised(true); + + client.setDisguisedAs(args[0]); + + changeName(caller, args[0]); + + Plugin.GetGadget().RemoveItem(caller); + + UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); + } catch(Exception e) + { + e.printStackTrace(); + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + } + }); + } + + @EventHandler + public void updateDisguises(UpdateEvent event) + { + if(event.getType() != UpdateType.FASTEST) + return; + + for(final Player player : UtilServer.getPlayers()) + { + if(!_disguisedPlayers.containsKey(player)) + continue; + + for(Player other : UtilServer.getPlayers()) + { + try + { + for(Team team : other.getScoreboard().getTeams()) + { + if(team.hasPlayer(player)) + { + team.removePlayer(player); + } + } + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); + + } catch(NullPointerException exp) + {} + } + + if(Plugin.GetDisguise().isDisguised(player)) + continue; + + DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); + _disguisedPlayerDisguises.put(player, playerDisguise); + Plugin.GetDisguise().disguise(playerDisguise); + } + } + + public void changeName(Player player, String changedName) + { try { - CoreClient client = Plugin.GetClients().Get(caller); - UUID uuid = UUIDFetcher.getUUIDOf(args[0]); - GameProfile profile = null; - try - { - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } catch(Exception e) - { - uuid = UUIDFetcher.getUUIDOf("Alex"); - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } + Field name = GameProfile.class.getDeclaredField("name"); + Field declaredProfile = EntityHuman.class.getDeclaredField("i"); + declaredProfile.setAccessible(true); + GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); - Rank otherRank = Rank.ALL; - try - { - CoreClient other = new CoreClient(args[0]); - Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); - otherRank = other.GetRank(); - } catch(NullPointerException exception) - {} - if(otherRank.Has(Rank.TWITCH)) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); - return; - } - _disguisedPlayers.put(caller, profile); - _disguisedPlayersNames.put(caller, caller.getName()); - client.setDisguisedRank(otherRank); - client.setDisguised(true); - - client.setDisguisedAs(args[0]); - - changeName(caller, args[0]); - - Plugin.GetGadget().RemoveItem(caller); - - UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); - } catch(Exception e) + name.setAccessible(true); + name.set(gameProfile, changedName); + name.setAccessible(false); + } catch(Exception ex) { - e.printStackTrace(); - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); - return; + ex.printStackTrace(); } - } - }); - } - - @EventHandler - public void updateDisguises(UpdateEvent event) - { - if(event.getType() != UpdateType.FASTEST) - return; - - for(final Player player : UtilServer.getPlayers()) - { - if(!_disguisedPlayers.containsKey(player)) - continue; - - for(Player other : UtilServer.getPlayers()) - { - try - { - for(Team team : other.getScoreboard().getTeams()) - { - if(team.hasPlayer(player)) - { - team.removePlayer(player); - } - } - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); - - } catch(NullPointerException exp) - {} - } - - if(Plugin.GetDisguise().isDisguised(player)) - continue; - - DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); - _disguisedPlayerDisguises.put(player, playerDisguise); - Plugin.GetDisguise().disguise(playerDisguise); } - } - public void changeName(Player player, String changedName) - { - try + @EventHandler(priority = EventPriority.HIGHEST) + public void Quit(PlayerQuitEvent event) { - Field name = GameProfile.class.getDeclaredField("name"); - Field declaredProfile = EntityHuman.class.getDeclaredField("i"); - declaredProfile.setAccessible(true); - GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); - - name.setAccessible(true); - name.set(gameProfile, changedName); - name.setAccessible(false); - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Quit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - try - { - _disguisedPlayers.remove(player); - _disguisedPlayerDisguises.remove(player); - Plugin.GetDisguise().undisguise(player); - String playerName = _disguisedPlayersNames.get(player); - _disguisedPlayersNames.remove(player); - - CoreClient client = Plugin.GetClients().Get(player); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(player, playerName); - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void Join(PlayerLoginEvent event) - { - for(Player player : _disguisedPlayers.keySet()) - { - if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) - { - event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); - } - } - } - - @EventHandler - public void gadget(GadgetActivateEvent event) - { - if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) - return; - - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler - public void chest(TreasureStartEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerSneak(PlayerToggleSneakEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - DisguisePlayer dp = _disguisedPlayerDisguises.get(player); - - dp.setSneaking(!dp.getSneaking()); - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onDPlayerChat(AsyncPlayerChatEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setFormat(" *" + event.getMessage()); - } - } - - @EventHandler - public void on(PlayerInteractEvent event) - { - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - Player player = event.getPlayer(); - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = player.getEntityId(); - - for(Player p : Bukkit.getOnlinePlayers()) + if(_disguisedPlayers.containsKey(player)) { - if(p != player) - { - Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); - } + try + { + _disguisedPlayers.remove(player); + _disguisedPlayerDisguises.remove(player); + Plugin.GetDisguise().undisguise(player); + String playerName = _disguisedPlayersNames.get(player); + _disguisedPlayersNames.remove(player); + + CoreClient client = Plugin.GetClients().Get(player); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(player, playerName); + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Join(PlayerLoginEvent event) + { + for(Player player : _disguisedPlayers.keySet()) + { + if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) + { + event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); + } + } + } + + @EventHandler + public void gadget(GadgetActivateEvent event) + { + if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) + return; + + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void chest(TreasureStartEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerSneak(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + DisguisePlayer dp = _disguisedPlayerDisguises.get(player); + + dp.setSneaking(!dp.getSneaking()); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDPlayerChat(AsyncPlayerChatEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setFormat(" *" + event.getMessage()); + } + } + + @EventHandler + public void on(PlayerInteractEvent event) + { + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + + Player player = event.getPlayer(); + + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = player.getEntityId(); + + for(Player p : Bukkit.getOnlinePlayers()) + { + if(p != player) + { + Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); + } + } + } } - } } - } } 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 7c32ed36a..e3d78a5a5 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 @@ -45,330 +45,330 @@ import org.bukkit.scoreboard.Team; public class DisguiseCommand extends CommandBase implements Listener { - private NautHashMap _disguisedPlayers = new NautHashMap<>(); - private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); - private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); + private NautHashMap _disguisedPlayers = new NautHashMap<>(); + private NautHashMap _disguisedPlayersNames = new NautHashMap<>(); + private NautHashMap _disguisedPlayerDisguises = new NautHashMap<>(); - public DisguiseCommand(ArcadeManager plugin) - { - super(plugin, Rank.JNR_DEV, new Rank[] - { Rank.YOUTUBE, Rank.TWITCH }, "disguise"); - plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); - new NCPDataManFix(); - } - - @Override - public void Execute(final Player caller, final String[] args) - { - if(args == null) + public DisguiseCommand(ArcadeManager plugin) { - if(!Plugin.GetDisguise().isDisguised(caller)) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); - return; - } - try - { - _disguisedPlayers.remove(caller); - _disguisedPlayerDisguises.remove(caller); - Plugin.GetDisguise().undisguise(caller); - String playerName = _disguisedPlayersNames.get(caller); - - CoreClient client = Plugin.GetClients().Get(caller); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); - - changeName(caller, playerName, true); - - for(Player other : UtilServer.getPlayers()) - { - for(Team team : other.getScoreboard().getTeams()) - { - team.removePlayer(caller); - } - other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); - } - - UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); - return; - } catch(Exception ex) - { - ex.printStackTrace(); - } - } - if(args != null && args.length > 1) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); - return; + super(plugin, Rank.JNR_DEV, new Rank[] + { Rank.YOUTUBE, Rank.TWITCH }, "disguise"); + plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); + new NCPDataManFix(); } - Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() + @Override + public void Execute(final Player caller, final String[] args) { - @Override - public void run() - { - if(Plugin.GetDisguise().isDisguised(caller)) + if(args == null || args.length == 0) { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); - return; - } - for(Player other : UtilServer.getPlayers()) - { - if(other.getName().equalsIgnoreCase(args[0])) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); - return; - } - } - if(_disguisedPlayersNames.containsValue(args[0])) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); - return; - } - if(args[0].length() > 16) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); - return; - } - - try - { - CoreClient client = Plugin.GetClients().Get(caller); - UUID uuid = UUIDFetcher.getUUIDOf(args[0]); - GameProfile profile = null; - try - { - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } catch(Exception e) - { - uuid = UUIDFetcher.getUUIDOf("Alex"); - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } - - Rank otherRank = Rank.ALL; - try - { - CoreClient other = new CoreClient(args[0]); - Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); - otherRank = other.GetRank(); - } catch(NullPointerException exception) - {} - if(otherRank.Has(Rank.TWITCH)) - { - UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); - return; - } - _disguisedPlayers.put(caller, profile); - _disguisedPlayersNames.put(caller, caller.getName()); - client.setDisguisedRank(otherRank); - client.setDisguised(true); - - client.setDisguisedAs(args[0]); - - changeName(caller, args[0], true); - - Plugin.getCosmeticManager().getGadgetManager().RemoveItem(caller); - - Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); - UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); - } catch(Exception e) - { - e.printStackTrace(); - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); - return; - } - } - }); - } - - @EventHandler - public void updateDisguises(UpdateEvent event) - { - if(event.getType() != UpdateType.FASTEST) - return; - - for(final Player player : UtilServer.getPlayers()) - { - if(!_disguisedPlayers.containsKey(player)) - continue; - - for(Player other : UtilServer.getPlayers()) - { - try - { - if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player)) - { - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player); - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); - } - if(other.getScoreboard().getTeam( - Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) != null) - { - if(other.getScoreboard() - .getTeam(Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) - .getPlayers().contains(player)) + if(!Plugin.GetDisguise().isDisguised(caller)) { - other.getScoreboard() - .getTeam( - Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) - .removePlayer(player); - other.getScoreboard() - .getTeam( - Plugin.GetClients().Get(player).getDisguisedRank().Name - + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()).addPlayer(player); + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; } - } - } catch(NullPointerException exp) - {} - } + try + { + _disguisedPlayers.remove(caller); + _disguisedPlayerDisguises.remove(caller); + Plugin.GetDisguise().undisguise(caller); + String playerName = _disguisedPlayersNames.get(caller); - if(Plugin.GetDisguise().isDisguised(player)) - continue; + CoreClient client = Plugin.GetClients().Get(caller); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); - DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); - _disguisedPlayerDisguises.put(player, playerDisguise); - Plugin.GetDisguise().disguise(playerDisguise); + changeName(caller, playerName, true); + + for(Player other : UtilServer.getPlayers()) + { + for(Team team : other.getScoreboard().getTeams()) + { + team.removePlayer(caller); + } + other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); + } + + UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); + return; + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + if(args != null && args.length > 1) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); + return; + } + + Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() + { + @Override + public void run() + { + if(Plugin.GetDisguise().isDisguised(caller)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + return; + } + for(Player other : UtilServer.getPlayers()) + { + if(other.getName().equalsIgnoreCase(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + } + if(_disguisedPlayersNames.containsValue(args[0])) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + return; + } + if(args[0].length() > 16) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + + try + { + CoreClient client = Plugin.GetClients().Get(caller); + UUID uuid = UUIDFetcher.getUUIDOf(args[0]); + GameProfile profile = null; + try + { + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } catch(Exception e) + { + uuid = UUIDFetcher.getUUIDOf("Alex"); + profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + } + + Rank otherRank = Rank.ALL; + try + { + CoreClient other = new CoreClient(args[0]); + Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); + otherRank = other.GetRank(); + } catch(NullPointerException exception) + {} + if(otherRank.Has(Rank.TWITCH)) + { + UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); + return; + } + _disguisedPlayers.put(caller, profile); + _disguisedPlayersNames.put(caller, caller.getName()); + client.setDisguisedRank(otherRank); + client.setDisguised(true); + + client.setDisguisedAs(args[0]); + + changeName(caller, args[0], true); + + Plugin.getCosmeticManager().getGadgetManager().RemoveItem(caller); + + Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); + UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); + } catch(Exception e) + { + e.printStackTrace(); + UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + return; + } + } + }); } - } - public void changeName(final Player player, String changedName, boolean skin) - { - try + @EventHandler + public void updateDisguises(UpdateEvent event) { - GameProfile gameProfile = ((CraftPlayer) player).getProfile(); + if(event.getType() != UpdateType.FASTEST) + return; - Field name = GameProfile.class.getDeclaredField("name"); - name.setAccessible(true); - name.set(gameProfile, changedName); - name.setAccessible(false); + for(final Player player : UtilServer.getPlayers()) + { + if(!_disguisedPlayers.containsKey(player)) + continue; - } catch(Exception ex) - { - ex.printStackTrace(); + for(Player other : UtilServer.getPlayers()) + { + try + { + if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player)) + { + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player); + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); + } + if(other.getScoreboard().getTeam( + Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) != null) + { + if(other.getScoreboard() + .getTeam(Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) + .getPlayers().contains(player)) + { + other.getScoreboard() + .getTeam( + Plugin.GetClients().Get(player).GetRank().Name + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()) + .removePlayer(player); + other.getScoreboard() + .getTeam( + Plugin.GetClients().Get(player).getDisguisedRank().Name + + Plugin.GetGame().GetTeam(player).GetName().toUpperCase()).addPlayer(player); + } + } + } catch(NullPointerException exp) + {} + } + + if(Plugin.GetDisguise().isDisguised(player)) + continue; + + DisguisePlayer playerDisguise = new DisguisePlayer(player, _disguisedPlayers.get(player)); + _disguisedPlayerDisguises.put(player, playerDisguise); + Plugin.GetDisguise().disguise(playerDisguise); + } } - } - @EventHandler(priority = EventPriority.HIGHEST) - public void Quit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) + public void changeName(final Player player, String changedName, boolean skin) { - try - { - _disguisedPlayers.remove(player); - _disguisedPlayerDisguises.remove(player); - Plugin.GetDisguise().undisguise(player); - String playerName = _disguisedPlayersNames.get(player); - _disguisedPlayersNames.remove(player); + try + { + GameProfile gameProfile = ((CraftPlayer) player).getProfile(); - CoreClient client = Plugin.GetClients().Get(player); - client.setDisguisedRank(null); - client.setDisguisedAs(null); - client.setDisguised(false); + Field name = GameProfile.class.getDeclaredField("name"); + name.setAccessible(true); + name.set(gameProfile, changedName); + name.setAccessible(false); - changeName(player, playerName, true); - } catch(Exception ex) - { - ex.printStackTrace(); - } + } catch(Exception ex) + { + ex.printStackTrace(); + } } - } - @EventHandler(priority = EventPriority.HIGHEST) - public void Join(PlayerLoginEvent event) - { - for(Player player : _disguisedPlayers.keySet()) + @EventHandler(priority = EventPriority.HIGHEST) + public void Quit(PlayerQuitEvent event) { - if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) - { - event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); - } - } - } - - @EventHandler - public void gadget(GadgetActivateEvent event) - { - if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) - return; - - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler - public void chest(TreasureStartEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerSneak(PlayerToggleSneakEvent event) - { - Player player = event.getPlayer(); - - if(_disguisedPlayers.containsKey(player)) - { - DisguisePlayer dp = _disguisedPlayerDisguises.get(player); - - dp.setSneaking(!dp.getSneaking()); - } - } - - @EventHandler - public void onPlayerLeftClick(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(player)) - { - EntityHuman human = (((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); - human.world.broadcastEntityEffect(human, (byte) 0); - } - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onDPlayerChat(AsyncPlayerChatEvent event) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - event.setFormat(" *" + event.getMessage()); - } - } - - @EventHandler - public void on(PlayerInteractEvent event) - { - if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) - { - if(_disguisedPlayers.containsKey(event.getPlayer())) - { - Player player = event.getPlayer(); - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = player.getEntityId(); - - for(Player p : Bukkit.getOnlinePlayers()) + if(_disguisedPlayers.containsKey(player)) { - if(p != player) - { - Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); - } + try + { + _disguisedPlayers.remove(player); + _disguisedPlayerDisguises.remove(player); + Plugin.GetDisguise().undisguise(player); + String playerName = _disguisedPlayersNames.get(player); + _disguisedPlayersNames.remove(player); + + CoreClient client = Plugin.GetClients().Get(player); + client.setDisguisedRank(null); + client.setDisguisedAs(null); + client.setDisguised(false); + + changeName(player, playerName, true); + } catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void Join(PlayerLoginEvent event) + { + for(Player player : _disguisedPlayers.keySet()) + { + if(player.getName().equalsIgnoreCase(event.getPlayer().getName())) + { + event.disallow(Result.KICK_OTHER, "There is already the same account playing. this probably happened because of /disguise"); + } + } + } + + @EventHandler + public void gadget(GadgetActivateEvent event) + { + if(!event.getGadget().GetName().equalsIgnoreCase("Coin Party Bomb") && event.getGadget().getGadgetType() != GadgetType.Morph) + return; + + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void chest(TreasureStartEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Disguise", "You cant open Treasure Chests while you are disguised!")); + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerSneak(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + + if(_disguisedPlayers.containsKey(player)) + { + DisguisePlayer dp = _disguisedPlayerDisguises.get(player); + + dp.setSneaking(!dp.getSneaking()); + } + } + + @EventHandler + public void onPlayerLeftClick(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(player)) + { + EntityHuman human = (((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); + human.world.broadcastEntityEffect(human, (byte) 0); + } + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDPlayerChat(AsyncPlayerChatEvent event) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + event.setFormat(" *" + event.getMessage()); + } + } + + @EventHandler + public void on(PlayerInteractEvent event) + { + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(event.getPlayer())) + { + + Player player = event.getPlayer(); + + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = player.getEntityId(); + + for(Player p : Bukkit.getOnlinePlayers()) + { + if(p != player) + { + Plugin.getPacketHandler().getPacketVerifier((Player) p).bypassProcess(packet); + } + } + } } - } } - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java index d6958a663..035e491b0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java @@ -27,7 +27,7 @@ public class SetCommand extends CommandBase if (Plugin.GetGame() == null) return; - if (args == null || args.length == 0) + if (args.length == 0) { caller.sendMessage(F.help("/game set (MapSource) (Map)", "Set the current game or next game", Rank.ADMIN)); return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java index 7a7a0dd43..499fe8063 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java @@ -28,7 +28,7 @@ public class StartCommand extends CommandBase } int seconds; - if(args != null && args.length > 0) + if(args.length > 0) seconds = Integer.parseInt(args[0]); else seconds = 10; From 0a23f9159239987689f5576d9f6b007fdbcc6144 Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Mon, 17 Aug 2015 11:53:50 +0200 Subject: [PATCH 7/7] fixed two little bogs --- .../src/mineplex/core/donation/command/GemCommand.java | 10 +++++----- .../mineplex/core/donation/command/GoldCommand.java | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java index 7593be55f..8690987bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java @@ -24,7 +24,7 @@ public class GemCommand extends CommandBase { if (args.length < 2) { - UtilPlayer.message(caller, F.main("gem", "Missing Args: " + F.elem("/gem "))); + UtilPlayer.message(caller, F.main("Gem", "Missing Args: " + F.elem("/gem "))); return; } @@ -59,7 +59,7 @@ public class GemCommand extends CommandBase } catch (Exception e) { - UtilPlayer.message(caller, F.main("gem", "Invalid gems Amount")); + UtilPlayer.message(caller, F.main("Gem", "Invalid gems Amount")); } } @@ -71,16 +71,16 @@ public class GemCommand extends CommandBase { if (completed) { - UtilPlayer.message(caller, F.main("gem", "You gave " + F.elem(gems + " gems") + " to " + F.name(targetName) + ".")); + UtilPlayer.message(caller, F.main("Gem", "You gave " + F.elem(gems + " gems") + " to " + F.name(targetName) + ".")); if (target != null) { - UtilPlayer.message(target, F.main("gem", F.name(caller.getName()) + " gave you " + F.elem(gems + " gems") + ".")); + UtilPlayer.message(target, F.main("Gem", F.name(caller.getName()) + " gave you " + F.elem(gems + " gems") + ".")); } } else { - UtilPlayer.message(caller, F.main("gem", "There was an error giving " + F.elem(gems + " gems") + " to " + F.name(targetName) + ".")); + UtilPlayer.message(caller, F.main("Gem", "There was an error giving " + F.elem(gems + " gems") + " to " + F.name(targetName) + ".")); } } }, caller.getName(), targetName, uuid, gems); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java index 6fa015312..36095de1b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GoldCommand.java @@ -23,6 +23,7 @@ public class GoldCommand extends CommandBase if (args == null || args.length == 0) { UtilPlayer.message(caller, F.main("Gold", "Your Gold: " + F.elem("" + Plugin.Get(caller).getGold()))); + return; } else if (args.length < 2) {