Timings for Visibility

This commit is contained in:
Cheese 2015-03-23 16:38:17 +11:00
parent 46dfb532fb
commit 5fded981d9
6 changed files with 56 additions and 7 deletions

View File

@ -13,15 +13,17 @@ public class TimeData
public long Started;
public long LastMarker;
public long Total;
public int Count = 0;
public void addTime()
{
Total += System.currentTimeMillis() - LastMarker;
LastMarker = System.currentTimeMillis();
Count++;
}
public void printInfo()
{
System.out.println("]==[TIME DATA]==[" + Title + " took " + Total + "ms in the last " + (System.currentTimeMillis() - Started) + "ms");
System.out.println("]==[TIME DATA]==[ " + Count + " " + Title + " took " + Total + "ms in the last " + (System.currentTimeMillis() - Started) + "ms");
}
}

View File

@ -94,6 +94,20 @@ public class TimingManager implements Listener
}
}
public static void endTotal(String title, boolean print)
{
if (!Debug)
return;
synchronized(_totalLock)
{
TimeData data = _totalList.remove(title);
if (data != null && print)
data.printInfo();
}
}
public static void printTotals()
{
if (!Debug)

View File

@ -4,6 +4,7 @@ import java.util.Iterator;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.recharge.Recharge;
import mineplex.core.timing.TimingManager;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
@ -43,9 +44,17 @@ public class VisibilityData
//it would still send the packet, even if the client thought it was already the state.
if (hide)
{
TimingManager.startTotal("Hide Player");
((CraftPlayer)player).hidePlayer(target, true, true);
TimingManager.stopTotal("Hide Player");
}
else
((CraftPlayer)player).showPlayer(target);
{
TimingManager.startTotal("Show Player");
player.showPlayer(target);
TimingManager.stopTotal("Show Player");
}
_lastState.put(target, hide);

View File

@ -5,6 +5,7 @@ import java.util.Iterator;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilServer;
import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -60,6 +61,8 @@ public class VisibilityManager extends MiniPlugin
if (event.getType() != UpdateType.TICK)
return;
TimingManager.startTotal("VisMan Update");
Iterator<Player> playerIter = _data.keySet().iterator();
while (playerIter.hasNext())
@ -74,6 +77,8 @@ public class VisibilityManager extends MiniPlugin
_data.get(player).attemptToProcessUpdate(player);
}
TimingManager.stopTotal("VisMan Update");
}
@EventHandler
@ -82,5 +87,16 @@ public class VisibilityManager extends MiniPlugin
_data.remove(event.getPlayer());
}
@EventHandler
public void updateDebug(UpdateEvent event)
{
if (event.getType() != UpdateType.MIN_01)
return;
System.out.println(" ");
TimingManager.endTotal("VisMan Update", true);
TimingManager.endTotal("Hide Player", true);
TimingManager.endTotal("Show Player", true);
System.out.println(" ");
}
}

View File

@ -62,15 +62,19 @@ public class HubVisibilityManager extends MiniPlugin
for (Player player : UtilServer.getPlayers())
{
boolean hideMe = Manager.getPreferences().Get(player).Invisibility || _hiddenPlayers.contains(player);
boolean hideMe = Manager.GetTutorial().InTutorial(player) ||
UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 ||
Manager.getPreferences().Get(player).Invisibility ||
_hiddenPlayers.contains(player);
for (Player other : UtilServer.getPlayers())
{
if (player.equals(other))
continue;
if (hideMe || !Manager.getPreferences().Get(other).ShowPlayers || UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 ||
Manager.GetTutorial().InTutorial(other) || Manager.GetTutorial().InTutorial(player))
if (hideMe ||
!Manager.getPreferences().Get(other).ShowPlayers ||
Manager.GetTutorial().InTutorial(other))
{
VisibilityManager.Instance.setVisibility(player, false, other);
}

View File

@ -1396,7 +1396,11 @@ public class SurvivalGames extends SoloGame
{
if (Recharge.Instance.use(player, "Hit by Border", 1000, false, false))
{
UtilAction.velocity(player, UtilAlg.getTrajectory2d(loc, GetSpectatorLocation()), 1.2, true, 0.4, 0, 10, true);
Entity bottom = player;
while (bottom.getVehicle() != null)
bottom = bottom.getVehicle();
UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(loc, GetSpectatorLocation()), 1.2, true, 0.4, 0, 10, true);
if (Manager.IsAlive(player))
{