Class BukkitUtility

java.lang.Object
xyz.srnyx.annoyingapi.utility.BukkitUtility

public class BukkitUtility extends Object
Utility methods relating to Bukkit
  • Method Details

    • color

      @NotNull public static @NotNull String color(@Nullable @Nullable Object object)
      Translates & color codes to ChatColor
      Parameters:
      object - the object/string to translate
      Returns:
      the translated object/string
    • color

      @NotNull public static @NotNull List<String> color(@Nullable @Nullable Object object1, @Nullable @Nullable Object... objects)
      Translates & color codes to ChatColor for multiple strings
      Parameters:
      object1 - the first object/string to translate
      objects - the other objects/strings to translate
      Returns:
      the translated objects/strings
    • colorCollection

      @NotNull public static @NotNull List<String> colorCollection(@Nullable @Nullable Collection<?> objects)
      Translates & color codes to ChatColor for a Collection of strings
      Parameters:
      objects - the objects/strings to translate
      Returns:
      the translated objects/strings
    • stripUntranslatedColor

      @NotNull public static @NotNull String stripUntranslatedColor(@Nullable @Nullable String string)
      Strips untranslated ChatColors (using &) from a String
      Parameters:
      string - the String to strip
      Returns:
      the stripped String
    • hexColor

      @NotNull public static @NotNull String hexColor(@NotNull @NotNull String hex)
      Translates hex color codes to &x color codes
      Parameters:
      hex - the hex color code
      Returns:
      the translated hex color code
    • toggleScoreboardTag

      public static boolean toggleScoreboardTag(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull String scoreboardTag)
      Toggles a scoreboard tag on an Entity
      Parameters:
      entity - the Entity to toggle the scoreboard tag on
      scoreboardTag - the scoreboard tag to toggle
      Returns:
      true if the scoreboard tag was added, false if it was removed (or if it failed)
    • getPermissionValue

      @NotNull public static @NotNull Optional<Long> getPermissionValue(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String permission)
      Gets the value of a permission node from a Player

      Example: player has friends.max.5 permission, getPermissionValue(player, "friends.max.") would return 5
      Parameters:
      player - the Player to get the permission value from
      permission - the permission node to get the value of
      Returns:
      the value of the permission node, or empty if not found
    • getOfflinePlayer

      @NotNull public static @NotNull Optional<org.bukkit.OfflinePlayer> getOfflinePlayer(@NotNull @NotNull String name)
      Gets an OfflinePlayer from the specified name
      Returns a Player if they're online
      Parameters:
      name - the name of the player
      Returns:
      the OfflinePlayer, or empty if not found
    • getOnlinePlayerNames

      @NotNull public static @NotNull Set<String> getOnlinePlayerNames()
      Gets a Set of all online player names
      Returns:
      the Set of player names
    • getOfflinePlayerNames

      @NotNull public static @NotNull Set<String> getOfflinePlayerNames()
      Gets a Set of all offline player names
      Returns:
      the Set of player names
    • getAllPlayerNames

      @NotNull public static @NotNull Set<String> getAllPlayerNames()
      Gets a Set of all player names
      Returns:
      the Set of player names
    • getWorldNames

      @NotNull public static @NotNull Set<String> getWorldNames()
      Gets a Set of all world names
      Returns:
      the Set of world names