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