Utility Helpers
Static utility classes in me.dzusill.core.util cover the most common plugin tasks.
ItemBuilder
Section titled βItemBuilderβFluent builder for ItemStacks with full MiniMessage support for names and lore.
ItemStack item = new ItemBuilder(Material.DIAMOND) .name("<aqua>Shiny Diamond") .lore("<gray>A very shiny diamond", "<dark_gray>Worth a lot") .glow() .amount(3) .build();| Method | Description |
|---|---|
name(String) |
MiniMessage display name |
name(Component) |
Adventure Component directly |
lore(String...) |
MiniMessage lore lines (varargs) |
lore(List<String>) |
MiniMessage lore lines (list) |
amount(int) |
Stack size |
glow() |
Enchantment glint without showing enchantment text |
flags(ItemFlag...) |
Add item flags |
ItemBuilder.head(String base64) |
Static β start a builder for a custom-textured PLAYER_HEAD |
skull(String base64) |
Apply a base64 texture to a PLAYER_HEAD item (use after new ItemBuilder(Material.PLAYER_HEAD)) |
pdc(key, type, value) |
Write a value to PersistentDataContainer |
build() |
Returns the finished ItemStack |
// Custom head with texture β one-liner via the static head() factoryItemStack plus = ItemBuilder.head("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly...") .name("<green>Add") .build();
// Equivalent explicit formItemStack head = new ItemBuilder(Material.PLAYER_HEAD) .skull("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly...") .name("<yellow>Custom Head") .build();
// In a menu, as a button icon:// button(11).icon(ItemBuilder.head(HEAD_PLUS).name("<green>Add").build()).onClick(...).add();
// PDC tag for identificationNamespacedKey key = new NamespacedKey(plugin, "item-type");ItemStack tagged = new ItemBuilder(Material.NETHER_STAR) .name("<gold>Special Item") .pdc(key, PersistentDataType.STRING, "special") .build();ColorUtils
Section titled βColorUtilsβSee Colors & MiniMessage for full documentation.
ColorUtils.parse("<gradient:aqua:blue>Text</gradient>")ColorUtils.parse(List.of("<gray>Line 1", "<gray>Line 2"))ColorUtils.legacy("&aLegacy color")ColorUtils.strip("<bold><red>Text") // β "Text"LocationUtils
Section titled βLocationUtilsβSerialize/deserialize Location objects for YAML storage.
Format: world,x,y,z,yaw,pitch
// SerializeString stored = LocationUtils.serialize(player.getLocation());// β "world,64.0,100.0,64.0,0.0,0.0"
// Deserialize (returns null if world not loaded or format invalid)Location loc = LocationUtils.deserialize(stored);if (loc != null) { player.teleport(loc);}TimeUtils
Section titled βTimeUtilsβFormat millisecond durations as human-readable strings (e.g. for cooldown messages).
TimeUtils.format(0) // "0s"TimeUtils.format(3500) // "3s"TimeUtils.format(65000) // "1m 5s"TimeUtils.format(3661000) // "1h 1m 1s"TimeUtils.format(90061000) // "1d 1h 1m 1s"Usage with CooldownManager:
long remaining = cooldown.remaining(player.getUniqueId());player.sendMessage(ColorUtils.parse( "<red>Wait <yellow>" + TimeUtils.format(remaining) + "<red> before using this again."));NumberUtils
Section titled βNumberUtilsβSafe parsing and compact abbreviation of numbers.
// Safe parsing β never throwsNumberUtils.parseInt("42") // Optional.of(42)NumberUtils.parseInt("abc") // Optional.empty()NumberUtils.parseDouble("3.14") // Optional.of(3.14)
// AbbreviationNumberUtils.abbreviate(1500) // "1.5K"NumberUtils.abbreviate(2300000) // "2.3M"NumberUtils.abbreviate(1000000000) // "1B"TextUtils
Section titled βTextUtilsβString utilities for command handling.
// Tab-completion filter β returns all candidates that start with token (case-insensitive)TextUtils.partialMatches("st", List.of("Steve", "Alex", "Stone"))// β ["Steve", "Stone"]
// Join args from an indexTextUtils.joinFrom(new String[]{"hello","world","foo"}, 1)// β "world foo"partialMatches is used internally by the command framework for all tab-completion; call it from custom ArgumentType.suggest() implementations.