Smarter player name to ID caching.

This commit is contained in:
ryanhamshire 2014-11-20 18:41:20 -08:00
parent 485805c63a
commit b58e74aac3
2 changed files with 5 additions and 5 deletions

View File

@ -2319,7 +2319,11 @@ public class GriefPrevention extends JavaPlugin
//limit memory footprint //limit memory footprint
if(GriefPrevention.uuidToNameMap.size() >= 500) GriefPrevention.uuidToNameMap.clear(); if(GriefPrevention.uuidToNameMap.size() >= 500) GriefPrevention.uuidToNameMap.clear();
GriefPrevention.uuidToNameMap.put(playerID, playerName); GriefPrevention.uuidToNameMap.put(playerID, playerName);
//always store the reverse mapping
GriefPrevention.instance.playerNameToIDMap.put(playerName, playerID);
GriefPrevention.instance.playerNameToIDMap.put(playerName.toLowerCase(), playerID);
} }
//string overload for above helper //string overload for above helper

View File

@ -587,10 +587,6 @@ class PlayerEventHandler implements Listener
//in case player has changed his name, on successful login, update UUID > Name mapping //in case player has changed his name, on successful login, update UUID > Name mapping
GriefPrevention.cacheUUIDNamePair(player.getUniqueId(), player.getName()); GriefPrevention.cacheUUIDNamePair(player.getUniqueId(), player.getName());
//also cache the reverse mapping
GriefPrevention.instance.playerNameToIDMap.put(player.getName(), playerID);
GriefPrevention.instance.playerNameToIDMap.put(player.getName().toLowerCase(), playerID);
} }
//when a player spawns, conditionally apply temporary pvp protection //when a player spawns, conditionally apply temporary pvp protection