erizsssy

i want to make a plugin where i can make it so if i do /respawning choose then i gotta right click a block. and that block will respawn every 15 minutes. and i can choose up to 10 blocks that respawn every 15 minutes. if i do /respawning list i can see all the blocks ive choosen to respawn every 15 min. and if i do /respawning remove i can choose from numbers of all the ones ive set so in 1, 2, 3, 4, 5 etc. then make it so i can do /respawning annoucement. then i can edit the annoucement of what will be annoucend in chat every 15 mins when the block respawn.

Kodari AI
KodariJun 3 at 3:08 pm 10
BlockRespawner
A block respawning plugin that lets admins register up to 10 blocks that automatically respawn at their original locations every 15 minutes. Use /respawning choose to right-click a block and register it, /respawning list to view all registered blocks, /respawning remove <number> to unregister one, and /respawning announcement to set a custom chat broadcast sent to all players each time blocks respawn.

Plan:

  • RespawnBlock — data class (location + material)

  • RespawnManager — list management, scheduler, persistence, player state tracking

  • SelectionListener — right-click selection + chat announcement editing

  • RespawningCommand — all subcommands

  • BlockRespawnerPlugin — main class wiring everything together

Here’s what the plugin does:

Commands:

Command
Action
/respawning choose
Puts you in selection mode — right-click any block to register it
/respawning list
Lists all registered blocks with their number, material, and coordinates
/respawning remove <1-10>
Removes the block at that list position
/respawning announcement
Prompts you to type a new announcement in chat (supports
&
color codes, type
cancel
to abort)

How respawning works: Every 15 minutes, every registered block is placed back at its stored location (so if a player mines it, it comes back), then the announcement is broadcast to the entire server.

Permission: blockrespawner.use — defaults to ops only.

erizsssy

they all reset at the same time so add /respawning cycle and it will say when the next respawn is. and it will just go on auto every 15 min from when the first block is selected. only players with OP can use these commands.

Kodari AI
KodariJun 3 at 3:24 pm 9

Three changes needed:

  1. RespawnManager — track cycle start time, expose time-until-next-respawn, only start timer when first block is added (not on plugin load if empty)

  2. RespawningCommand — add cycle subcommand, swap permission check to isOp()

  3. plugin.yml — add cycle to command description, remove permission node

Now fix the main class — startScheduler() should only be called on load if blocks already exist (cycle was already running before restart), and we need to persist the cycle state:

Done. Here’s what changed:

  • /respawning cycle — shows Next respawn in: Xm Ys. If no blocks have been added yet it tells you the cycle hasn’t started.

  • Cycle timing — the 15-minute clock starts the moment you register your first block with /respawning choose. All subsequent blocks join that same cycle, so everything always respawns together.

  • Server restarts — if blocks already exist when the server starts, the cycle resumes immediately (the timer resets from restart, which is the most predictable behavior).

  • OP only — all commands now check player.isOp() instead of a permission node, so only operators can use them.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
8 500
src/main/java/com/kodari/blockrespawner/BlockRespawnerPlugin.java
package com.kodari.blockrespawner;

import org.bukkit.plugin.java.JavaPlugin;

public class BlockRespawnerPlugin extends JavaPlugin {

    private RespawnManager respawnManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        respawnManager = new RespawnManager(this);
        respawnManager.load();
        if (!respawnManager.getBlocks().isEmpty()) {
            respawnManager.startScheduler();
        }

        getCommand("respawning").setExecutor(new RespawningCommand(respawnManager));
        getServer().getPluginManager().registerEvents(new SelectionListener(respawnManager), this);
    }

    @Override
    public void onDisable() {
        if (respawnManager != null) {
            respawnManager.save();
        }
    }
}