Package dev.majek.hexnicks.util
Class MiscUtils
java.lang.Object
dev.majek.hexnicks.util.MiscUtils
Handles general utility methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull Set<@NotNull net.kyori.adventure.text.format.NamedTextColor>
blockedColors
(@NotNull org.bukkit.command.CommandSender sender) Get a set of blocked colors for a command sender based on permissions.static @NotNull Set<@NotNull net.kyori.adventure.text.format.TextDecoration>
blockedDecorations
(@NotNull org.bukkit.command.CommandSender sender) Get a set of blocked decorations for a command sender based on permissions.static net.kyori.adventure.text.Component
configString
(String path, String def) Get a string from the config and parse it into a Component with MiniMessage.static net.kyori.adventure.text.Component
configStringPlaceholders
(String path, String def, org.bukkit.entity.Player player) Get a string from the config, apply placeholders from PlaceholderAPI, and parse it into a Component with MiniMessage.static boolean
Check whether the given nickname is blocked by config settings.static @Nullable Character
legacyCodeFromNamed
(@NotNull net.kyori.adventure.text.format.NamedTextColor color) Get the legacy color code from a named text color.static boolean
preventDuplicates
(@NotNull net.kyori.adventure.text.Component nickname, @NotNull org.bukkit.entity.Player player) Check if a nickname is taken and prevent it.static void
sendMessage
(@NotNull org.bukkit.command.CommandSender recipient, @NotNull net.kyori.adventure.text.Component message) Send a message to a user provided the message isn't empty.static @NotNull String
sendRequestAndGetResponse
(@NotNull HttpRequest request) Send a http request and get the response body.
-
Method Details
-
configStringPlaceholders
public static net.kyori.adventure.text.Component configStringPlaceholders(String path, String def, org.bukkit.entity.Player player) Get a string from the config, apply placeholders from PlaceholderAPI, and parse it into a Component with MiniMessage.- Parameters:
path
- The path to the string.def
- The default if the path returns null.player
- The player for placeholders.- Returns:
- Formatted component.
-
configString
Get a string from the config and parse it into a Component with MiniMessage.- Parameters:
path
- The path to the string.def
- The default if the path returns null.- Returns:
- Formatted component.
-
preventDuplicates
public static boolean preventDuplicates(@NotNull @NotNull net.kyori.adventure.text.Component nickname, @NotNull @NotNull org.bukkit.entity.Player player) Check if a nickname is taken and prevent it.- Parameters:
nickname
- the nickname to checkplayer
- the player trying to set the nickname- Returns:
- true if the nickname was a duplicate and the message was sent
-
isBlocked
Check whether the given nickname is blocked by config settings.- Parameters:
plainTextNick
- the provided nickname in plain text- Returns:
- whether the nickname is blocked.
-
legacyCodeFromNamed
@Nullable public static @Nullable Character legacyCodeFromNamed(@NotNull @NotNull net.kyori.adventure.text.format.NamedTextColor color) Get the legacy color code from a named text color.- Parameters:
color
- the named text color- Returns:
- legacy color code
-
blockedColors
@NotNull public static @NotNull Set<@NotNull net.kyori.adventure.text.format.NamedTextColor> blockedColors(@NotNull @NotNull org.bukkit.command.CommandSender sender) Get a set of blocked colors for a command sender based on permissions.- Parameters:
sender
- the sender- Returns:
- blocked colors
-
blockedDecorations
@NotNull public static @NotNull Set<@NotNull net.kyori.adventure.text.format.TextDecoration> blockedDecorations(@NotNull @NotNull org.bukkit.command.CommandSender sender) Get a set of blocked decorations for a command sender based on permissions.- Parameters:
sender
- the sender- Returns:
- blocked decorations
-
sendRequestAndGetResponse
@NotNull public static @NotNull String sendRequestAndGetResponse(@NotNull @NotNull HttpRequest request) Send a http request and get the response body.- Parameters:
request
- the request- Returns:
- the response body
-
sendMessage
public static void sendMessage(@NotNull @NotNull org.bukkit.command.CommandSender recipient, @NotNull @NotNull net.kyori.adventure.text.Component message) Send a message to a user provided the message isn't empty.- Parameters:
recipient
- the recipient of the messagemessage
- the message to send
-