Class IdUtilLocal

java.lang.Object
com.kamikazejam.kamicommon.util.id.IdUtilLocal
All Implemented Interfaces:
Runnable, Listener

public class IdUtilLocal extends Object implements Listener, Runnable
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.
  • Field Details

    • IDPREFIX

      public static final String IDPREFIX
      See Also:
    • CONSOLE_ID

      public static final String CONSOLE_ID
      See Also:
    • CONSOLE_DATA

      public static final IdData CONSOLE_DATA
    • CACHEFILE_TYPE

      public static final Type CACHEFILE_TYPE
    • gson

      public static final com.google.gson.Gson gson
  • Constructor Details

    • IdUtilLocal

      public IdUtilLocal()
  • Method Details

    • get

      public static IdUtilLocal get()
    • getDatas

      @Contract(pure=true) public static Set<IdData> getDatas()
    • getIdToData

      @Contract(pure=true) public static Map<String,IdData> getIdToData()
    • getNameToData

      @Contract(pure=true) public static Map<String,IdData> getNameToData()
    • getMaintainedIds

      @Contract(pure=true) public static SenderMap getMaintainedIds()
    • getIds

      @NotNull public static @NotNull @UnmodifiableView Set<String> getIds(@NotNull @NotNull SenderPresence presence, @NotNull @NotNull SenderType type)
    • getMaintainedNames

      @Contract(pure=true) public static SenderMap 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

      @Contract("null -> fail") public static void register(CommandSender sender)
    • unregister

      @Contract("null -> fail") public static void unregister(CommandSender sender)
    • getLocalSenders

      @NotNull public static @NotNull Set<CommandSender> getLocalSenders()
    • update

      @Contract("null, null -> fail") public static void update(String id, String name)
    • update

      @Contract("null, null, _ -> fail") public static void update(String id, String name, long millis)
    • update

      @Contract("null, null, _ -> fail") public static void update(String id, String name, SenderPresence presence)
    • update

      public static void update(@NotNull @NotNull IdData data)
    • update

      @Contract("null, null, _, _ -> fail") public static void update(String id, String name, long millis, SenderPresence presence)
    • setup

      public static void setup(@NotNull @NotNull KamiPlugin plugin)
    • playerLoginLowest

      public void playerLoginLowest(@NotNull @NotNull PlayerLoginEvent event)
    • playerJoinLowest

      public void playerJoinLowest(@NotNull @NotNull PlayerJoinEvent event)
    • playerLeaveMonitor

      public void playerLeaveMonitor(@NotNull @NotNull PlayerQuitEvent event)
    • playerKickMonitor

      public void playerKickMonitor(@NotNull @NotNull PlayerKickEvent event)
    • getData

      @Contract("null -> null") public static IdData getData(Object senderObject)
    • getConsole

      @NotNull public static @NotNull ConsoleCommandSender getConsole()
    • getPlayer

      @Contract("null -> null") public static Player getPlayer(Object senderObject)
    • getSender

      @Contract("null -> null") public static CommandSender getSender(Object senderObject)
    • getUUID

      @Contract("null -> null") public static UUID getUUID(Object senderObject)
    • getId

      @Contract("null -> null") public static String getId(Object senderObject)
    • getIdFromSender

      @Contract("null -> !null") @Nullable public static @Nullable String getIdFromSender(CommandSender sender)
    • getIdFromUuid

      @Contract(pure=true) public static String getIdFromUuid(@NotNull @NotNull UUID uuid)
    • getName

      @NotNull public static @NotNull Optional<String> getName(@Nullable @Nullable Object senderObject)
      Returns:
      the name of the senderObject, or null if the senderObject is null/has no known name.
      See Also:
    • getNameOrUUID

      @NotNull public static @NotNull String getNameOrUUID(@NotNull @NotNull Object senderObject)
      Returns:
      the name of the senderObject, or the UUID if the senderObject is null/has no known name.
    • getOfflinePlayer

      @Contract("null -> null") public static OfflinePlayer getOfflinePlayer(Object senderObject)
    • getNameFromSender

      public static String getNameFromSender(@NotNull @NotNull CommandSender sender)
    • isOnline

      @Contract("null -> false") public static boolean isOnline(Object senderObject)
    • getMillis

      @Contract("null -> null") public static Long getMillis(Object senderObject)
    • isPlayerId

      public static boolean isPlayerId(String string)
    • isPlayer

      @Contract("null -> false") public static boolean isPlayer(Object senderObject)
    • isConsoleId

      @Contract(value="null -> false", pure=true) public static boolean isConsoleId(String string)
    • isConsole

      @Contract("null -> false") public static boolean isConsole(Object senderObject)
    • getAsSender

      @Contract(value="null -> null", pure=true) public static CommandSender getAsSender(Object object)
    • getAsPlayer

      @Contract(value="null -> null", pure=true) public static Player getAsPlayer(Object object)
    • getAsConsole

      @Contract(value="null -> null", pure=true) public static ConsoleCommandSender getAsConsole(Object object)
    • getGameMode

      @Contract("null, _ -> param2") public static GameMode getGameMode(@Nullable @Nullable Object object, GameMode def)
    • isGameMode

      @Contract("null, _, _ -> param3") public static boolean isGameMode(@Nullable @Nullable Object object, GameMode gm, boolean def)
    • loadDatas

      public static void loadDatas()
    • getCacheFile

      @NotNull public static @NotNull File getCacheFile()
    • getCacheFileTemp

      @NotNull public static @NotNull File getCacheFileTemp()
    • saveCachefileDatas

      public static void saveCachefileDatas()
    • getCachefileDatas

      public static Set<IdData> getCachefileDatas()
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • getLocalPlayerDatas

      @NotNull public static @NotNull Set<@NotNull IdData> getLocalPlayerDatas()
    • getKamiCommonGsonBuilder

      public static com.google.gson.GsonBuilder getKamiCommonGsonBuilder()