Build a Paper/Spigot Minecraft plugin called "BlockInfection" targeting server
version 1.21.11 (api-version '1.21' in plugin.yml, paper-api dependency pinned
to 1.21.11-R0.1-SNAPSHOT). Java 21. Package it as a Maven project with the
shade plugin so dependencies are bundled into the final jar.
## Core concept: virus-style block spreading
When a player breaks a block that belongs to a configured category
(EASY / NORMAL / HARD block lists in config.yml), trigger an "infection":
1. Roll a weighted random outcome category from chances.EASY / chances.NORMAL
/ chances.HARD / chances.SPAWNER (percentages configurable, should sum to
100 by default: EASY 2, NORMAL 25, HARD 23, SPAWNER 50). The outcome
category can differ from the source category.
2. If the outcome is SPAWNER, pick a random mob from a configurable
spawner.mobs list and the result becomes a spawner block set to that mob.
Otherwise pick a random block material from that category's block list in
config.yml.
3. Do NOT do a connected-blocks flood fill. Instead spread to a random
number of blocks scattered around the broken block, with NO requirement
that they touch each other or the origin block:
- Total blocks to infect: random between min-blocks and max-blocks
(config, default 50-500).
- The search box around the origin is asymmetrical/organic: each of the
6 directions (+X, -X, +Y, -Y, +Z, -Z) independently rolls its own
random radius between min-radius and max-radius (config, default
50-100 blocks), instead of one uniform cube radius.
- Targets are picked by choosing random offsets within that box and
checking the real block there ā only existing SOLID blocks are ever
converted (never place into air or liquid; skip and re-roll if the
target is air/liquid/already infected).
4. Apply the spread gradually over time instead of instantly: convert a
configurable number of blocks per batch (blocks-per-batch, default 4)
every N ticks (ticks-per-batch, default 2), using a BukkitRunnable /
scheduler task, to avoid lag spikes on large spreads. Cap total random
target attempts at (remaining blocks * max-attempts-multiplier) so it
can't spin forever if it runs out of valid targets.
5. Track every block that has been produced by a spread (world+x+y+z) in an
in-memory set. If a player breaks a block that's in this set, it must
NEVER start a new infection ā treat it as a plain break. Any block NOT
in this set is always eligible to start a fresh, independent infection
when broken, even if it's sitting right next to already-infected blocks.
6. infection.prevent-recursion (config, default true) toggles the immunity
check above. infection.preserve-drops (default true) controls whether
the originally broken block still drops its normal items ā blocks
converted during the spread itself never drop anything, they just
silently change type.
## Commands
/infection
permission: blockinfection.admin (default: op)
- on/off: toggle the plugin, persist to config.yml
- status: show current on/off state
- reload: reload config.yml and clear the infected-blocks tracking set
- chat: toggle whether infection start/result messages are sent to the
triggering player
- chance <0-100> (alias: percentage): set one category's chance
- chances: print all four current chance values
- spread: with no extra args, print current spreading settings; with
`spread `, update one of: min-blocks, max-blocks,
min-radius, max-radius, blocks-per-batch, ticks-per-batch (positive
integers only)
Include tab completion for all subcommands and their arguments.
## config.yml structure
```
enabled: false
debug: false
chat:
enabled: true
chances:
EASY: 2
NORMAL: 25
HARD: 23
SPAWNER: 50
infection:
prevent-recursion: true
preserve-drops: true
spreading:
min-blocks: 50
max-blocks: 500
min-radius: 50
max-radius: 100
blocks-per-batch: 4
ticks-per-batch: 2
max-attempts-multiplier: 20
require-solid-target: true
spawner:
mobs: [ZOMBIE, SKELETON, CREEPER, SPIDER, BLAZE, ENDERMAN, WARDEN]
blocks:
EASY: [STONE, COBBLESTONE, DIRT, GRASS_BLOCK, SAND, GRAVEL, OAK_LOG,
OAK_LEAVES, BIRCH_LOG, SPRUCE_LOG, GLASS, BRICKS]
NORMAL: [COAL_ORE, IRON_ORE, COPPER_ORE, REDSTONE_ORE, LAPIS_ORE,
QUARTZ_BLOCK, AMETHYST_BLOCK, OBSIDIAN, IRON_BLOCK, COPPER_BLOCK]
HARD: [DIAMOND_BLOCK, GOLD_BLOCK, EMERALD_BLOCK, NETHERITE_BLOCK,
ANCIENT_DEBRIS, CRYING_OBSIDIAN]
messages:
(prefix + all command feedback strings + infection.started /
infection.result chat messages, with color codes via &)
```
## Classes to produce
- Category enum (EASY, NORMAL, HARD, SPAWNER) with fromName(String)
- BlockPosition: immutable world-UUID + x/y/z key with equals/hashCode, used
both for the infected-blocks tracking set and general position identity
- InfectionResult: holds either a chosen Material or (Material.SPAWNER +
EntityType), with a resultName() for messages
- InfectionEngine: owns the infected-blocks Set, listens via a
BlockBreakEvent handler, does the category lookup, weighted chance roll,
result creation, and kicks off the gradual spread job; exposes
clearProcessingGuard() for /infection reload
- SpreadJob (BukkitRunnable): performs the asymmetrical radius rolls per
axis, the batched random-target conversion loop, solid-block checks,
spawner setup via CreatureSpawner, and sends the "infection finished"
chat message when done
- InfectionListener: thin @EventHandler(priority=HIGHEST,
ignoreCancelled=true) wrapper calling engine.process(event)
- InfectionCommand: CommandExecutor + TabCompleter implementing all
subcommands above
- BlockInfectionPlugin (main class): loads config, tracks enabled state,
registers listener/command, exposes message()/rawMessage()/debug() helpers
Deliver a working Maven project (pom.xml with paper-api provided scope
pinned to 1.21.11-R0.1-SNAPSHOT, maven-shade-plugin configured) plus all
source files and the default config.yml/plugin.yml, so `mvn package`
produces the finished plugin jar.