Class Common
java.lang.Object
com.github.pinont.singularitylib.api.utils.Common
Utility class providing common operations and helper methods.
This class contains various static methods for working with items, players, materials, and text formatting.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckAirInSlot(PlayerInventorySlotType type, org.bukkit.entity.Player player) Checks if a specific inventory slot contains air for a player.static voidcheckBoolean(boolean expression, String falseMessage, Object... replacements) Checks if a boolean expression is true, logs a message if false.static @NotNull net.kyori.adventure.text.ComponentColorizes a string message using MiniMessage format without disabling italic.static @NotNull net.kyori.adventure.text.ComponentColorizes a string message using MiniMessage format.static org.bukkit.Material[]Gets all valid item materials, filtering out invalid or non-item materials.static StringGets the current API version.static org.bukkit.inventory.ItemStackCreates an ItemStack from a material name string.static org.bukkit.inventory.ItemStackgetItemInSlot(PlayerInventorySlotType type, org.bukkit.entity.Player player) Gets the ItemStack in a specific inventory slot for a player.static org.bukkit.entity.PlayergetNearestPlayer(org.bukkit.Location location, int radius) Gets the nearest player to a location within a specified radius.static Collection<? extends org.bukkit.entity.Player> Gets all online players.Gets the names of all online players.static StringIntegerToRomanNumeral(int input) Converts an integer to Roman numeral representation.static BooleanisAir(org.bukkit.inventory.ItemStack item) Checks if the given ItemStack is air or null.static BooleanisItemIsMaterial(org.bukkit.Material material) Checks if the given material is a valid item material.static BooleanisMainHandEmpty(org.bukkit.entity.Player player) Checks if a player's main hand is empty.static StringnormalizeStringName(String string) Normalizes a string name by converting underscores to spaces and capitalizing words.static StringresetStringColor(String text) Removes color codes from a string.static StringresetStringColor(net.kyori.adventure.text.Component component) Converts a Component to its MiniMessage string representation.static voidLogs an error message from a throwable.static long
-
Constructor Details
-
Common
public Common()Default constructor for Common utility class.
-
-
Method Details
-
getAPIVersion
-
colorize
@NotNull public static @NotNull net.kyori.adventure.text.Component colorize(@NotNull @NotNull String message, boolean noItalic) Colorizes a string message using MiniMessage format.- Parameters:
message- the message to colorizenoItalic- whether to disable italic formatting- Returns:
- the colorized Component
-
colorize
@NotNull public static @NotNull net.kyori.adventure.text.Component colorize(@NotNull @NotNull String message) Colorizes a string message using MiniMessage format without disabling italic.- Parameters:
message- the message to colorize- Returns:
- the colorized Component
-
getAllItemsMaterials
public static org.bukkit.Material[] getAllItemsMaterials()Gets all valid item materials, filtering out invalid or non-item materials.- Returns:
- array of valid item materials
-
isItemIsMaterial
Checks if the given material is a valid item material.- Parameters:
material- the material to check- Returns:
- true if the material is a valid item, false otherwise
-
isAir
Checks if the given ItemStack is air or null.- Parameters:
item- the ItemStack to check- Returns:
- true if the item is air or null, false otherwise
-
checkBoolean
Checks if a boolean expression is true, logs a message if false.- Parameters:
expression- the boolean expression to checkfalseMessage- the message to log if expression is falsereplacements- optional parameters for string formatting
-
getItem
Creates an ItemStack from a material name string.- Parameters:
itemName- the name of the material- Returns:
- the created ItemStack
- Throws:
IllegalArgumentException- if the material name is invalid
-
sneaky
Logs an error message from a throwable.- Parameters:
t- the throwable to log
-
getOnlinePlayers
Gets all online players.- Returns:
- collection of online players
-
getOnlinePlayersNames
-
normalizeStringName
-
isMainHandEmpty
Checks if a player's main hand is empty.- Parameters:
player- the player to check- Returns:
- true if the main hand is empty, false otherwise
-
IntegerToRomanNumeral
Converts an integer to Roman numeral representation.- Parameters:
input- the integer to convert (must be between 1 and 3999)- Returns:
- the Roman numeral string, or "Invalid Roman Number Value" if out of range
-
getNearestPlayer
public static org.bukkit.entity.Player getNearestPlayer(org.bukkit.Location location, int radius) Gets the nearest player to a location within a specified radius.- Parameters:
location- the location to search fromradius- the search radius- Returns:
- the nearest player, or null if none found
-
checkAirInSlot
Checks if a specific inventory slot contains air for a player.- Parameters:
type- the slot type to checkplayer- the player whose inventory to check- Returns:
- true if the slot contains air, false otherwise
-
getItemInSlot
public static org.bukkit.inventory.ItemStack getItemInSlot(PlayerInventorySlotType type, org.bukkit.entity.Player player) Gets the ItemStack in a specific inventory slot for a player.- Parameters:
type- the slot type to get the item fromplayer- the player whose inventory to check- Returns:
- the ItemStack in the specified slot, or air if slot is empty
-
resetStringColor
-
resetStringColor
Converts a Component to its MiniMessage string representation.- Parameters:
component- the component to convert- Returns:
- the MiniMessage string representation
-
toTicks
-