Take a second crack at fixing invisibility across Arcade and Clans

This commit is contained in:
AlexTheCoder 2016-11-20 22:15:19 -05:00 committed by Shaun Bennett
parent e4a968759a
commit 0a458c150f
2 changed files with 33 additions and 12 deletions

View File

@ -41,7 +41,6 @@ import com.google.common.io.ByteStreams;
import mineplex.core.Managers;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.Achievement;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
@ -52,9 +51,11 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.creature.Creature;
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
import mineplex.core.disguise.DisguiseManager;
@ -146,6 +147,7 @@ import mineplex.minecraft.game.core.IRelation;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.Condition;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.minecraft.game.core.damage.DamageManager;
import mineplex.minecraft.game.core.fire.Fire;
@ -156,6 +158,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{
public static final int CLAIMABLE_RADIUS = 800;
public static final int WORLD_RADIUS = 1200;
private static final long PLAYER_VISIBILITY_REFRESH_RATE = 30000;
private static final int VIEW_DISTANCE_BLOCK_VALUE = 8;
private long _lastVisibilityRefresh = 0;
private static final TimeZone TIME_ZONE = TimeZone.getDefault();
private static ClansManager _instance;
@ -1400,6 +1405,27 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
}
}
}
@EventHandler
public void refreshVisibility(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
if (UtilTime.elapsed(_lastVisibilityRefresh, PLAYER_VISIBILITY_REFRESH_RATE))
{
_lastVisibilityRefresh = System.currentTimeMillis();
Bukkit.getOnlinePlayers().stream().filter(player -> !Managers.get(ConditionManager.class).HasCondition(player, ConditionType.INVISIBILITY) && !Managers.get(ConditionManager.class).HasCondition(player, ConditionType.CLOAK) && !UtilPlayer.isSpectator(player) && !Managers.get(IncognitoManager.class).Get(player).Hidden && !Managers.get(ObserverManager.class).isObserver(player)).forEach(player ->
{
Bukkit.getOnlinePlayers().stream().filter(viewer -> UtilMath.offset2d(viewer, player) <= (Bukkit.getViewDistance() * VIEW_DISTANCE_BLOCK_VALUE)).forEach(viewer ->
{
viewer.hidePlayer(player);
viewer.showPlayer(player);
});
});
}
}
public Pair<ClanInfo, Long> leftRecently(UUID uniqueId, long time)
{

View File

@ -72,19 +72,14 @@ public class GamePlayerManager implements Listener
{
return;
}
for (Player player : Manager.GetGame().GetPlayers(true))
Manager.GetGame().GetPlayers(true).stream().filter(player -> !Manager.GetCondition().HasCondition(player, ConditionType.INVISIBILITY) && !Manager.GetCondition().HasCondition(player, ConditionType.CLOAK) && Manager.GetGame().IsAlive(player) && !UtilPlayer.isSpectator(player)).forEach(player ->
{
if (!Manager.GetCondition().HasCondition(player, ConditionType.INVISIBILITY) && !Manager.GetCondition().HasCondition(player, ConditionType.CLOAK) && Manager.GetGame().IsAlive(player) && !UtilPlayer.isSpectator(player))
Bukkit.getOnlinePlayers().stream().filter(viewer -> UtilMath.offset2d(viewer, player) <= (Bukkit.getViewDistance() * VIEW_DISTANCE_BLOCK_VALUE)).forEach(viewer ->
{
for (Player viewer : Bukkit.getOnlinePlayers())
{
if (UtilMath.offset2d(viewer, player) <= (Bukkit.getViewDistance() * VIEW_DISTANCE_BLOCK_VALUE))
{
viewer.showPlayer(player);
}
}
}
}
viewer.hidePlayer(player);
viewer.showPlayer(player);
});
});
}
}