Class IdUtilLocal
java.lang.Object
com.kamikazejam.kamicommon.util.id.IdUtilLocal
Identification of a CommandSender can be done in 4 different ways.
1. CommandSender sender (the sender itself) 2. UUID senderUuid (the uuid for the sender) 3. String senderId (the string id for the sender) 4. String senderName (the name for the sender) (5). Object senderObject (any of the four above)
This works very fine for players (instances of the Player class). The UUID would be the Mojang account uuid, the id would be the stringified UUID and the name would be the current player name (it's always unique even though it can be changed).
Then there is the server console command sender (instance of ConsoleCommandSender). This one does not natively have a proper uuid, id or name. I have however given it some. It's very often practical being able to treat the console as any player.
We provide the following features: - Lookup of all the data based on one of the unique parts. - Maintained sets for All, Online and Offline.
Players are registered automatically. Console is registered with imaginary and deterministic data values. Non-standard CommandSenders must be manually registered using the register method.
1. CommandSender sender (the sender itself) 2. UUID senderUuid (the uuid for the sender) 3. String senderId (the string id for the sender) 4. String senderName (the name for the sender) (5). Object senderObject (any of the four above)
This works very fine for players (instances of the Player class). The UUID would be the Mojang account uuid, the id would be the stringified UUID and the name would be the current player name (it's always unique even though it can be changed).
Then there is the server console command sender (instance of ConsoleCommandSender). This one does not natively have a proper uuid, id or name. I have however given it some. It's very often practical being able to treat the console as any player.
We provide the following features: - Lookup of all the data based on one of the unique parts. - Maintained sets for All, Online and Offline.
Players are registered automatically. Console is registered with imaginary and deterministic data values. Non-standard CommandSenders must be manually registered using the register method.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IdUtilLocal
get()
static ConsoleCommandSender
getAsConsole
(Object object) static Player
getAsPlayer
(Object object) static CommandSender
getAsSender
(Object object) static @NotNull File
static @NotNull File
static @NotNull ConsoleCommandSender
static IdData
getDatas()
static GameMode
getGameMode
(@Nullable Object object, GameMode def) static String
static @Nullable String
getIdFromSender
(CommandSender sender) static String
getIdFromUuid
(@NotNull UUID uuid) getIds
(@NotNull SenderPresence presence, @NotNull SenderType type) static com.google.gson.GsonBuilder
static @NotNull Set
<CommandSender> static SenderMap
static SenderMap
static Long
static String
getNameFromSender
(@NotNull CommandSender sender) static @NotNull String
getNameOrUUID
(@NotNull Object senderObject) getNames
(@NotNull SenderPresence presence, @NotNull SenderType type) static OfflinePlayer
getOfflinePlayer
(Object senderObject) static Player
static @NotNull @UnmodifiableView Map
<String, CommandSender> static @NotNull @UnmodifiableView Map
<CommandSender, String> static CommandSender
static UUID
static boolean
static boolean
isConsoleId
(String string) static boolean
isGameMode
(@Nullable Object object, GameMode gm, boolean def) static boolean
static boolean
static boolean
isPlayerId
(String string) static void
void
playerJoinLowest
(@NotNull PlayerJoinEvent event) void
playerKickMonitor
(@NotNull PlayerKickEvent event) void
playerLeaveMonitor
(@NotNull PlayerQuitEvent event) void
playerLoginLowest
(@NotNull PlayerLoginEvent event) static void
register
(CommandSender sender) void
run()
static void
static void
setup
(@NotNull KamiPlugin plugin) static void
unregister
(CommandSender sender) static void
static void
static void
static void
update
(String id, String name, long millis, SenderPresence presence) static void
update
(String id, String name, SenderPresence presence)
-
Field Details
-
IDPREFIX
- See Also:
-
CONSOLE_ID
- See Also:
-
CONSOLE_DATA
-
CACHEFILE_TYPE
-
gson
public static final com.google.gson.Gson gson
-
-
Constructor Details
-
IdUtilLocal
public IdUtilLocal()
-
-
Method Details
-
get
-
getDatas
-
getIdToData
-
getNameToData
-
getMaintainedIds
-
getIds
@NotNull public static @NotNull @UnmodifiableView Set<String> getIds(@NotNull @NotNull SenderPresence presence, @NotNull @NotNull SenderType type) -
getMaintainedNames
-
getNames
@NotNull public static @NotNull @UnmodifiableView Set<String> getNames(@NotNull @NotNull SenderPresence presence, @NotNull @NotNull SenderType type) -
getRegistryIdToSender
@Contract(value=" -> new", pure=true) @NotNull public static @NotNull @UnmodifiableView Map<String,CommandSender> getRegistryIdToSender() -
getRegistrySenderToId
@Contract(value=" -> new", pure=true) @NotNull public static @NotNull @UnmodifiableView Map<CommandSender,String> getRegistrySenderToId() -
register
-
unregister
-
getLocalSenders
-
update
-
update
-
update
@Contract("null, null, _ -> fail") public static void update(String id, String name, SenderPresence presence) -
update
-
update
@Contract("null, null, _, _ -> fail") public static void update(String id, String name, long millis, SenderPresence presence) -
setup
-
playerLoginLowest
-
playerJoinLowest
-
playerLeaveMonitor
-
playerKickMonitor
-
getData
-
getConsole
-
getPlayer
-
getSender
-
getUUID
-
getId
-
getIdFromSender
@Contract("null -> !null") @Nullable public static @Nullable String getIdFromSender(CommandSender sender) -
getIdFromUuid
-
getName
- Returns:
- the name of the senderObject, or null if the senderObject is null/has no known name.
- See Also:
-
getNameOrUUID
- Returns:
- the name of the senderObject, or the UUID if the senderObject is null/has no known name.
-
getOfflinePlayer
-
getNameFromSender
-
isOnline
-
getMillis
-
isPlayerId
-
isPlayer
-
isConsoleId
-
isConsole
-
getAsSender
-
getAsPlayer
-
getAsConsole
@Contract(value="null -> null", pure=true) public static ConsoleCommandSender getAsConsole(Object object) -
getGameMode
-
isGameMode
-
loadDatas
public static void loadDatas() -
getCacheFile
-
getCacheFileTemp
-
saveCachefileDatas
public static void saveCachefileDatas() -
getCachefileDatas
-
run
public void run() -
getLocalPlayerDatas
-
getKamiCommonGsonBuilder
public static com.google.gson.GsonBuilder getKamiCommonGsonBuilder()
-