📄
pasted-code-1789651861759.txt
txt
1 lines
▶
Make me a Minecraft Paper plugin in Java for an FFA server that handles arena rotation using Multiverse-Core. I have a list of MV worlds (arenas) in config.yml and a rotation interval in minutes (default 30). The plugin should track which arena is currently "active" and rotate to the next one in the list (round-robin) every interval. When rotation happens: any player currently inside the old active arena gets teleported to their normal spawn (do NOT kill them, just teleport), and the active arena becomes the next one in the list. If a player is already at spawn, don't touch them. The plugin should also provide a /arena command that opens a small GUI with a sword item — clicking it teleports the player to the currently active arena. The GUI always reflects whichever arena is active right now, so after a rotation the sword automatically sends you to the new arena. Use Multiverse-Core API to resolve worlds and spawn locations. Include plugin.yml (depend on Multiverse-Core), config.yml, and the Java classes. Keep it simple, no extra dependencies.
Create the Gradle project and plugin metadata.
Add configuration, arena rotation, Multiverse world resolution, and spawn teleport handling.
Add the
/arenaGUI with a live active-arena teleport button.
Created the FFA arena rotation plugin with:
Multiverse-Core integration for world and spawn resolution.
Configurable arena list and rotation interval.
Round-robin arena rotation.
Teleportation of players from the old arena to normal spawn without killing them.
Spawn proximity check to avoid unnecessary teleports.
/arenaGUI with a live diamond sword button.GUI refresh after each rotation so it always displays the current arena.
plugin.yml,config.yml, Gradle setup, and all Java classes.
Also add the following: When 5 seconds remain before rotation, show a countdown title and subtitle on screen ("Map rotation in 3... 2... 1..."). The countdown display location should be configurable in config.yml with options: chat, actionbar, or disabled (none). Add a /ffaarenarotation status command that shows the current active arena, the time remaining until next rotation, and the list of players currently in that arena. Add a /ffaarenarotation reload command to reload config.yml without restarting. Expose a placeholder for the remaining time in minutes:seconds format so it can be used in scoreboards or other plugins. The plugin name is GlowistMAP and the author is GlowistZEW — make sure plugin.yml reflects that.
Update plugin identity and metadata to GlowistMAP / GlowistZEW.
Add configurable five-second rotation countdown titles and display locations.
Add
/ffaarenarotation statusandreloadsubcommands.Expose the remaining-time placeholder in
minutes:secondsformat.
Task 1 is complete: plugin.yml now identifies the plugin as GlowistMAP by GlowistZEW.
Tasks 2–3 are complete: the five-second countdown, configurable display mode, status output, reload flow, and command registration are in place.
Updated plugin metadata:
Name:
GlowistMAPAuthor:
GlowistZEW
Added configurable countdown:
YAMLrotation-countdown-display: actionbarSupported values:
chatactionbarnone/disabled
Displays
Map rotation in 5...throughMap rotation in 1....Added commands:
/ffaarenarotation statusActive arena
Remaining time in
MM:SSPlayers currently in the active arena
/ffaarenarotation reloadReloads
config.ymlRequires
ffaarenarotation.reload
Added PlaceholderAPI support:
Plain Text%glowistmap_remaining%Returns the remaining rotation time in
MM:SSformat.PlaceholderAPI is optional and configured as a soft dependency; no library is bundled into the plugin.
Also add: The countdown display location in config.yml should have these options: title (with subtitle), title (without subtitle, just the main text), chat, actionbar, or disabled (none). After the countdown finishes and rotation happens, show a message "Map has been rotated!" (configurable text) in the same display location. Also add a feature where any block a player places in the active arena world is automatically removed after a configurable time (default 5 minutes, settable in config.yml as block-cleanup-minutes). The plugin should track placed blocks per player and schedule their removal. Players can place blocks freely but cannot break blocks (cancel block break events in the arena world).
Extend countdown/rotation messaging with title, subtitle, chat, actionbar, and disabled display modes.
Add per-player placed-block tracking with configurable delayed cleanup and prevent block breaking in the active arena.
Update configuration and any required listener/manager wiring.
Implemented:
Added countdown display modes:
title— main title with subtitletitle-without-subtitle— main title onlychatactionbardisabled/none
Added configurable countdown text and subtitle:
YAMLrotation-countdown-message: "&eMap rotation in %seconds%..." rotation-countdown-subtitle: "&7Prepare for the next map."Added configurable rotation completion message:
YAMLrotation-complete-message: "&aMap has been rotated!"It uses the same configured display mode.
Added automatic placed-block cleanup:
YAMLblock-cleanup-minutes: 5Tracks placed blocks per player and removes them after the configured delay.
Cancels all block-break events in the active arena world.
Registered the new block listener in the main plugin class.
Also, when the block cleanup runs and removes the player's placed blocks, send them a chat message like "Your placed blocks have been cleaned up." (configurable text in config.yml).
Added configurable cleanup messaging:
block-cleanup-message: "&eYour placed blocks have been cleaned up."
When a tracked placed block is removed, the player receives the configured chat message.
Change the block cleanup message so it's broadcast to all online players in chat, not just the individual player. Something like "&e[Map Rotation] Placed blocks have been cleaned up." — broadcast to everyone, not per-player and also look deep into the plugin and check if there are any bugs, if are fix them
Change block-cleanup messaging to broadcast once to all online players with configurable text.
Audit the plugin’s rotation, countdown, commands, GUI, cleanup, and reload paths for concrete bugs and fix verified issues.
Updated GlowistMAP:
Block cleanup messages now use
Bukkit.broadcastMessage(...), reaching all online players.Default message is:
YAMLblock-cleanup-message: "&e[Map Rotation] Placed blocks have been cleaned up."Cleanup broadcasts only once per cleanup pass instead of once per block.
During the audit, I also fixed these confirmed issues:
Prevented cleanup from removing replacement blocks at tracked locations.
Added support for multi-block placements such as doors and beds.
Ignored cancelled block-place events.
Preserved the rotation timer when reloading configuration.
Rejected reloads that remove the currently active arena.
Prevented invalid reloads from partially replacing the active configuration.
Fixed null countdown messages from breaking the rotation task.
Added Multiverse alias support.
Added loading support for configured but unloaded Multiverse worlds.
Made one-arena configurations report
00:00instead of showing a frozen full timer.Kept tracked blocks pending if their world is temporarily unloaded.
Updated the reload failure message to explain the validation requirements.
Remove any hardcoded reference to "arena_one" or any default arena name. The plugin should only use whatever arenas are listed in config.yml, with no assumptions about naming. If the state file or internal logic references a default arena, remove it. The first arena in the config.yml list should be the initial active arena on first startup, and after that it just follows the list order.
Updated config.yml to remove all hardcoded arena names:
arenas:
# Add Multiverse-Core world names here in rotation order.
Verified the internal logic already behaves as required:
The first configured arena starts as active because
activeIndexbegins at0.Rotations follow the configured list order using round-robin logic.
No state file or persisted default arena reference exists.
No Java code references
arena_one,arena_two, or another fixed arena name.The plugin disables itself if no arenas are configured rather than selecting a fallback arena.
📄
pasted-code-1789655387449.txt
txt
1 lines
▶
Fix the block cleanup: instead of broadcasting the message once per block, collect all blocks to remove first, remove them all in a single batch instantly, and then broadcast the message exactly once. Also, players should be able to break blocks they placed themselves — only prevent breaking of pre-existing arena blocks, not player-placed ones. Make all message prefixes configurable in config.yml by adding a single message-prefix option that gets prepended to all broadcast messages (rotation complete, block cleanup, countdown, etc.). The prefix must support full color formatting including hex colors and gradients (use MiniMessage or at minimum support & codes plus hex like FF5555). Add a /ffaarenarotation bypass command that toggles a bypass mode for the player who runs it — while bypassed, the player can break any block in the arena including pre-existing ones, place blocks without them being tracked for cleanup, and is not affected by the block break cancel. The command should require OP or a custom permission node (glowistmap.bypass). Send a private message when bypass is toggled on or off.
Batch block cleanup and broadcast the prefixed message once.
Track player-placed blocks so their owners can break them while protected arena blocks remain unbreakable.
Add configurable prefix formatting, including legacy/hex/gradient support.
Add the permission-gated
/ffaarenarotation bypasstoggle and apply its exemptions.
Implemented the requested changes.
Block cleanup now:
Collects all expired placed blocks first.
Removes them together in one cleanup pass.
Broadcasts the cleanup message exactly once after removal.
Uses the configurable
message-prefix.
Block breaking behavior:
Players can break tracked player-placed blocks.
Pre-existing arena blocks remain protected.
Bypass players can break any block.
Tracked blocks are properly removed from cleanup tracking when broken.
Added configurable message prefix with support for:
Legacy colors:
&e,&l,&r, etc.Hex colors:
&#FF5555MiniMessage colors, gradients, and formatting.
Example configuration:
message-prefix: "<gradient:#00C6FF:#0072FF>GlowistMAP</gradient> &8» "
block-cleanup-message: "Placed blocks have been cleaned up."
Added
/ffaarenarotation bypass.Requires OP or
glowistmap.bypass.Toggles per-player bypass mode.
Bypassed players can break protected arena blocks.
Their placed blocks are not tracked for cleanup.
Sends a private enabled/disabled message.
Added the permission to
plugin.yml.
Countdown and rotation-complete displays now also use the configured prefix.
📄
pasted-code-1789656050597.txt
txt
7 lines
▶
The block cleanup is STILL spamming the chat multiple times and blocks are not being removed instantly. Here is exactly what needs to happen:
The cleanup task should run ONCE (not repeatedly). When the timer expires, collect ALL tracked blocks into a list, set them ALL to air in a single loop on the main thread, then broadcast the message EXACTLY ONE TIME. Do not broadcast inside the loop.
If the cleanup is currently implemented as a repeating task or a per-block scheduler, rewrite it as a single one-shot scheduled task that fires at the exact expiration time.
After cleanup, clear the tracked blocks list so it doesn't fire again.
Show me the exact Java code for the cleanup method so I can verify it broadcasts once and removes all blocks in one pass.
Also, do NOT apply the message-prefix to the countdown messages (title, subtitle, or actionbar). The prefix should only be applied to broadcast chat messages like the rotation complete message and the block cleanup message. The countdown display should show exactly what is written in rotation-countdown-message and rotation-countdown-subtitle, with no prefix prepended.
Rewrite cleanup as a one-shot expiration task that batches removal, clears tracking, and broadcasts once.
Remove the prefix from countdown title, subtitle, and actionbar output while retaining it for broadcast chat messages.
Implemented.
Replaced the repeating cleanup task with a single
runTaskLater(...)task.The task collects all tracked blocks, clears tracking immediately, removes blocks in one main-thread loop, then broadcasts once.
New blocks are scheduled only when no cleanup task is already pending.
Countdown messages no longer receive
message-prefix; countdown title, subtitle, chat, and actionbar use their configured text exactly.Rotation-complete and block-cleanup chat messages still use the configurable prefix.
Exact cleanup code:
private void scheduleBlockCleanup(long cleanupMillis) {
if (blockCleanupTask != null) {
return;
}
long cleanupTicks = Math.max(1L, cleanupMillis / 50L);
blockCleanupTask = Bukkit.getScheduler()
.runTaskLater(plugin, this::cleanupPlacedBlocks, cleanupTicks);
}
private void cleanupPlacedBlocks() {
blockCleanupTask = null;
List<PlacedBlock> blocksToRemove = new ArrayList<>();
for (Map<BlockKey, PlacedBlock> playerBlocks : placedBlocks.values()) {
blocksToRemove.addAll(playerBlocks.values());
}
placedBlocks.clear();
for (PlacedBlock placedBlock : blocksToRemove) {
World world = Bukkit.getWorld(placedBlock.key().worldId());
if (world == null) {
continue;
}
Block block = world.getBlockAt(
placedBlock.key().x(),
placedBlock.key().y(),
placedBlock.key().z()
);
if (block.getType() == placedBlock.material()) {
block.setType(Material.AIR, false);
}
}
if (!blocksToRemove.isEmpty()) {
String cleanupMessage = plugin.getConfig().getString(
"block-cleanup-message",
"Placed blocks have been cleaned up."
);
Component component = formatMessage(cleanupMessage);
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(component);
}
}
}
The broadcast is outside the removal loop, so it executes at most once per cleanup task.
📄
pasted-code-1789657054714.txt
txt
15 lines
▶
Apply all of the following fixes to GlowistMAP:
Block cleanup: Rewrite the cleanup as a single one-shot scheduled task. When the timer expires, collect ALL tracked blocks (including liquids: water, lava, flowing water, flowing lava) into a list, set them all to air in one loop on the main thread, then broadcast the message exactly once. After cleanup, clear the tracked blocks list. Do NOT broadcast inside the loop. Do NOT prevent liquid flow — water and lava must flow normally. The cleanup is the only protection.
Block breaking: Players can break blocks they placed themselves. Only prevent breaking of pre-existing arena blocks.
Fire: Cancel FireTickEvent in the active arena world to prevent fire spread. Cancel PlayerInteractEvent for flint and steel in the arena world. Do NOT cancel EntityCombustEvent — potions, fire aspect, and all combat mechanics must work normally.
Explosions: Listen to EntityExplodeEvent in the arena world. Call event.blockList().clear() so no blocks are destroyed, but do NOT cancel the event — damage must still go through.
Message prefix: Add a single message-prefix option in config.yml supporting hex colors and gradients. The prefix is applied ONLY to the block cleanup broadcast message. Do NOT apply it to countdown messages (title, subtitle, actionbar) or to the rotation complete message ("Map has been rotated!"). Those show exactly what is in their config entries, no prefix.
Bypass: /ffaarenarotation bypass toggles bypass for the player. While bypassed they can break any block, place without tracking, and are not affected by block break cancel. Requires OP or glowistmap.bypass. Private message on toggle.
Show me the final Java code for the cleanup method, event handlers (fire, explosion, block break, block place), and the bypass command handler.
Implemented all requested changes.
Cleanup remains a single
runTaskLaterone-shot task.All tracked blocks are copied, tracking is cleared, and every block—including water, lava, and flowing liquid—is set to air in one main-thread loop.
Cleanup broadcasts exactly once after removal.
Liquid flow is not cancelled; flow destinations are tracked for cleanup.
Fire spread and fire block damage are prevented without cancelling
EntityCombustEvent.Explosions still deal entity damage, but their block-destruction list is cleared.
message-prefixis used only for the block cleanup broadcast.Countdown and rotation-complete messages are displayed exactly as configured.
Bypass messages are private and do not receive the cleanup prefix.
Paper does not provide a FireTickEvent; BlockSpreadEvent is the event used to stop fire spreading, and BlockBurnEvent prevents fire from destroying blocks.
Cleanup scheduling and method
private void scheduleBlockCleanup(long cleanupMillis) {
if (blockCleanupTask != null) {
return;
}
long cleanupTicks = Math.max(1L, (cleanupMillis + 49L) / 50L);
blockCleanupTask = Bukkit.getScheduler()
.runTaskLater(plugin, this::cleanupPlacedBlocks, cleanupTicks);
}
private void cleanupPlacedBlocks() {
blockCleanupTask = null;
List<PlacedBlock> blocksToRemove = new ArrayList<>();
for (Map<BlockKey, PlacedBlock> playerBlocks : placedBlocks.values()) {
blocksToRemove.addAll(playerBlocks.values());
}
placedBlocks.clear();
for (PlacedBlock placedBlock : blocksToRemove) {
World world = Bukkit.getWorld(placedBlock.key().worldId());
if (world == null) {
continue;
}
Block block = world.getBlockAt(
placedBlock.key().x(),
placedBlock.key().y(),
placedBlock.key().z()
);
block.setType(Material.AIR, false);
}
if (!blocksToRemove.isEmpty()) {
String prefix = plugin.getConfig().getString("message-prefix", "");
String cleanupMessage = plugin.getConfig().getString(
"block-cleanup-message",
"Placed blocks have been cleaned up."
);
Bukkit.broadcast(parseMessage(
(prefix == null ? "" : prefix)
+ (cleanupMessage == null ? "" : cleanupMessage)
));
}
}
The tracked record now contains only the block key:
private record PlacedBlock(BlockKey key) {
}
Block placement and liquid tracking
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (event.isCancelled()) {
return;
}
if (!arenaManager.isActiveArenaWorld(event.getBlock().getWorld())) {
return;
}
if (arenaManager.isBypassed(event.getPlayer())) {
arenaManager.forgetTrackedPlacedBlock(event.getBlock().getLocation());
} else {
arenaManager.trackPlacedBlock(
event.getPlayer(),
event.getBlock().getLocation()
);
}
if (event instanceof BlockMultiPlaceEvent multiPlaceEvent) {
for (BlockState blockState : multiPlaceEvent.getReplacedBlockStates()) {
if (arenaManager.isBypassed(event.getPlayer())) {
arenaManager.forgetTrackedPlacedBlock(
blockState.getBlock().getLocation()
);
} else {
arenaManager.trackPlacedBlock(
event.getPlayer(),
blockState.getBlock().getLocation()
);
}
}
}
}
@EventHandler
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
if (event.isCancelled()
|| !arenaManager.isActiveArenaWorld(event.getBlock().getWorld())) {
return;
}
if (arenaManager.isBypassed(event.getPlayer())) {
arenaManager.forgetTrackedPlacedBlock(event.getBlock().getLocation());
} else {
arenaManager.trackPlacedBlock(
event.getPlayer(),
event.getBlock().getLocation()
);
}
}
@EventHandler
public void onLiquidFlow(BlockFromToEvent event) {
if (event.isCancelled()
|| !arenaManager.isActiveArenaWorld(event.getBlock().getWorld())) {
return;
}
String sourceType = event.getBlock().getType().name();
if (sourceType.equals("WATER") || sourceType.equals("LAVA")) {
arenaManager.trackLiquidFlow(
event.getBlock().getLocation(),
event.getToBlock().getLocation()
);
}
}
Block breaking
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
if (event.isCancelled()) {
return;
}
if (!arenaManager.isActiveArenaWorld(event.getBlock().getWorld())) {
return;
}
boolean bypassed = arenaManager.isBypassed(event.getPlayer());
boolean trackedPlacedBlock =
arenaManager.forgetTrackedPlacedBlock(event.getBlock().getLocation());
if (bypassed || trackedPlacedBlock) {
return;
}
event.setCancelled(true);
}
Tracked player-placed blocks are allowed to break normally. Untracked pre-existing arena blocks remain protected. Bypassed players can break either type.
Fire and explosion handlers
@EventHandler
public void onBlockSpread(BlockSpreadEvent event) {
if (!arenaManager.isActiveArenaWorld(event.getBlock().getWorld())) {
return;
}
String sourceType = event.getSource().getType().name();
if (sourceType.equals("FIRE") || sourceType.equals("SOUL_FIRE")) {
event.setCancelled(true);
}
}
@EventHandler
public void onBlockBurn(BlockBurnEvent event) {
if (arenaManager.isActiveArenaWorld(event.getBlock().getWorld())) {
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getItem() != null
&& event.getItem().getType().name().equals("FLINT_AND_STEEL")
&& arenaManager.isActiveArenaWorld(event.getPlayer().getWorld())) {
event.setCancelled(true);
}
}
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (arenaManager.isActiveArenaWorld(event.getLocation().getWorld())) {
event.blockList().clear();
}
}
EntityCombustEvent is not registered or cancelled, so fire aspect, potions, and other entity combustion mechanics continue to work.
Bypass command handler
if (args[0].equalsIgnoreCase("bypass")) {
if (!(sender instanceof Player player)) {
sender.sendMessage(ChatColor.RED
+ "Only players can toggle bypass mode.");
return true;
}
if (!sender.isOp()
&& !sender.hasPermission("glowistmap.bypass")) {
sender.sendMessage(ChatColor.RED
+ "You do not have permission to use bypass mode.");
return true;
}
boolean enabled = arenaManager.toggleBypass(player);
player.sendMessage(enabled
? ChatColor.GREEN + "Arena bypass enabled."
: ChatColor.YELLOW + "Arena bypass disabled.");
return true;
}
Rotation completion now uses:
showRotationDisplay(
plugin.getConfig().getString(
"rotation-complete-message",
"&aMap has been rotated!"
),
""
);
No message-prefix is applied to the rotation completion message or any countdown title, subtitle, actionbar, or countdown chat display.
The liquid cleanup is not working. When a player places water or lava, it flows and creates new liquid blocks that are NOT being tracked, so they remain after cleanup. Fix this: listen to FluidLevelChangeEvent in the active arena world. When a new liquid block appears at a destination (i.e. the destination was air or a non-liquid block before the event), add that destination block to the tracked blocks list with the same expiration as the original placement. This must work recursively — if the flowed water then flows further, those new blocks must also be tracked. The cleanup task must remove ALL of these, not just the original source block. Test scenario: player places 1 water source block on the floor → it flows 4-5 blocks → ALL of those blocks (source + flowed) must be removed at cleanup time.
also change plugin version to 1.0.1
Fix recursive liquid tracking via
FluidLevelChangeEventand ensure cleanup removes every flowed block.Update the plugin version to
1.0.1.
The current listener only tracks BlockFromToEvent destinations when it can match the source key. I’m adding FluidLevelChangeEvent handling with a tracked-liquid-neighbor check, so each newly created liquid block is chained to the original tracked placement without tracking unrelated natural fluids.
Added
FluidLevelChangeEventhandling for active arena worlds. New water/lava blocks are tracked only when the destination was previously non-liquid and the new block data is liquid.Added recursive tracking through adjacent tracked liquid blocks, so every subsequent flow is associated with the original placement and removed by the existing cleanup task.
Updated
plugin.ymlversion from1.0.0to1.0.1.
package com.example.ffaarena;
import com.example.ffaarena.command.ArenaCommand;
import com.example.ffaarena.command.FFAArenaRotationCommand;
import com.example.ffaarena.gui.ArenaMenuListener;
import com.example.ffaarena.placeholder.RemainingTimePlaceholder;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public final class FFAArenaPlugin extends JavaPlugin {
private ArenaManager arenaManager;
@Override
public void onEnable() {
saveDefaultConfig();
arenaManager = new ArenaManager(this);
getCommand("arena").setExecutor(new ArenaCommand(arenaManager));
getCommand("ffaarenarotation").setExecutor(new FFAArenaRotationCommand(arenaManager));
Bukkit.getPluginManager().registerEvents(new ArenaMenuListener(arenaManager), this);
Bukkit.getPluginManager().registerEvents(new ArenaBlockListener(arenaManager), this);
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
new RemainingTimePlaceholder(this, arenaManager).register();
}
arenaManager.startRotation();
}
@Override
public void onDisable() {
if (arenaManager != null) {
arenaManager.stopRotation();
}
}
}