diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java index 91d873faa..afb328093 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java @@ -17,6 +17,7 @@ import com.google.common.base.Function; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -90,30 +91,45 @@ public class IncognitoManager extends MiniDbClientPlugin @EventHandler(priority = EventPriority.HIGHEST) public void Join(PlayerJoinEvent event) { + Player player = event.getPlayer(); + + if (Get(event.getPlayer()).Status && !_clientManager.hasRank(event.getPlayer(), Rank.HELPER)) + { + Get(event.getPlayer()).Status = false; + runAsync(() -> _repository.setStatus(_clientManager.getAccountId(player), false)); + return; + } + if (Get(event.getPlayer()).Status) { event.setJoinMessage(null); - informIncognito(event.getPlayer()); + informIncognito(player); } - IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(event.getPlayer())); + IncognitoHidePlayerEvent customEvent = null; - UtilServer.getPlayersCollection().forEach(player -> { - if (!customEvent.isCancelled() && Get(event.getPlayer()).Status && !_clientManager.hasRank(player, _clientManager.Get(event.getPlayer()).GetRank())) + if (Get(event.getPlayer()).Status) + { + customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(player)); + } + + for (Player other : UtilServer.getPlayers()) + { + if (customEvent != null && !customEvent.isCancelled() && !_clientManager.hasRank(other, _clientManager.Get(player).GetRank())) { - player.hidePlayer(event.getPlayer()); + other.hidePlayer(player); } - if (Get(player).Status) + if (Get(other).Status) { - IncognitoHidePlayerEvent customEvent2 = UtilServer.CallEvent(new IncognitoHidePlayerEvent(player)); + IncognitoHidePlayerEvent customEvent2 = UtilServer.CallEvent(new IncognitoHidePlayerEvent(other)); - if (!customEvent2.isCancelled() && !_clientManager.hasRank(event.getPlayer(), _clientManager.Get(player).GetRank())) + if (!customEvent2.isCancelled() && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank())) { - event.getPlayer().hidePlayer(player); + player.hidePlayer(other); } } - }); + } } @EventHandler(priority = EventPriority.HIGHEST)