Overview
TheCommon class is Foundation’s primary utility class, providing essential methods for:
- Messaging players and console
- Broadcasting messages
- Colorizing text
- Logging and error handling
- String manipulation
- Collection operations
- Command execution
- Plugin management
Messaging methods
tell
Sends colorized messages to a command sender.The player or console to send the message to
One or more messages to send (supports & color codes)
tellNoPrefix
Sends messages without the tell prefix.The command sender
Messages to send
tellTimed
Sends a message with cooldown to prevent spam.Minimum seconds between identical messages
The command sender
The message to send
Broadcasting methods
broadcast
Broadcasts a message to all online players and console.Messages to broadcast
broadcastWithPerm
Broadcasts to players with a specific permission.The permission required to see the message
The message to broadcast
Whether to also log to console
Color methods
colorize
Translates & color codes to Minecraft color codes. Supports HEX colors on 1.16+.The message to colorize
The colorized message
HEX colors are supported in formats:
&#RRGGBB, {#RRGGBB}, or #RRGGBBstripColors
Removes all color codes from a message.The message to strip
The message without color codes
Logging methods
log
Logs messages to console with color support.Messages to log
logTimed
Logs a message with cooldown to prevent console spam.Minimum seconds between identical messages
The message to log
warning
Logs a warning message.The warning message
error
Logs an error with stack trace.The exception
Additional context messages (can use %error variable)
String formatting
format
Formats a string with smart object conversion (players, locations, etc.).The format string (uses %s placeholders)
Arguments to format
plural
Creates plural forms of words based on count.The count
The singular word
limit
Limits string length and appends ”…” if cut.The text to limit
Maximum length
Collection methods
toArray
Converts a collection to an array.The collection to convert
join
Joins collection elements into a string.Elements to join
Separator (default: ”, “)
Command execution
dispatchCommand
Executes a command as console with placeholder support.Player to replace placeholder (can be null)
The command to execute (without /)
You can prefix commands with
@announce, @warn, @error, @info, @question, or @success to send formatted messages insteaddispatchCommandAsPlayer
Executes a command as if the player typed it.The player to execute the command
The command to execute
Visual elements
chatLine
Returns a decorative chat line.consoleLine
Returns a decorative console line.Regex methods
regExMatch
Tests if a regex pattern matches a message.The regular expression
The message to test
True if the pattern matches
compilePattern
Compiles a regex pattern with automatic configuration.The regular expression
The compiled pattern
Plugin management
doesPluginExist
Checks if a plugin is installed and enabled.The exact plugin name
True if the plugin exists and is enabled
Constants
The default Gson instance for JSON operations
Configuration
setTellPrefix
Sets the prefix for tell() messages.The prefix (supports & colors)
setLogPrefix
Sets the prefix for log() messages.The prefix (supports & colors)