Package net.minecraftforge.common
Class UsernameCache
- java.lang.Object
-
- net.minecraftforge.common.UsernameCache
-
public final class UsernameCache extends java.lang.Object
Caches player's last known usernamesModders 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 Classes Modifier and Type Class Description private static class
UsernameCache.SaveThread
Used for saving theGson
representation of the cache to disk
-
Field Summary
Fields Modifier and Type Field Description private static com.google.gson.Gson
gson
private static org.apache.logging.log4j.Logger
LOGGER
private static java.util.Map<java.util.UUID,java.lang.String>
map
private static java.nio.file.Path
saveFile
private static org.apache.logging.log4j.Marker
USRCACHE
-
Constructor Summary
Constructors Modifier Constructor Description private
UsernameCache()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
containsUUID(java.util.UUID uuid)
Check if the cache contains the given player's usernamestatic java.lang.String
getLastKnownUsername(java.util.UUID uuid)
Get the player's last known usernamestatic java.util.Map<java.util.UUID,java.lang.String>
getMap()
Get an immutable copy of the cache's underlying mapprotected static void
load()
Load the cache from fileprotected static boolean
removeUsername(java.util.UUID uuid)
Remove a player's username from the cacheprotected static void
save()
Save the cache to fileprotected static void
setUsername(java.util.UUID uuid, java.lang.String username)
Set a player's current usernamee
-
-
-
Field Detail
-
map
private static java.util.Map<java.util.UUID,java.lang.String> map
-
saveFile
private static final java.nio.file.Path 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
-
-
Method Detail
-
setUsername
protected static void setUsername(java.util.UUID uuid, java.lang.String username)
Set a player's current usernamee- Parameters:
uuid
- the player'sUUID
username
- the player's username
-
removeUsername
protected static boolean removeUsername(java.util.UUID uuid)
Remove a player's username from the cache- Parameters:
uuid
- the player'sUUID
- Returns:
- if the cache contained the user
-
getLastKnownUsername
@Nullable public static java.lang.String getLastKnownUsername(java.util.UUID uuid)
Get the player's last known usernameMay be
null
- Parameters:
uuid
- the player'sUUID
- Returns:
- the player's last known username, or
null
if the cache doesn't have a record of the last username
-
containsUUID
public static boolean containsUUID(java.util.UUID uuid)
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
public static java.util.Map<java.util.UUID,java.lang.String> 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
-
-