Smarter player name to ID caching.
This commit is contained in:
parent
485805c63a
commit
b58e74aac3
|
|
@ -2319,7 +2319,11 @@ public class GriefPrevention extends JavaPlugin
|
|||
//limit memory footprint
|
||||
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
|
||||
|
|
|
|||
|
|
@ -587,10 +587,6 @@ class PlayerEventHandler implements Listener
|
|||
|
||||
//in case player has changed his name, on successful login, update UUID > Name mapping
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user