Package net.neoforged.neoforge.common
Class UsernameCache
java.lang.Object
net.neoforged.neoforge.common.UsernameCache
Caches player's last known usernames
Modders should use getLastKnownUsername(UUID) to determine a players
last known username.
For convenience, getMap() is provided to get an immutable copy of
the caches underlying map.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classUsed for saving theGsonrepresentation of the cache to disk -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsUUID(UUID uuid) Check if the cache contains the given player's usernamestatic @Nullable StringgetLastKnownUsername(UUID uuid) Get the player's last known usernamegetMap()Get an immutable copy of the cache's underlying mapprotected static voidload()Load the cache from fileprotected static booleanremoveUsername(UUID uuid) Remove a player's username from the cacheprotected static voidsave()Save the cache to fileprotected static voidsetUsername(UUID uuid, String username) Set a player's current usernamee
-
Field Details
-
map
-
saveFile
-
gson
private static final com.google.gson.Gson gson -
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
USRCACHE
private static final org.apache.logging.log4j.Marker USRCACHE
-
-
Constructor Details
-
UsernameCache
private UsernameCache()
-
-
Method Details
-
setUsername
Set a player's current usernamee- Parameters:
uuid- the player'sUUIDusername- the player's username
-
removeUsername
Remove a player's username from the cache- Parameters:
uuid- the player'sUUID- Returns:
- if the cache contained the user
-
getLastKnownUsername
Get the player's last known usernameMay be
null- Parameters:
uuid- the player'sUUID- Returns:
- the player's last known username, or
nullif the cache doesn't have a record of the last username
-
containsUUID
Check if the cache contains the given player's username- Parameters:
uuid- the player'sUUID- Returns:
- if the cache contains a username for the given player
-
getMap
Get an immutable copy of the cache's underlying map- Returns:
- the map
-
save
protected static void save()Save the cache to file -
load
protected static void load()Load the cache from file
-