Only cache offline playernames is requested
This commit is contained in:
parent
e96cbd344b
commit
4608ca9b95
|
|
@ -99,6 +99,8 @@ public class GriefPrevention extends JavaPlugin
|
|||
//log entry manager for GP's custom log files
|
||||
CustomLogger customLogger;
|
||||
|
||||
// hashmap to cache offline playernames
|
||||
public static HashMap<UUID, String> playerNameCache = new HashMap<>();
|
||||
//configuration variables, loaded/saved from a config.yml
|
||||
|
||||
//claim mode for each world
|
||||
|
|
@ -2669,7 +2671,7 @@ public class GriefPrevention extends JavaPlugin
|
|||
public enum IgnoreMode
|
||||
{None, StandardIgnore, AdminIgnore}
|
||||
|
||||
private String trustEntryToPlayerName(String entry)
|
||||
public String trustEntryToPlayerName(String entry)
|
||||
{
|
||||
if (entry.startsWith("[") || entry.equals("public"))
|
||||
{
|
||||
|
|
@ -2944,11 +2946,15 @@ public class GriefPrevention extends JavaPlugin
|
|||
//parameter validation
|
||||
if (playerID == null) return "somebody";
|
||||
|
||||
if (playerNameCache.containsKey(playerID))
|
||||
return playerNameCache.get(playerID);
|
||||
//check the cache
|
||||
OfflinePlayer player = GriefPrevention.instance.getServer().getOfflinePlayer(playerID);
|
||||
if (player.hasPlayedBefore() || player.isOnline())
|
||||
{
|
||||
return player.getName();
|
||||
String playerName = player.getName();
|
||||
playerNameCache.put(playerID, playerName);
|
||||
return playerName;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user