Package com.booksaw.betterTeams
Class Utils
java.lang.Object
com.booksaw.betterTeams.Utils
-
Method Summary
Modifier and TypeMethodDescriptionstatic voiddeserializeIntoInventory(@NotNull org.bukkit.inventory.Inventory inventory, @NotNull String jsons) Deserializes inventory data from a YAML string and populates the provided inventory.static @NotNull StringdumpItem(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.OfflinePlayergetOfflinePlayer(String name) Used to get an offline player, unlike the inbuilt method this will return null if the player is invalid.static booleanisComponentEmpty(net.kyori.adventure.text.Component component) static booleanisVanished(@NotNull org.bukkit.entity.Player player) Checks if a player is currently in vanished state by examining their metadata.static @NotNull StringserializeInventory(@NotNull org.bukkit.inventory.Inventory inventory) Serializes the contents of an inventory into a YAML string representation.
-
Method Details
-
getOfflinePlayer
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
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 itemsjsons- 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
-
isComponentEmpty
public static boolean isComponentEmpty(net.kyori.adventure.text.Component component)
-