From 7e1b0b911061d62fcfa6f1319cda93fe6d4fb7cd Mon Sep 17 00:00:00 2001 From: Morten Date: Sat, 2 Jan 2016 03:19:39 +0100 Subject: [PATCH] Love you Sarah <3 --- .../core/disguise/DisguisePlayerBean.java | 34 ++++++++++ .../core/disguise/PlayerDisguiseManager.java | 68 +++++++++++++++++++ .../core/disguise/PlayerUndisguiseEvent.java | 31 +++++++++ .../core/message/commands/AdminCommand.java | 8 ++- .../src/mineplex/hub/HubManager.java | 3 +- .../hub/commands/DisguiseCommand.java | 2 + .../serverdata/redis/RedisDataRepository.java | 1 + .../nautilus/game/arcade/ArcadeManager.java | 3 + .../game/arcade/command/DisguiseCommand.java | 2 + 9 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java new file mode 100644 index 000000000..3403768bb --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java @@ -0,0 +1,34 @@ +package mineplex.core.disguise; + +import mineplex.serverdata.data.Data; + +public class DisguisePlayerBean implements Data +{ + private int _accountID; + private String _disguisedPlayer; + private String _playerName; + public DisguisePlayerBean(int playerAccountID, String playerName, String disguiseAs) + { + this._accountID = playerAccountID; + this._disguisedPlayer = disguiseAs; + this._playerName = playerName; + + } + public int getAccountID() + { + return _accountID; + } + public String getDisguisedPlayer() + { + return _disguisedPlayer; + } + public String getPlayerName() + { + return _playerName; + } + @Override + public String getDataId() + { + return _accountID+_playerName; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java new file mode 100644 index 000000000..d7edc247a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java @@ -0,0 +1,68 @@ +package mineplex.core.disguise; + +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.serverdata.Region; +import mineplex.serverdata.redis.RedisDataRepository; + +public class PlayerDisguiseManager extends MiniPlugin +{ + private CoreClientManager _clients; + private RedisDataRepository _redis; + public PlayerDisguiseManager(JavaPlugin plugin, CoreClientManager clients) + { + super("Player Disguise Manager", plugin); + this._clients = clients; + + _redis = new RedisDataRepository(Region.ALL, DisguisePlayerBean.class, "disguisedPlayer"); + } + + @EventHandler + public void onDisguisedPlayerQuit(PlayerQuitEvent event) + { + CoreClient client = _clients.Get(event.getPlayer()); + if(client.isDisguised()) + { + _redis.addElement(new DisguisePlayerBean(client.getAccountId(), client.GetPlayerName(), client.getDisguisedAs()), 60*60*12); // 12 hours + } + } + + @EventHandler + public void onDisguisedPlayerJoin(PlayerJoinEvent event) + { + new BukkitRunnable() + { + @Override + public void run() + { + CoreClient client = _clients.Get(event.getPlayer()); + + if(!client.GetRank().has(Rank.JNR_DEV) && client.GetRank() != Rank.YOUTUBE_SMALL && client.GetRank() != Rank.TWITCH && client.GetRank() != Rank.YOUTUBE) + return; + + if(_redis.elementExists(client.getAccountId()+client.GetPlayerName())) + { + DisguisePlayerBean bean = _redis.getElement(client.getAccountId()+client.GetPlayerName()); + Bukkit.getPluginManager().callEvent(new PlayerCommandPreprocessEvent(event.getPlayer(), "/Disguise " + bean.getDisguisedPlayer())); + } + } + }.runTaskLater(getPlugin(), 7); + } + + @EventHandler + public void onPlayerUndisguise(PlayerUndisguiseEvent event) + { + CoreClient client = _clients.Get(event.getPlayer()); + _redis.removeElement(client.getAccountId()+client.GetPlayerName()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java new file mode 100644 index 000000000..ad8d9a9d0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java @@ -0,0 +1,31 @@ +package mineplex.core.disguise; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlayerUndisguiseEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + private Player _player; + public PlayerUndisguiseEvent(Player disguisee) + { + this._player = disguisee; + } + + public Player getPlayer() + { + return _player; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} 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 5735a2dc4..f9c2242d1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java @@ -10,6 +10,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.message.MessageManager; +import mineplex.core.visibility.VisibilityManager; public class AdminCommand extends CommandBase { @@ -52,7 +53,12 @@ public class AdminCommand extends CommandBase { if (!to.equals(caller)) UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message); - + + if(Plugin.GetClientManager().Get(to).GetRank().has(Rank.JNR_DEV)) + { + if(Plugin.GetClientManager().Get(to).isDisguised() || !caller.canSee(to)) + continue; + } staff = true; //Sound diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 55d00076d..24be3b3dc 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -33,6 +33,7 @@ import mineplex.core.common.util.UtilWorld; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.PlayerDisguiseManager; import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; @@ -249,7 +250,7 @@ public class HubManager extends MiniClientPlugin // _halloweenManager = new HalloweenSpookinessManager(this); new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); - + new PlayerDisguiseManager(plugin, _clientManager); // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java index 84439b77d..2fc0346ab 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -13,6 +13,7 @@ import mineplex.core.common.util.ProfileLoader; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.PlayerUndisguiseEvent; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.types.GadgetType; @@ -83,6 +84,7 @@ public class DisguiseCommand extends CommandBase implements Listener _disguisedPlayerDisguises.remove(caller); Plugin.GetDisguise().undisguise(caller); String playerName = _disguisedPlayersNames.get(caller); + Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller)); CoreClient client = Plugin.GetClients().Get(caller); client.setDisguisedRank(null); diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisDataRepository.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisDataRepository.java index a49de5b64..caea6188b 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisDataRepository.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisDataRepository.java @@ -55,6 +55,7 @@ public class RedisDataRepository implements DataRepository _region = region; _elementType = elementType; _elementLabel = elementLabel; + } public RedisDataRepository(ConnectionData conn, Region region, Class elementType, String elementLabel) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 943be1a3e..db787f98e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -3,6 +3,7 @@ package nautilus.game.arcade; import java.io.File; import java.util.ArrayList; import java.util.HashSet; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -51,6 +52,7 @@ import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.PlayerDisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.energy.Energy; @@ -291,6 +293,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager); new HolidayManager(this, titanGiveaway); new GameTestingManager(this); + new PlayerDisguiseManager(plugin, _clientManager); // Game Addons new CompassAddon(plugin, this); 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 ba13306e0..c8f9f5a9a 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 @@ -13,6 +13,7 @@ import mineplex.core.common.util.ProfileLoader; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.PlayerUndisguiseEvent; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.types.GadgetType; @@ -86,6 +87,7 @@ public class DisguiseCommand extends CommandBase implements Liste _disguisedPlayerDisguises.remove(caller); Plugin.GetDisguise().undisguise(caller); String playerName = _disguisedPlayersNames.get(caller); + Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller)); CoreClient client = Plugin.GetClients().Get(caller); client.setDisguisedRank(null);