From 7f92a3c0485a86b33054e7e1c34cb446d22619ef Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 5 Apr 2016 00:38:27 +0100 Subject: [PATCH] incognito changes --- .../src/mineplex/core/chat/Chat.java | 8 ++- .../core/incognito/IncognitoManager.java | 72 +++++++++---------- .../events/IncognitoStatusChangeEvent.java | 12 ++++ .../mineplex/core/message/MessageManager.java | 18 +++-- .../core/message/commands/AdminCommand.java | 13 +++- .../src/mineplex/game/clans/Clans.java | 6 +- .../game/clans/clans/ClansManager.java | 15 ++-- .../clans/clans/commands/ClansCommand.java | 2 +- .../clans/clans/staff/SilentChestOpen.java | 2 +- .../items/legendaries/MeridianScepter.java | 2 +- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 4 +- .../src/mineplex/hub/HubManager.java | 15 +++- .../src/mineplex/staffServer/StaffServer.java | 15 ++-- .../src/nautilus/game/arcade/Arcade.java | 6 +- .../nautilus/game/arcade/ArcadeManager.java | 31 ++++++-- 15 files changed, 142 insertions(+), 79 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index b0d9d7448..fcdb2aafa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -58,6 +58,7 @@ public class Chat extends MiniPlugin private CoreClientManager _clientManager; private PreferencesManager _preferences; private AchievementManager _achievements; + private IncognitoManager _incognitoManager; private String[] _hackusations = {"hack", "hax", "hacker", "hacking", "cheat", "cheater", "cheating", "forcefield", "flyhack", "flyhacking", "autoclick", "aimbot"}; private String _filterUrl = "https://chat.mineplex.com:8003/content/item/moderate"; @@ -74,10 +75,11 @@ public class Chat extends MiniPlugin private HashMap _playerLastMessage = new HashMap(); - public Chat(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, AchievementManager achievements, String serverName) + public Chat(JavaPlugin plugin, IncognitoManager incognitoManager, CoreClientManager clientManager, PreferencesManager preferences, AchievementManager achievements, String serverName) { super("Chat", plugin); - + + _incognitoManager = incognitoManager; _clientManager = clientManager; _serverName = serverName; _preferences = preferences; @@ -308,7 +310,7 @@ public class Chat extends MiniPlugin Player sender = event.getPlayer(); - if (IncognitoManager.Instance.Get(sender).Status) + if (_incognitoManager != null && _incognitoManager.Get(sender).Status) { UtilPlayer.message(sender, C.cYellow + "You can not chat while incognito."); event.setCancelled(true); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java index db73b3b55..91d873faa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java @@ -2,24 +2,26 @@ package mineplex.core.incognito; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniClientPlugin; +import com.google.common.base.Function; + import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.incognito.commands.IncognitoToggleCommand; +import mineplex.core.incognito.events.IncognitoHidePlayerEvent; import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.incognito.repository.IncognitoClient; import mineplex.core.incognito.repository.IncognitoRepository; @@ -31,17 +33,13 @@ public class IncognitoManager extends MiniDbClientPlugin { private CoreClientManager _clientManager; private IncognitoRepository _repository; - - public static IncognitoManager Instance; - + public IncognitoManager(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler) { super("Incognito", plugin, clientManager); _repository = new IncognitoRepository(this); _clientManager = clientManager; - - Instance = this; } public void addCommands() @@ -64,9 +62,23 @@ public class IncognitoManager extends MiniDbClientPlugin if (!enabled) { - for (Player other : UtilServer.getPlayers()) + if (event.doShow()) { - other.showPlayer(caller); + for (Player other : UtilServer.getPlayers()) + { + other.showPlayer(caller); + } + } + } + else + { + IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(caller)); + + if (!customEvent.isCancelled()) + { + UtilServer.getPlayersCollection().forEach(player -> { + player.hidePlayer(caller); + }); } } @@ -75,28 +87,6 @@ public class IncognitoManager extends MiniDbClientPlugin return enabled; } - @EventHandler(priority = EventPriority.LOWEST) - public void Update(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - { - UtilServer.getPlayersCollection().forEach(player -> - { - UtilServer.getPlayersCollection().forEach(other -> - { - if (Get(other).Status && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank())) - player.hidePlayer(other); - - if (Get(player).Status) - { - if (!_clientManager.hasRank(other, _clientManager.Get(player).GetRank())) - other.hidePlayer(player); - } - }); - }); - } - } - @EventHandler(priority = EventPriority.HIGHEST) public void Join(PlayerJoinEvent event) { @@ -105,15 +95,23 @@ public class IncognitoManager extends MiniDbClientPlugin event.setJoinMessage(null); informIncognito(event.getPlayer()); } - + + IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(event.getPlayer())); + UtilServer.getPlayersCollection().forEach(player -> { - if (Get(event.getPlayer()).Status && !_clientManager.hasRank(player, _clientManager.Get(event.getPlayer()).GetRank())) + if (!customEvent.isCancelled() && Get(event.getPlayer()).Status && !_clientManager.hasRank(player, _clientManager.Get(event.getPlayer()).GetRank())) + { player.hidePlayer(event.getPlayer()); - + } + if (Get(player).Status) { - if (!_clientManager.hasRank(event.getPlayer(), _clientManager.Get(player).GetRank())) + IncognitoHidePlayerEvent customEvent2 = UtilServer.CallEvent(new IncognitoHidePlayerEvent(player)); + + if (!customEvent2.isCancelled() && !_clientManager.hasRank(event.getPlayer(), _clientManager.Get(player).GetRank())) + { event.getPlayer().hidePlayer(player); + } } }); } @@ -153,7 +151,7 @@ public class IncognitoManager extends MiniDbClientPlugin { return _repository; } - + @Override public String getQuery(int accountId, String uuid, String name) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoStatusChangeEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoStatusChangeEvent.java index 1bf0f1ed2..79e3291ee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoStatusChangeEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoStatusChangeEvent.java @@ -13,6 +13,8 @@ public class IncognitoStatusChangeEvent extends Event private boolean _cancelled; + private boolean _show = true; + public IncognitoStatusChangeEvent(Player player, boolean newState) { _player = player; @@ -49,4 +51,14 @@ public class IncognitoStatusChangeEvent extends Event return handlers; } + public void show(boolean show) + { + _show = show; + } + + public boolean doShow() + { + return _show; + } + } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index 8e1790063..a84ed8cdf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -27,7 +27,12 @@ import mineplex.core.friend.data.FriendData; import mineplex.core.friend.data.FriendStatus; import mineplex.core.ignore.IgnoreManager; import mineplex.core.incognito.IncognitoManager; -import mineplex.core.message.commands.*; +import mineplex.core.message.commands.AdminCommand; +import mineplex.core.message.commands.AnnounceCommand; +import mineplex.core.message.commands.MessageAdminCommand; +import mineplex.core.message.commands.MessageCommand; +import mineplex.core.message.commands.ResendAdminCommand; +import mineplex.core.message.commands.ResendCommand; import mineplex.core.message.redis.AnnouncementHandler; import mineplex.core.message.redis.MessageHandler; import mineplex.core.message.redis.RedisMessage; @@ -45,6 +50,8 @@ public class MessageManager extends MiniClientPlugin private CoreClientManager _clientManager; private FriendManager _friendsManager; private IgnoreManager _ignoreManager; + private IncognitoManager _incognitoManager; + private HashMap _messageTimeouts = new HashMap(); private PreferencesManager _preferences; private Punish _punish; @@ -52,11 +59,12 @@ public class MessageManager extends MiniClientPlugin private ArrayList _randomMessage; private String _serverName; - public MessageManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, + public MessageManager(JavaPlugin plugin, IncognitoManager incognitoManager, CoreClientManager clientManager, PreferencesManager preferences, IgnoreManager ignoreManager, Punish punish, FriendManager friendManager, Chat chat) { super("Message", plugin); - + + _incognitoManager = incognitoManager; _clientManager = clientManager; _preferences = preferences; _ignoreManager = ignoreManager; @@ -86,7 +94,7 @@ public class MessageManager extends MiniClientPlugin addCommand(new AnnounceCommand(this)); //addCommand(new GlobalCommand(this)); - addCommand(new AdminCommand(this)); + addCommand(new AdminCommand(this, _incognitoManager)); } @Override @@ -523,7 +531,7 @@ public class MessageManager extends MiniClientPlugin // If this is a message inside the server if (to != null) { - if (IncognitoManager.Instance.Get(to).Status) + if (_incognitoManager.Get(to).Status) { UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "].")); return; 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 f9c2242d1..be869c072 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java @@ -9,14 +9,18 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.incognito.IncognitoManager; import mineplex.core.message.MessageManager; -import mineplex.core.visibility.VisibilityManager; public class AdminCommand extends CommandBase { - public AdminCommand(MessageManager plugin) + private IncognitoManager _incognitoManager; + + public AdminCommand(MessageManager plugin, IncognitoManager incognitoManager) { super(plugin, Rank.ALL, "a","admin"); + + _incognitoManager = incognitoManager; } @Override @@ -51,6 +55,11 @@ public class AdminCommand extends CommandBase { if (Plugin.GetClientManager().Get(to).GetRank().has(Rank.HELPER)) { + if (_incognitoManager.Get(to).Status) + { + continue; + } + if (!to.equals(caller)) UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index bf654ff83..a9e32d2dd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -120,12 +120,12 @@ public class Clans extends JavaPlugin IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); - new IncognitoManager(this, _clientManager, packetHandler); + IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler); StatsManager statsManager = new StatsManager(this, _clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager); - Chat chat = new Chat(this, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); - new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat); + Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); + new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat); new MemoryFix(this); new FoodDupeFix(this); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 567362919..6c1165401 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -74,7 +74,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansUtility.ClanRelation; -import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.commands.ClanManagementCommand; import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand; @@ -99,7 +98,6 @@ import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.siege.SiegeManager; -import mineplex.game.clans.clans.siege.outpost.OutpostManager; import mineplex.game.clans.clans.staff.SilentChestOpen; import mineplex.game.clans.clans.supplyDrop.SupplyDropManager; import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager; @@ -172,6 +170,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati private NetherManager _netherManager; private DamageManager _damageManager; private SiegeManager _siegeManager; + private IncognitoManager _incognitoManager; private ClansBlacklist _blacklist; @@ -236,6 +235,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati /*_clansBans = clansBans;*/ _punish = punish; + _incognitoManager = new IncognitoManager(plugin, clientManager, packetHandler); _serverName = serverName; _clientManager = clientManager; _combatManager = new CombatManager(plugin); @@ -603,7 +603,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati return; }*/ - if (IncognitoManager.Instance.Get(event.getPlayer()).Status) + if (_incognitoManager.Get(event.getPlayer()).Status) { return; } @@ -632,7 +632,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati { event.setQuitMessage(null); - if (IncognitoManager.Instance.Get(event.getPlayer()).Status) + if (_incognitoManager.Get(event.getPlayer()).Status) { return; } @@ -657,7 +657,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati @EventHandler(priority = EventPriority.HIGHEST) public void Kick(PlayerKickEvent event) { - if (IncognitoManager.Instance.Get(event.getPlayer()).Status) + if (_incognitoManager.Get(event.getPlayer()).Status) { event.setLeaveMessage(null); return; @@ -1370,4 +1370,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati { return _siegeManager; } + + public IncognitoManager getIncognitoManager() + { + return _incognitoManager; + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 7d063af44..741fc365a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -357,7 +357,7 @@ public class ClansCommand extends CommandBase } Player target = UtilPlayer.searchOnline(caller, args[1], true); - if (target == null || IncognitoManager.Instance.Get(target).Status) return; + if (target == null || _clansManager.getIncognitoManager().Get(target).Status) return; Plugin.getClanUtility().invite(caller, clan, target); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestOpen.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestOpen.java index c3fe7119d..2f9bfabae 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestOpen.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/staff/SilentChestOpen.java @@ -25,7 +25,7 @@ public class SilentChestOpen extends MiniPlugin @EventHandler public void onInteract(PlayerInteractEvent event) { - if (!IncognitoManager.Instance.Get(event.getPlayer()).Status) + if (!_clansManager.getIncognitoManager().Get(event.getPlayer()).Status) return; if (!ClansManager.getInstance().getClientManager().hasRank(event.getPlayer(), Rank.CMOD)) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java index d29c7a9c1..cff2d6e38 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java @@ -152,7 +152,7 @@ public class MeridianScepter extends LegendaryItem continue; } - if (IncognitoManager.Instance.Get(closest).Status) + if (ClansManager.getInstance().getIncognitoManager().Get(closest).Status) { continue; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index e87cd18d4..b663e7f1d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -143,8 +143,8 @@ public class Hub extends JavaPlugin implements IRelation IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler); new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager); - Chat chat = new Chat(this, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); - new MessageManager(this, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); + Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); + new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); new MemoryFix(this); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new CustomTagFix(this, packetHandler); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 985e8c5f3..da9d102aa 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -9,8 +9,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Random; -import mineplex.core.reward.RewardManager; -import mineplex.core.valentines.ValentinesGiftManager; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -74,8 +72,8 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.types.GadgetType; -import mineplex.core.giveaway.GiveawayManager; import mineplex.core.hologram.HologramManager; +import mineplex.core.incognito.events.IncognitoHidePlayerEvent; import mineplex.core.inventory.InventoryManager; import mineplex.core.message.PrivateMessageEvent; import mineplex.core.mount.MountManager; @@ -97,12 +95,14 @@ import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; +import mineplex.core.reward.RewardManager; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; import mineplex.core.treasure.TreasureManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.valentines.ValentinesGiftManager; import mineplex.hub.commands.DisguiseCommand; import mineplex.hub.commands.ForcefieldRadius; import mineplex.hub.commands.GadgetToggle; @@ -574,6 +574,15 @@ public class HubManager extends MiniClientPlugin event.setCancelled(true); } } + + @EventHandler + public void Incog(IncognitoHidePlayerEvent event) + { + if (!_clientManager.hasRank(event.getPlayer(), Rank.ADMIN)) + { + event.setCancelled(true); + } + } @EventHandler public void PlayerChat(AsyncPlayerChatEvent event) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index cdb02169a..33e1eb2d5 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -2,6 +2,12 @@ package mineplex.staffServer; import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_8_R3.CraftServer; +import org.bukkit.plugin.java.JavaPlugin; + +import com.mojang.authlib.GameProfile; + import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; @@ -9,6 +15,7 @@ import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; import mineplex.core.creature.Creature; import mineplex.core.donation.DonationManager; +import mineplex.core.incognito.IncognitoManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.memory.MemoryFix; import mineplex.core.monitor.LagMeter; @@ -26,12 +33,6 @@ import mineplex.staffServer.customerSupport.CustomerSupport; import mineplex.staffServer.salespackage.SalesPackageManager; import net.minecraft.server.v1_8_R3.MinecraftServer; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_8_R3.CraftServer; -import org.bukkit.plugin.java.JavaPlugin; - -import com.mojang.authlib.GameProfile; - public class StaffServer extends JavaPlugin { private String WEB_CONFIG = "webServer"; @@ -60,7 +61,7 @@ public class StaffServer extends JavaPlugin preferenceManager.GiveItem = false; Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); - new Chat(this, clientManager, preferenceManager, new AchievementManager(new StatsManager(this, clientManager), clientManager, donationManager), serverStatusManager.getCurrentServerName()); + new Chat(this, null, clientManager, preferenceManager, new AchievementManager(new StatsManager(this, clientManager), clientManager, donationManager), serverStatusManager.getCurrentServerName()); new MemoryFix(this); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 35d44e8cd..72b1024b1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -134,8 +134,8 @@ public class Arcade extends JavaPlugin StatsManager statsManager = new StatsManager(this, _clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager); FriendManager friendManager = new FriendManager(this, _clientManager, preferenceManager, portal); - Chat chat = new Chat(this, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); - new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); + Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); + new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); BlockRestore blockRestore = new BlockRestore(this); @@ -157,7 +157,7 @@ public class Arcade extends JavaPlugin //Arcade Manager PollManager pollManager = new PollManager(this, _clientManager, _donationManager); - _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish); + _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, incognito, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish); new MemoryFix(this); new CustomTagFix(this, packetHandler); 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 4aa33a1d3..6dd245b99 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -191,6 +191,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation private ResourcePackManager _resourcePackManager; private CustomDataManager _customDataManager; private Punish _punishmentManager; + + private IncognitoManager _incognitoManager; private TaskManager _taskManager; private PacketHandler _packetHandler; @@ -212,7 +214,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, - StatsManager statsManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat, + StatsManager statsManager, IncognitoManager incognitoManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat, Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler, CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, NpcManager npcManager, CustomDataManager customDataManager, Punish punish) @@ -224,6 +226,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation // Modules _blockRestore = new BlockRestore(plugin); + _incognitoManager = incognitoManager; + _blood = blood; _preferencesManager = preferences; @@ -616,7 +620,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { if (event.getNewState() && _game != null && _game.IsPlaying(event.getPlayer()) && _game.IsLive()) { - UtilPlayer.message(event.getPlayer(), F.main("Incognito", "You may not go incognito whilst in a game.")); + addSpectator(event.getPlayer(), true); event.setCancelled(true); return; } @@ -624,13 +628,28 @@ public class ArcadeManager extends MiniPlugin implements IRelation if (event.getNewState()) { UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName())); + + if (_game == null || _game.GetState() != GameState.Live) + { + _specList.add(event.getPlayer()); + } } else { UtilServer.broadcast(F.sys("Join", event.getPlayer().getName())); + + if (_game != null && isSpectator(event.getPlayer())) + { + if (_game.GetState() != GameState.Live) + { + _specList.remove(event.getPlayer()); + } + + event.show(false); + } } } - + @EventHandler public void MessageMOTD(ServerListPingEvent event) { @@ -695,7 +714,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { String name = event.getPlayer().getName(); - if (IncognitoManager.Instance.Get(event.getPlayer()).Status) + if (_incognitoManager.Get(event.getPlayer()).Status) { event.setJoinMessage(null); return; @@ -714,7 +733,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation @EventHandler public void MessageQuit(PlayerQuitEvent event) { - if (IncognitoManager.Instance.Get(event.getPlayer()).Status) + if (_incognitoManager.Get(event.getPlayer()).Status) { event.setQuitMessage(null); return; @@ -1123,7 +1142,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation public boolean IsObserver(Player player) { - if (IncognitoManager.Instance.Get(player).Status) + if (_incognitoManager.Get(player).Status) { _specList.add(player); }