Skip to content

Utility Classes

Utility classes provide helper methods and predefined logic to simplify common tasks across the system.


When to use

  • You need helper functions for common tasks
  • You want to avoid duplicating logic
  • You need quick access to reusable functionality

Notes

  • These utilities are heavily used across the core
  • Always prefer them over custom implementations
  • If something feels like "this should already exist" → it probably does here

MessageConstants

Contains predefined messages used across the system.

  • Use instead of hardcoding common messages
  • Keeps wording consistent

Example:

  • "player not online"
  • "command not for console"

MessageUtil

Central class for everything message-related.

Handles:

  • color parsing (& → adventure)
  • emoji filtering / whitelist
  • spam & caps cleanup
  • lore splitting
  • formatting (lists, booleans, etc.)

Use this basically every time you handle user input or output.

Important:

  • Always use translateUserInput(...) for colorized player text
  • Don’t manually parse colors

NumberUtil

Helper for number formatting and calculations.

Provides:

  • formatted numbers (1.000, 10.5, etc.)
  • roman numbers (I, II, III, …)
  • rounding
  • K/D ratio

Use for:

  • UI display
  • stats
  • numbers in chat / lore

TimeUtil

Everything related to time and durations.

Provides:

  • timestamps → readable strings ("Heute, 14:32 Uhr")
  • duration formatting ("2 Stunden & 5 Minuten")
  • parsing time strings ("1h30m")
  • time calculations (next week, midnight, etc.)

Use for:

  • cooldowns
  • UI display
  • logs / timestamps

ValueComparator

Utility to sort maps by value.

Use when:

  • ranking players
  • leaderboards
  • sorting stats

Example:

  • highest value first
  • lowest value first

FireworkUtil

Spawns random fireworks.

Use for:

  • rewards
  • events
  • visual feedback

Translations

System for translating Bukkit objects into readable names.

Includes:

  • EntityTranslation → entities
  • ItemTranslation → items
  • EnchantmentTranslation → enchants
  • PotionTranslation → potions
  • DeathReasonTranslation → death causes

Use for:

  • UI
  • lore
  • chat messages

Example:

  • EntityTranslation.getColoredName(EntityType.GUARDIAN) → "\<aqua>Wächter\</aqua>"

Important:

  • Never hardcode names
  • Always use translations

ReflectionUtil

Allows access to private fields via reflection.

Use when:

  • you really need internal access

Important:

  • Avoid if possible
  • Can break easily
  • Use only if you know what you’re doing