Class Utils

java.lang.Object
com.booksaw.betterTeams.Utils

public class Utils extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    deserializeIntoInventory(@NotNull org.bukkit.inventory.Inventory inventory, @NotNull String jsons)
    Deserializes inventory data from a YAML string and populates the provided inventory.
    static @NotNull String
    dumpItem(org.bukkit.inventory.ItemStack itemStack)
    Converts a single ItemStack into a YAML string representation.
    static <T> @NotNull List<T>
    filterNonNull(Collection<T> collection)
     
    static @Nullable org.bukkit.OfflinePlayer
    Used to get an offline player, unlike the inbuilt method this will return null if the player is invalid.
    static boolean
    isComponentEmpty(net.kyori.adventure.text.Component component)
     
    static boolean
    isVanished(@NotNull org.bukkit.entity.Player player)
    Checks if a player is currently in vanished state by examining their metadata.
    static @NotNull String
    serializeInventory(@NotNull org.bukkit.inventory.Inventory inventory)
    Serializes the contents of an inventory into a YAML string representation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getOfflinePlayer

      @Nullable public static @Nullable org.bukkit.OfflinePlayer getOfflinePlayer(String name)
      Used to get an offline player, unlike the inbuilt method this will return null if the player is invalid.
      Parameters:
      name - The name of the player
      Returns:
      The offlinePlayer object
    • serializeInventory

      @NotNull public static @NotNull String serializeInventory(@NotNull @NotNull org.bukkit.inventory.Inventory inventory)
      Serializes the contents of an inventory into a YAML string representation. Non-null items are stored with their position index as the key.
      Parameters:
      inventory - The inventory to serialize
      Returns:
      A YAML string containing the serialized inventory data
      Throws:
      NullPointerException - if inventory is null
    • dumpItem

      @NotNull public static @NotNull String dumpItem(org.bukkit.inventory.ItemStack itemStack)
      Converts a single ItemStack into a YAML string representation.
      Parameters:
      itemStack - The ItemStack to serialize
      Returns:
      A YAML string containing the serialized item data
    • deserializeIntoInventory

      public static void deserializeIntoInventory(@NotNull @NotNull org.bukkit.inventory.Inventory inventory, @NotNull @NotNull String jsons)
      Deserializes inventory data from a YAML string and populates the provided inventory. Each item is placed at its original position in the inventory.
      Parameters:
      inventory - The inventory to populate with deserialized items
      jsons - The YAML string containing serialized inventory data
      Throws:
      NullPointerException - if inventory or jsons is null
    • isVanished

      public static boolean isVanished(@NotNull @NotNull org.bukkit.entity.Player player)
      Checks if a player is currently in vanished state by examining their metadata.
      Parameters:
      player - The player to check for vanish status
      Returns:
      true if the player is vanished, false otherwise
      Throws:
      NullPointerException - if player is null
    • filterNonNull

      @NotNull public static <T> @NotNull List<T> filterNonNull(Collection<T> collection)
    • isComponentEmpty

      public static boolean isComponentEmpty(net.kyori.adventure.text.Component component)