Smarter player name to ID caching.
This commit is contained in:
parent
485805c63a
commit
b58e74aac3
|
|
@ -2320,6 +2320,10 @@ public class GriefPrevention extends JavaPlugin
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user