Class Utils

java.lang.Object
me.lokka30.levelledmobs.util.Utils

public final class Utils extends Object
Holds common utilities
Since:
2.5.0
  • Field Details

    • logger

      @NotNull public static final @NotNull MicroLogger logger
    • oneToNine

      @NotNull public static final @NotNull List<String> oneToNine
  • Method Details

    • round

      public static double round(double value)
      Rounds value to 2 decimal points.
      Parameters:
      value - value to round
      Returns:
      rounded value
    • round

      public static double round(double value, int digits)
    • replaceEx

      @NotNull public static @NotNull String replaceEx(@NotNull @NotNull String message, @NotNull @NotNull String replaceWhat, @NotNull @NotNull String replaceTo)
      Replaces content of a message with case insensitivity.
      Parameters:
      message - message that should be edited
      replaceWhat - the text to be replaced
      replaceTo - the text to replace with
      Returns:
      modified message
    • isInteger

      public static boolean isInteger(@Nullable @Nullable String str)
      Check if str is an integer
      Parameters:
      str - str to check
      Returns:
      if str is an integer (e.g. "1234" = true, "hello" = false)
    • isDouble

      public static boolean isDouble(@Nullable @Nullable String str)
    • isNullOrEmpty

      public static boolean isNullOrEmpty(@Nullable @Nullable String str)
    • replaceAllInList

      @NotNull public static @NotNull List<String> replaceAllInList(@NotNull @NotNull List<String> oldList, @NotNull @NotNull String replaceWhat, @NotNull @NotNull String replaceTo)
    • colorizeAllInList

      @NotNull public static @NotNull List<String> colorizeAllInList(@NotNull @NotNull List<String> oldList)
    • debugLog

      public static void debugLog(@NotNull @NotNull LevelledMobs instance, @NotNull @NotNull DebugType debugType, @NotNull @NotNull String msg)
      Sends a debug message to console if enabled in settings
      Parameters:
      instance - LevelledMobs class
      debugType - Reference to whereabouts the debug log is called so that it can be traced back easily
      msg - Message to help de-bugging
    • capitalize

      @NotNull public static @NotNull String capitalize(@NotNull @NotNull String str)
      Puts the string into lowercase and makes every character that starts a word a capital letter.

      e.g. from: wiTheR sKeLeTOn to: Wither Skeleton

      Parameters:
      str - string to capitalize
      Returns:
      a string with each word capitalized
    • isLivingEntityInModalList

      public static boolean isLivingEntityInModalList(@NotNull @NotNull CachedModalList<String> list, LivingEntityWrapper lmEntity, boolean checkBabyMobs)
    • isIntegerInModalList

      public static boolean isIntegerInModalList(@NotNull @NotNull CachedModalList<MinAndMax> list, int checkNum)
    • isBiomeInModalList

      public static boolean isBiomeInModalList(@NotNull @NotNull CachedModalList<org.bukkit.block.Biome> list, org.bukkit.block.Biome biome, RulesManager rulesManager)
    • isDamageCauseInModalList

      public static boolean isDamageCauseInModalList(@NotNull @NotNull CachedModalList<DeathCause> list, DeathCause cause)
    • getMillisecondsFromInstant

      public static long getMillisecondsFromInstant(Instant instant)
    • getPortalOrWorldSpawn

      @NotNull public static @NotNull PlayerNetherOrWorldSpawnResult getPortalOrWorldSpawn(@NotNull @NotNull LevelledMobs main, @NotNull @NotNull org.bukkit.entity.Player player)
    • getChunkKey

      public static long getChunkKey(@NotNull @NotNull org.bukkit.Chunk chunk)
    • displayChunkLocation

      public static String displayChunkLocation(@NotNull @NotNull org.bukkit.Location location)
    • getPair

      @Contract(value="_, _ -> new", pure=true) public static <T, U> @NotNull Map.Entry<T,U> getPair(T first, U second)
    • adaptVanillaSpawnReason

      public static LevelledMobSpawnReason adaptVanillaSpawnReason(@NotNull org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason)
    • matchWildcardString

      public static boolean matchWildcardString(@NotNull @NotNull String input, @NotNull @NotNull String match)
    • removeColorCodes

      public static String removeColorCodes(@NotNull @NotNull String input)
    • showLocation

      @NotNull public static @NotNull String showLocation(@NotNull @NotNull org.bukkit.Location location)
    • checkIfMobHashChanged

      public static boolean checkIfMobHashChanged(@NotNull @NotNull LivingEntityWrapper lmEntity)