Package xyz.srnyx.annoyingapi.utility
Class BukkitUtility
java.lang.Object
xyz.srnyx.annoyingapi.utility.BukkitUtility
Utility methods relating to Bukkit
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull StringTranslates&color codes toChatColorTranslates&color codes toChatColorfor multiple stringscolorCollection(@Nullable Collection<?> objects) Gets aSetof all player namesstatic @NotNull Optional<org.bukkit.OfflinePlayer> getOfflinePlayer(@NotNull String name) Gets anOfflinePlayerfrom the specified name
Returns aPlayerif they're onlineGets aSetof all offline player namesGets aSetof all online player namesgetPermissionValue(@NotNull org.bukkit.entity.Player player, @NotNull String permission) Gets the value of a permission node from aPlayer
Example:playerhasfriends.max.5permission,getPermissionValue(player, "friends.max.")would return5Gets aSetof all world namesstatic @NotNull StringTranslates hex color codes to&xcolor codesstatic @NotNull StringstripUntranslatedColor(@Nullable String string) static booleantoggleScoreboardTag(@NotNull org.bukkit.entity.Entity entity, @NotNull String scoreboardTag) Toggles a scoreboard tag on anEntity
-
Method Details
-
color
Translates&color codes toChatColor- 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 toChatColorfor multiple strings- Parameters:
object1- the first object/string to translateobjects- the other objects/strings to translate- Returns:
- the translated objects/strings
-
colorCollection
@NotNull public static @NotNull List<String> colorCollection(@Nullable @Nullable Collection<?> objects) - Parameters:
objects- the objects/strings to translate- Returns:
- the translated objects/strings
-
stripUntranslatedColor
-
hexColor
Translates hex color codes to&xcolor 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 anEntity- Parameters:
entity- theEntityto toggle the scoreboard tag onscoreboardTag- 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 aPlayer
Example:playerhasfriends.max.5permission,getPermissionValue(player, "friends.max.")would return5- Parameters:
player- thePlayerto get the permission value frompermission- 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 anOfflinePlayerfrom the specified name
Returns aPlayerif they're online- Parameters:
name- the name of the player- Returns:
- the
OfflinePlayer, or empty if not found
-
getOnlinePlayerNames
Gets aSetof all online player names- Returns:
- the
Setof player names
-
getOfflinePlayerNames
Gets aSetof all offline player names- Returns:
- the
Setof player names
-
getAllPlayerNames
Gets aSetof all player names- Returns:
- the
Setof player names
-
getWorldNames
Gets aSetof all world names- Returns:
- the
Setof world names
-