Add these commands to the Minecraft Battle Royale plugin:
/br start <time>
Starts the Battle Royale event.
Randomly teleport all players inside the WorldBorder.
After teleporting, freeze all players so they cannot move.
Start a countdown timer using the <time> value.
Show countdown animations/titles and play sounds during the countdown.
When the timer ends, unfreeze all players so they can move and fight.
During the event:
If a player dies after the event starts:
Set them to Spectator mode.
If a dead player rejoins:
Keep them in Spectator mode.
/br end
Ends the Battle Royale event.
Set all players back to Survival mode.
Unfreeze everyone.
Stop all event systems/timers.
Reset the event cleanly.
Additional requirements:
Only OPs can use all /br commands.
Use clean and optimized Paper/Spigot API code.
Support multiplayer correctly.
Include sounds, titles, and smooth countdown effects.
Make the system expandable for future Battle Royale features.
Here’s the full plugin structure I’ll build:
BattleRoyalePlugin.java— main class, wires everything togethermanager/GameManager.java— core game state, freeze logic, spectator trackingmanager/CountdownManager.java— animated countdown with titles/soundslistener/PlayerListener.java— death → spectator, rejoin → spectatorcommand/BRCommand.java—/br start <time>and/br endplugin.yml+config.yml
Here’s a summary of what was built:
Files created (7):
File | Purpose |
|---|---|
BattleRoyalePlugin.java | Main class — wires managers, registers events/commands |
model/GameState.java | IDLE / COUNTDOWN / RUNNING enum |
manager/GameManager.java | Teleport, freeze/unfreeze, death→spectator, rejoin restore, end/reset |
manager/CountdownManager.java | Per-second BukkitTask with titles, action bar, progress bar, sounds |
listener/PlayerListener.java | Death event, join event, movement cancel for frozen players |
command/BRCommand.java | /br start <time> and /br end with tab completion |
plugin.yml | Command registration |
Key design decisions:
Freeze uses Slowness 255 + Jump Boost 250 + Blindness via potions, plus
PlayerMoveEventcancellation for a bulletproof lockCountdown ticks play louder/faster sounds in the final 5 seconds; sounds every 5s for long countdowns to avoid spam
Dead players are tracked by UUID so rejoining mid-game correctly restores spectator mode
/br endcancels the countdown task, restores all players to Survival, and clears all state cleanlyExpandable: add new
GameStatevalues, new commands, or new managers without touching existing logic
ommand: /br announce <color>
Requirements:
Only OPs can use the command.
Show an advancement-style toast to all online players.
Title: Battle Royale Event Description: The event is starting soon!
Use a Nether Star icon.
Validate colors: red, gold, green, blue, purple.
Send an error for invalid colors.
Use clean, optimized code with separate classes and include plugin.yml.
Plan:
Create
util/ColorUtil.java— MiniMessage helperCreate
util/ToastUtil.java— advancement toast senderAdd
announcesubcommand toBRCommand.java(new case + handler + tab completion)Update
plugin.ymlusage line
Now patch BRCommand.java to add the announce subcommand:
Now create the two utility classes:
Here’s what was added:
New files:
File | Purpose |
|---|---|
util/ColorUtil.java | MiniMessage wrapper — colorize(String) → Component |
util/ToastUtil.java | Registers a temporary advancement, grants it to show the toast, then revokes + unregisters it 1 tick later leaving zero trace |
BRCommand.java changes:
Added
handleAnnounce()— validates the color, mapspurple→<light_purple>(MiniMessage has no<purple>), builds title/description components, fires the toastVALID_COLORSset +COLOR_TAGmap for clean validation and mappingTab completion now suggests all 5 colors for
/br announce <TAB>sendUsage()lists the new command
How the toast works:
The advancement JSON is built with "trigger":"minecraft:impossible" so it can never be earned naturally. It’s registered via Bukkit.getUnsafe().loadAdvancement(), immediately granted to all players (which fires the toast client-side), then revoked and unregistered one tick later — players never see it in their advancement screen.
Fix the plugin
Let me look at the current state of the files before diagnosing anything.
Found all the issues. Here’s what’s broken:
build.gradle— Usesspigot-apibut the code uses Paper-only APIs (sendActionBar,sendTitlewith Adventure, MiniMessage,Component). Must switch topaper-api. Also missingadventure-text-serializer-gsondependency (used inToastUtil).plugin.yml—api-version: 1.13is too old; Paper/Adventure APIs require at minimum1.20.GameManager.java—PotionEffectType.JUMP_BOOSTwas renamed toJUMPin newer Paper/Spigot versions. Must use XSeries.CountdownManager.java—player.sendActionBar(String)is deprecated/removed on Paper; must useplayer.sendActionBar(Component).ToastUtil.java—iconJSON format changed in 1.20.5+;{"id":"minecraft:nether_star"}needs"count":1and the advancement JSON needs"parent"or"requirements"field to be valid on newer Paper. AlsoBukkit.getUnsafe().loadAdvancementis deprecated — must useBukkit.getUnsafe().loadAdvancement(key, json)which still works but the JSON structure must be correct.GameManager.java—player.sendTitle(String, String, int, int, int)is deprecated on Paper; should use AdventureComponenttitles.
Now fix GameManager.java — replace deprecated sendTitle(String...) with Adventure Component titles, and fix JUMP_BOOST → XSeries-safe potion handling:
Now fix CountdownManager.java — replace deprecated sendActionBar(String) and sendTitle(String...) with Adventure equivalents:The file has special characters that didn’t survive the round-trip. Let me rewrite CountdownManager.java completely since the content is garbled:
Now fix GameManager.java — remove the unused ChatColor import since we switched to Adventure titles:
Good — GameManager.java imports look correct. Now check the ChatColor usage still in GameManager (the broadcastMessage calls):
ChatColor is still used in GameManager but the import was removed. Need to add it back:
Now fix ToastUtil.java — the icon JSON format changed in 1.20.5+ (needs "components" wrapper) and the advancement JSON needs a "requirements" field to be valid:
All fixes applied. Here’s a summary of every issue that was fixed:
# | File | Problem | Fix |
|---|---|---|---|
1 | build.gradle | Used spigot-api — missing Paper-only APIs ( Component, Title, sendActionBar, MiniMessage) | Switched to paper-api:1.20.4 with Paper Maven repo |
2 | plugin.yml | api-version: 1.13 — too old, Paper rejects Adventure API usage | Updated to api-version: '1.20' |
3 | GameManager.java | PotionEffectType.JUMP_BOOST — renamed to JUMP in 1.20.5, causes NoSuchFieldError | Replaced with XPotion.matchXPotion("JUMP") for cross-version safety |
4 | GameManager.java | player.sendTitle(String, String, int, int, int) — deprecated/removed on Paper | Replaced with player.showTitle(Title.title(Component...)) |
5 | CountdownManager.java | player.sendTitle(String...) + player.sendActionBar(String) — both removed on Paper | Full rewrite to Adventure Title.title(Component...) + sendActionBar(Component) |
6 | CountdownManager.java | buildProgressBar returned String with ChatColor codes — incompatible with Adventure subtitle Component | Returns Component built with NamedTextColor |
7 | ToastUtil.java | Advancement JSON missing "requirements" field + icon missing "count" — invalid on 1.20.4+ Paper | Added "requirements":[[\"trigger\"]] and "count":1 to icon object |
package com.kodari.battleroyale;
import com.kodari.battleroyale.command.BRCommand;
import com.kodari.battleroyale.listener.PlayerListener;
import com.kodari.battleroyale.manager.CountdownManager;
import com.kodari.battleroyale.manager.GameManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
public class BattleRoyalePlugin extends JavaPlugin {
@Getter
private GameManager gameManager;
@Getter
private CountdownManager countdownManager;
@Override
public void onEnable() {
saveDefaultConfig();
this.gameManager = new GameManager(this);
this.countdownManager = new CountdownManager(this);
getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
BRCommand brCommand = new BRCommand(this);
getCommand("br").setExecutor(brCommand);
getCommand("br").setTabCompleter(brCommand);
getLogger().info("BattleRoyale has been enabled.");
}
@Override
public void onDisable() {
if (gameManager != null) {
gameManager.forceReset();
}
getLogger().info("BattleRoyale has been disabled.");
}
}