more timings for visman

This commit is contained in:
Cheese 2015-03-26 10:08:41 +11:00
parent 4a25265c7c
commit 6ab03e95ec
2 changed files with 36 additions and 16 deletions

View File

@ -16,10 +16,12 @@ public class VisibilityData
public void updatePlayer(Player player, Player target, boolean hide)
{
TimingManager.stopTotal("VisData updatePlayer");
if (_lastState.containsKey(target) && _lastState.get(target) == hide)
{
//Already this state, do nothing
//System.out.println("REPEAT " + player.getName() + " ~ " + target.getName());
TimingManager.stopTotal("VisData updatePlayer");
return;
}
@ -33,11 +35,15 @@ public class VisibilityData
//Store
_shouldHide.put(target, hide);
}
TimingManager.stopTotal("VisData updatePlayer");
}
//Process New
private boolean attemptToProcess(Player player, Player target, boolean hide)
{
TimingManager.startTotal("VisData attemptToProcess");
if (Recharge.Instance.use(player, "VIS " + target.getName(), 250, false, false))
{
//Use craftplayer because i recall jon added something where
@ -58,37 +64,47 @@ public class VisibilityData
_lastState.put(target, hide);
//System.out.println("TRUE " + player.getName() + " ~ " + target.getName());
TimingManager.stopTotal("VisData attemptToProcess");
return true;
}
//System.out.println("FALSE " + player.getName() + " ~ " + target.getName());
TimingManager.stopTotal("VisData attemptToProcess");
return false;
}
//Process Update
public void attemptToProcessUpdate(Player player)
{
for (Iterator<Player> targetIter = _shouldHide.keySet().iterator(); targetIter.hasNext();)
TimingManager.startTotal("VisData attemptToProcessUpdate shouldHide");
if (!_shouldHide.isEmpty())
{
Player target = targetIter.next();
boolean hide = _shouldHide.get(target);
if (!target.isOnline() || !target.isValid() || attemptToProcess(player, target, hide))
for (Iterator<Player> targetIter = _shouldHide.keySet().iterator(); targetIter.hasNext();)
{
targetIter.remove();
Player target = targetIter.next();
boolean hide = _shouldHide.get(target);
if (!target.isOnline() || !target.isValid() || attemptToProcess(player, target, hide))
{
targetIter.remove();
}
}
}
TimingManager.stopTotal("VisData attemptToProcessUpdate shouldHide");
for (Iterator<Player> targetIter = _lastState.keySet().iterator(); targetIter.hasNext();)
TimingManager.startTotal("VisData attemptToProcessUpdate lastState");
if (!_lastState.isEmpty())
{
Player target = targetIter.next();
if (!target.isOnline() || !target.isValid())
for (Iterator<Player> targetIter = _lastState.keySet().iterator(); targetIter.hasNext();)
{
targetIter.remove();
Player target = targetIter.next();
if (!target.isOnline() || !target.isValid())
{
targetIter.remove();
}
}
}
TimingManager.stopTotal("VisData attemptToProcessUpdate lastState");
}
}

View File

@ -98,8 +98,12 @@ public class VisibilityManager extends MiniPlugin
return;
System.out.println(" ");
TimingManager.endTotal("VisMan Update", true);
TimingManager.endTotal("VisMan SetVis", true);
TimingManager.endTotal("VisMan update", true);
TimingManager.endTotal("VisMan setVis", true);
TimingManager.endTotal("VisData attemptToProcess", true);
TimingManager.endTotal("VisData updatePlayer", true);
TimingManager.endTotal("VisData attemptToProcessUpdate shouldHide", true);
TimingManager.endTotal("VisData attemptToProcessUpdate lastState", true);
TimingManager.endTotal("Hide Player", true);
TimingManager.endTotal("Show Player", true);
System.out.println(" ");