Class Utils
java.lang.Object
tech.guilhermekaua.spigotboot.core.spigot.utils.Utils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Tfind(Collection<T> collection, Predicate<T> predicate) static org.bukkit.inventory.ItemStackgetItemFromConfig(org.bukkit.configuration.ConfigurationSection section) static intgetMaxValue(Set<Integer> set) static longmillisToTicks(long millis) static <T> voidmoveLastItemToFirst(List<T> list) static voidplaySound(PlatformScheduler scheduler, org.bukkit.entity.Player player, String name) Plays a sound for the player on the thread owning the player's region.static <T> voidremoveDuplicates(List<T> list) static <T> voidshuffleList(List<T> list) static voidsneakThrow(Runnable runnable) static <T> TsneakThrow(Supplier<T> supplier) static voidsync(PlatformScheduler scheduler, org.bukkit.entity.Entity entity, Runnable runnable) Runs a task on the thread owning the entity's region.static voidsyncLater(PlatformScheduler scheduler, org.bukkit.entity.Entity entity, Runnable runnable, long delayTicks) Runs a task on the thread owning the entity's region after a delay.static voidtryElsePrint(Runnable runnable)
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
getItemFromConfig
public static org.bukkit.inventory.ItemStack getItemFromConfig(org.bukkit.configuration.ConfigurationSection section) -
tryElsePrint
-
shuffleList
-
moveLastItemToFirst
-
getMaxValue
-
removeDuplicates
-
sneakThrow
-
sneakThrow
-
sync
public static void sync(PlatformScheduler scheduler, org.bukkit.entity.Entity entity, Runnable runnable) Runs a task on the thread owning the entity's region.- Parameters:
scheduler- the platform schedulerentity- the entity whose region owns the taskrunnable- the work to run
-
syncLater
public static void syncLater(PlatformScheduler scheduler, org.bukkit.entity.Entity entity, Runnable runnable, long delayTicks) Runs a task on the thread owning the entity's region after a delay.- Parameters:
scheduler- the platform schedulerentity- the entity whose region owns the taskrunnable- the work to rundelayTicks- the delay in server ticks
-
find
-
playSound
public static void playSound(PlatformScheduler scheduler, org.bukkit.entity.Player player, String name) Plays a sound for the player on the thread owning the player's region. The sound name is resolved viaSoundCompatso this works on both enum (≤ 1.21.2) and interface (≥ 1.21.3) server builds.- Parameters:
scheduler- the platform schedulerplayer- the target playername- the sound name (enum constant or namespaced key)
-
millisToTicks
public static long millisToTicks(long millis)
-