Disable incognito mode for staff members that have been demoted whilst using it.
Also fixes a bug that caused IncognitoHidePlayerEvent fire even if the player logging in does not have incognito mode enabled.
This commit is contained in:
parent
3a8ab581dd
commit
eed3df720a
@ -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<IncognitoClient>
|
||||
@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)
|
||||
|
Loading…
Reference in New Issue
Block a user