Access rights is only sent when it changed.

This commit is contained in:
ProfMobius committed 2014-04-10 01:03:45 +02:00
1 parent 0591a38600
commit d899d164e9
2 files changed
+8 -2

No files matched your search

@@ -31,6 +31,7 @@ import mcp.mobius.opis.data.profilers.ProfilerPacket;
import mcp.mobius.opis.data.profilers.ProfilerTick;
import mcp.mobius.opis.gui.overlay.OverlayStatus;
import mcp.mobius.opis.network.OpisPacketHandler;
import mcp.mobius.opis.network.enums.AccessLevel;
import mcp.mobius.opis.network.enums.Message;
import mcp.mobius.opis.network.packets.server.NetDataCommand;
import mcp.mobius.opis.network.packets.server.NetDataList;
@@ -51,6 +52,8 @@ public enum OpisServerTickHandler implements ITickHandler {
public long timer1000 = System.nanoTime();
public long timer5000 = System.nanoTime();
public HashMap<Player, AccessLevel> cachedAccess = new HashMap<Player, AccessLevel>();
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
}
@@ -82,7 +85,10 @@ public enum OpisServerTickHandler implements ITickHandler {
OpisPacketHandler.sendPacketToAllSwing(NetDataValue.create(Message.VALUE_AMOUNT_ENTITIES, new SerialInt(EntityManager.INSTANCE.getAmountEntities())));
for (Player player : PlayerTracker.instance().playersSwing){
OpisPacketHandler.validateAndSend(NetDataValue.create(Message.STATUS_ACCESS_LEVEL, new SerialInt(PlayerTracker.instance().getPlayerAccessLevel(player).ordinal())), player);
if (!cachedAccess.containsKey(player) || cachedAccess.get(player) != PlayerTracker.instance().getPlayerAccessLevel(player)){
OpisPacketHandler.validateAndSend(NetDataValue.create(Message.STATUS_ACCESS_LEVEL, new SerialInt(PlayerTracker.instance().getPlayerAccessLevel(player).ordinal())), player);
cachedAccess.put(player, PlayerTracker.instance().getPlayerAccessLevel(player));
}
}
// Dimension data update.
+1 -1
View File
@@ -21,7 +21,7 @@ public class PlayerTracker implements IPlayerTracker{
public HashSet<Player> playersSwing = new HashSet<Player>(); //This is the list of players who have opened the UI
//public HashSet<Player> playersOpis = new HashSet<Player>(); //This is the list of players who have opened the UI or used the command line
public HashMap<String, Boolean> filteredAmount = new HashMap<String, Boolean>(); //Should the entity amount be filtered or not
public HashMap<String, Boolean> filteredAmount = new HashMap<String, Boolean>(); //Should the entity amount be filtered or not
public HashMap<Player, OverlayStatus> playerOverlayStatus = new HashMap<Player, OverlayStatus>();
public HashMap<Player, Integer> playerDimension = new HashMap<Player, Integer>();
public HashMap<Player, SelectedTab> playerTab = new HashMap<Player, SelectedTab>();