Skip to content

Global Functions

Ceremony provides a set of globally available functions that you can call from anywhere in your scripts — no imports or namespace prefixes required. These cover the most common operations: sending messages, playing sounds, displaying titles, scheduling delays, and working with players.


Sends a chat message to a player using MiniMessage formatting.

ParameterTypeDescription
playerany (ServerPlayer)The target player to send the message to
textstringMessage text in MiniMessage format
// Simple colored message
msg(player, '<green>Hello!');
// Styled text with gradients
msg(player, '<gradient:gold:yellow>You earned 50 coins!</gradient>');
// Bold and italic
msg(player, '<bold><red>WARNING:</red></bold> <gray>The dungeon is closing in 60 seconds.');
// Hover and click events
msg(player, '<click:run_command:/spawn><hover:show_text:"Click to teleport"><underlined><aqua>Click here to return to spawn</aqua></underlined></hover></click>');

Sends an action bar message (the text that appears above the hotbar) using MiniMessage formatting.

ParameterTypeDescription
playerany (ServerPlayer)The target player
textstringAction bar text in MiniMessage format
// XP gain notification
actionbar(player, '<gold>+50 XP');
// Combat status
actionbar(player, '<red>HP: <white>14/20 <gray>| <green>Shield: <white>Active');
// Zone entry
actionbar(player, '<gradient:green:dark_green>Entering Viridian Forest</gradient>');

title(player, main, sub?, fadeIn?, stay?, fadeOut?)

Section titled “title(player, main, sub?, fadeIn?, stay?, fadeOut?)”

Sends a title and optional subtitle to a player. Timing values are in ticks (20 ticks = 1 second).

ParameterTypeDefaultDescription
playerany (ServerPlayer)The target player
mainstringTitle text in MiniMessage format
substring''Subtitle text in MiniMessage format
fadeInnumber10Fade-in duration in ticks
staynumber70Stay duration in ticks
fadeOutnumber20Fade-out duration in ticks
// Simple title
title(player, '<gold>Victory!');
// Title with subtitle
title(player, '<gold>Victory', '<gray>Well played');
// Title with custom timing (fast appear, long stay, slow fade)
title(player, '<gold>Victory', '<gray>Well played', 10, 70, 20);
// Countdown effect
async function showCountdown(player) {
title(player, '<red>3', '', 0, 20, 5);
await delay(20);
title(player, '<yellow>2', '', 0, 20, 5);
await delay(20);
title(player, '<green>1', '', 0, 20, 5);
await delay(20);
title(player, '<bold><green>GO!', '<gray>Good luck!', 0, 40, 20);
}
// Boss encounter
title(player, '<dark_red><bold>BOSS FIGHT', '<red>Defeat the Ender Dragon', 20, 60, 10);

Broadcasts a MiniMessage-formatted chat message to all online players.

ParameterTypeDescription
textstringMessage text in MiniMessage format
// Server announcement
broadcast('<yellow>Server restarting in 5 minutes');
// Event announcement
broadcast('<gold><bold>EVENT:</bold> <yellow>A Legendary Pokemon has appeared in the Wild Area!');
// Player achievement
broadcast(`<gray>[<gold>Achievement<gray>] <white>${playerName} <gray>caught their first Shiny Pokemon!`);

Parses a MiniMessage string into a vanilla Minecraft Component object. This is useful when you need a Component for Java API calls rather than sending a message directly.

ParameterTypeDescription
miniMessagestringText in MiniMessage format

Returns: Minecraft Component

// Create a Component for use with Java APIs
const comp = text('<red>Error');
// Use with entity custom names
const nameTag = text('<gold><bold>Quest NPC');
// Use with inventory item display names
const itemName = text('<light_purple>Legendary Sword');

Plays a sound effect for a specific player. Sound names use Minecraft’s dot-notation identifiers.

ParameterTypeDefaultDescription
playerany (ServerPlayer)The target player
soundNamestringMinecraft sound identifier (dot notation)
volumenumber1.0Volume level (0.0 to 1.0+)
pitchnumber1.0Pitch multiplier (0.5 = low, 1.0 = normal, 2.0 = high)
// Level up fanfare
sound(player, 'entity.player.levelup', 0.5, 1.2);
// Error buzzer
sound(player, 'block.note_block.bass', 1.0, 0.5);
// Success chime
sound(player, 'block.note_block.chime', 0.8, 1.5);
// Ambient cave sound
sound(player, 'ambient.cave', 0.3, 1.0);
// Ender dragon roar for boss encounters
sound(player, 'entity.ender_dragon.growl', 1.0, 0.8);
// Chest opening for reward reveals
sound(player, 'block.chest.open', 1.0, 1.0);

Returns a Promise that resolves after a specified number of game ticks. Use with await inside async functions to pause execution without blocking the server.

ParameterTypeDescription
ticksnumberNumber of game ticks to wait (20 ticks = 1 second)

Returns: Promise<void>

// Wait 1 second
await delay(20);
// Wait 5 seconds
await delay(100);
// Practical example: reward ceremony with delays
async function rewardCeremony(player) {
msg(player, '<yellow>Opening reward chest...');
sound(player, 'block.chest.open', 1.0, 1.0);
await delay(30); // 1.5 seconds
msg(player, '<gold>You received: <white>Diamond x5');
sound(player, 'entity.item.pickup', 1.0, 1.0);
await delay(20); // 1 second
msg(player, '<gold>You received: <light_purple>Rare Candy x3');
sound(player, 'entity.item.pickup', 1.0, 1.2);
await delay(20);
title(player, '<gold>Rewards Claimed!', '<gray>Check your inventory', 10, 40, 20);
sound(player, 'entity.player.levelup', 0.8, 1.0);
}

Schedules a callback function to run after a specified number of milliseconds. Unlike delay(), this is wall-clock time, not tick-based.

ParameterTypeDefaultDescription
callbackfunctionFunction to execute after the delay
delayMsnumber0Delay in milliseconds before executing the callback
// Run after 3 seconds (wall-clock time)
setTimeout(() => {
msg(player, 'Delayed!');
}, 3000);
// Run on next tick cycle (no delay)
setTimeout(() => {
broadcast('<green>Server initialized!');
});
// Chain multiple timeouts for a timed sequence
setTimeout(() => msg(player, '<yellow>3...'), 0);
setTimeout(() => msg(player, '<yellow>2...'), 1000);
setTimeout(() => msg(player, '<yellow>1...'), 2000);
setTimeout(() => msg(player, '<green>Go!'), 3000);

Wraps a vanilla ServerPlayer object into Ceremony’s rich Player interface, which provides convenient methods for messaging, teleportation, effects, and more.

ParameterTypeDescription
playerany (ServerPlayer)A vanilla Minecraft ServerPlayer instance

Returns: Player interface

// Wrap a player from an event
Events.on('PlayerJoinEvent', (event) => {
const p = wrapPlayer(event.getEntity());
p.sendMessage('<green>Welcome back!');
});
// Access player properties
const p = wrapPlayer(serverPlayer);
const name = p.getName();
const uuid = p.getUUID();
const pos = p.getPosition(); // { x, y, z }
const health = p.getHealth();
// Player actions
p.sendMessage('<red>Watch out!');
p.playSound('entity.player.levelup', 1.0, 1.0);
p.sendTitle('<gold>Level Up!', '<gray>You are now level 10');
p.teleport(100, 65, 200);
p.heal(20);

Retrieves the persistent PlayerData key-value storage for a specific player. Data persists across sessions and server restarts.

ParameterTypeDescription
playerany (ServerPlayer)The target player

Returns: PlayerData interface

The PlayerData interface provides:

MethodDescription
get(key)Get a stored value by key. Returns string or null
set(key, value)Store a key-value pair. Both key and value are strings
has(key)Check if a key exists. Returns boolean
remove(key)Remove a stored key-value pair
keys()Get all stored keys. Returns string[]
// Store and retrieve player stats
const data = getPlayerData(player);
data.set('score', '100');
data.set('kills', '25');
data.set('last_login', Date.now().toString());
const score = parseInt(data.get('score') || '0');
msg(player, `<yellow>Your score: <white>${score}`);
// Track daily login rewards
const data = getPlayerData(player);
const lastClaim = parseInt(data.get('last_daily_claim') || '0');
const now = Date.now();
const oneDayMs = 24 * 60 * 60 * 1000;
if (now - lastClaim >= oneDayMs) {
data.set('last_daily_claim', now.toString());
const streak = parseInt(data.get('daily_streak') || '0') + 1;
data.set('daily_streak', streak.toString());
msg(player, `<gold>Daily reward claimed! <gray>Streak: <white>${streak}`);
} else {
msg(player, '<red>You already claimed today\'s reward.');
}

FunctionPurposeReturns
msg(player, text)Send chat messagevoid
actionbar(player, text)Send action bar textvoid
title(player, main, sub?, fadeIn?, stay?, fadeOut?)Show title/subtitlevoid
broadcast(text)Message all playersvoid
text(miniMessage)Parse to ComponentComponent
sound(player, soundName, volume?, pitch?)Play sound effectvoid
delay(ticks)Async tick delayPromise<void>
setTimeout(callback, delayMs?)Schedule callbackvoid
wrapPlayer(player)Wrap ServerPlayerPlayer
getPlayerData(player)Get persistent storagePlayerData