Meow Meow124

Create a plugin for the version 1.21.11 where every 60 seconds a random letter is chosen and the blocks starting with that letter stay and all other blocks disappear for 5 seconds And

Kodari AI
KodariOct 27 at 2:42 pm 1
LetterSurvival
A Minecraft 1.21.11 plugin that creates a dynamic block survival challenge. Every 60 seconds, a random letter is selected, and all blocks whose names begin with that letter remain visible while all other blocks disappear for 5 seconds. Players must adapt to the changing environment, strategizing their movements and builds around the temporary block vanish cycle. The plugin includes configurable timers, a visual countdown warning before each letter selection, and a chat announcement displaying the chosen letter. After the 5-second disappearance window, all blocks reappear, resetting the cycle. This creates an engaging survival twist where players must memorize block layouts and navigate through temporary voids, testing their spatial awareness and quick thinking.
  1. Create the Paper 1.21 plugin setup for Minecraft 1.21.11.

  2. Every 60 seconds, choose a letter and temporarily remove loaded-world blocks whose material names start with another letter.

  3. Restore the removed blocks after five seconds.

Created RandomLetterBlocks, a Paper plugin for 1.21.11. After 60 seconds and every minute thereafter, it picks a random letter, removes non-air blocks in loaded chunks whose material names start with a different letter, then restores them after five seconds.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 88
src/main/java/com/kodari/randomletterblocks/RandomLetterBlocksPlugin.java
package com.kodari.randomletterblocks;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

public final class RandomLetterBlocksPlugin extends JavaPlugin {
    private static final long INTERVAL_TICKS = 60L * 20L;
    private static final long VANISH_TICKS = 5L * 20L;

    @Override
    public void onEnable() {
        Bukkit.getScheduler().runTaskTimer(this, this::startRound, INTERVAL_TICKS, INTERVAL_TICKS);
    }

    private void startRound() {
        char chosenLetter = (char) ('A' + ThreadLocalRandom.current().nextInt(26));
        org.bukkit.Material air = XMaterial.matchXMaterial("AIR").orElseThrow().parseMaterial();
        List<BlockState> removedBlocks = new ArrayList<>();

        for (World world : Bukkit.getWorlds()) {
            for (var chunk : world.getLoadedChunks()) {
                for (int x = 0; x < 16; x++) {
                    for (int z = 0; z < 16; z++) {
                        for (int y = world.getMinHeight(); y < world.getMaxHeight(); y++) {
                            Block block = chunk.getBlock(x, y, z);
                            if (block.getType().isAir()) {
                                continue;
                            }

                            String materialName = XMaterial.matchXMaterial(block.getType()).name();
                            if (materialName.charAt(0) != chosenLetter) {
                                removedBlocks.add(block.getState());
                                block.setType(air, false);
                            }
                        }
                    }
                }
            }
        }

        Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&eBlocks starting with &6" + chosenLetter + " &ewill stay. Other blocks return in 5 seconds."));
        Bukkit.getScheduler().runTaskLater(this, () -> {
            for (BlockState state : removedBlocks) {
                state.update(true, false);
            }
        }, VANISH_TICKS);
    }
}