ToggleMobSpawn
Docs/ToggleMobSpawn

ToggleMobSpawn

Let players switch hostile mob spawning off around themselves, with per-player state that survives restarts.

Requirements

  • Paper or Folia 26.2 or newer
  • Java 25

The Paper dialog admin menu (/mobadmin dialog) needs no extra version; it works on every supported server.

Installation

  1. Drop ToggleMobSpawn.jar into plugins/.
  2. Start the server once to generate the config files.
  3. Set your license key in config.yml (license-key).
  4. Edit config.yml, messages.yml, database.yml and the files in gui/ as needed.
  5. Run /mobadmin reload (or /mob reload) to apply changes without a restart. Storage settings in database.yml need a restart.

Required libraries are downloaded automatically on first start.

Files created in plugins/ToggleMobSpawn/:

File Purpose
config.yml Settings, spawn rules, trial chamber guard, vault protection, sounds, permission nodes
messages.yml Every chat line, action bar, title and sound
database.yml Storage backend and connection settings
gui/whitelist.yml Layout of the inventory admin menu
gui/admin-dialog.yml Layout of the dialog admin menu
toggle-players.yml Saved toggles when storage-type is YAML
data.db Saved toggles when storage-type is SQLITE

When the plugin updates, missing keys are added to config.yml, messages.yml, database.yml and the gui/ files and your values are kept. The console lists the keys that were added. When a file's version number goes up, your previous file is also saved as <file>.bak and the new default file is written next to it as <file>.new, so you can compare the two. A file with invalid YAML is ignored and the bundled defaults are used until you fix it.

Commands

Command Aliases Description Permission
/mobspawn /tms Toggle mob spawn blocking near you. Clears nearby blocked mobs when you switch it on (see settings.clear-on-disable) togglemobspawn.toggle
/mobspawn status /tms status Show your current toggle state togglemobspawn.toggle
/mobspawn reload /tms reload Reload config, messages and menus togglemobspawn.toggle and togglemobspawn.reload
/mobspawn help /tms help Show the command list togglemobspawn.toggle
/mob Toggle mob spawn blocking near you. Does not clear nearby mobs togglemobspawn.toggle
/mob status Show your current toggle state togglemobspawn.toggle
/mob reload Reload config, messages and menus togglemobspawn.toggle and togglemobspawn.reload
/mob help Show the command list togglemobspawn.toggle
/mobadmin Open the admin menu (mob lists and settings). Opens the inventory menu, or the dialog menu when settings.admin-menu-dialog is true togglemobspawn.admin
/mobadmin gui Open the inventory menu togglemobspawn.admin
/mobadmin dialog Open the dialog menu togglemobspawn.admin
/mobadmin reload Reload config, messages and menus togglemobspawn.admin and togglemobspawn.reload
/mobadmin help Show the admin command list togglemobspawn.admin

Toggle, status and the admin menus can only be used by players. Tab completion is available for all subcommands; reload is only suggested to players who hold togglemobspawn.reload.

How blocking works

Spawn blocking is per player and is saved, so it is restored after a restart. While it is on for a player, a spawn is cancelled when it happens within settings.chunk-radius chunks of that player (same world, square area).

  • Spawn reasons listed under spawn-reasons.always-allowed are never blocked.
  • Reasons listed under spawn-reasons.natural use the settings.blocked-natural list.
  • Every other reason uses the settings.blocked-non-natural list.
  • Trial spawner spawns are always blocked near a toggled player, whatever the lists say, and the trial chamber guard removes the mobs that slip through.
  • Chicken jockeys are always blocked near a toggled player, whatever the lists say. When a blocked mob was spawned riding something or with a rider, the freshly spawned mount or rider is removed with it. A chicken that is not new simply stops being a jockey. Mobs removed by /mobspawn clearing, the trial chamber guard or shutdown clearing take a chicken jockey mount with them.

The trial chamber guard sweeps the area around every toggled player each scan-interval-ms. It removes mobs whose type is in trial-chamber-guard.mob-types, and also any mob without a custom name whose type is in settings.blocked-natural. The sweep covers settings.chunk-radius chunks around the player and trial-chamber-guard.vertical-radius blocks above and below.

If settings.clear-on-disable is enabled, switching blocking on with /mobspawn also removes blocked mobs already within your chunk radius (mobs in the blocked-natural list). /mob only toggles and never clears.

Permissions

Permission Default Description
togglemobspawn.toggle op Use /mob and /mobspawn (toggle, status, help)
togglemobspawn.reload op Use the reload subcommand. It is required in addition to the command's own permission
togglemobspawn.admin op Use /mobadmin
togglemobspawn.whitelist op Declared for the mob list menu; /mobadmin itself checks togglemobspawn.admin
togglemobspawn.* op Grants toggle, reload, whitelist and admin

The nodes the commands check are set under permissions in config.yml and default to the names above. The commands are also gated by the default nodes in plugin.yml, so leave them at their defaults unless you know you need to change them.

Configuration

config.yml

Key Default Description
license-key support invite link Your license key
debug false Print verbose spawn-blocking activity to the console
accent-color &#00D4FF Main color of the plugin, written as #RRGGBB. Used wherever {accent} appears. An invalid value falls back to #00D4FF
colors.success / error / warning / muted / separator / info / white &#00FF9D / &#FF4D4D / &#FFD166 / &#9AA7B5 / &#5C6773 / &#C77DFF / &#FFFFFF Shared palette, used as {success}, {error} and so on inside messages.yml and gui/*.yml
settings.chunk-radius 6 Radius in chunks around each toggled player where spawning is blocked. Minimum 1
settings.clear-on-disable true Remove already-spawned blocked mobs near a player when they enable blocking with /mobspawn. On servers that are not Folia it also clears all blocked mobs in every world on plugin shutdown
settings.admin-menu-dialog false Open /mobadmin as a dialog instead of an inventory menu
settings.blocked-natural hostile mobs Entity types blocked from natural spawns
settings.blocked-non-natural hostile mobs Entity types blocked from non-natural spawns (spawners, breeding, portals, raids and similar)
spawn-reasons.natural NATURAL, DEFAULT, JOCKEY, MOUNT, CHUNK_GEN, DROWNED, SILVERFISH_BLOCK, BEEHIVE, VILLAGE_INVASION, PIGLIN_ZOMBIFIED, SHEARED Bukkit spawn reasons treated as natural. Every reason not listed here or under always-allowed counts as non-natural. Unknown names are skipped
spawn-reasons.always-allowed SPAWNER_EGG, EGG, DISPENSE_EGG, BUILD_SNOWMAN, BUILD_IRONGOLEM, BUILD_WITHER, OCELOT_BABY, SHOULDER_ENTITY Reasons that are never blocked (player-built or player-spawned mobs)
spawn-reasons.trial-spawner TRIAL_SPAWNER Spawn reason used by trial spawners
trial-chamber-guard.enabled true Periodically remove trial chamber mobs near toggled players, since they can slip through event cancellation
trial-chamber-guard.mob-types BREEZE, BOGGED Entity types removed by the sweep (unnamed mobs in settings.blocked-natural are removed too)
trial-chamber-guard.scan-interval-ms 2000 Milliseconds between sweeps for every toggled player. Minimum 1
trial-chamber-guard.per-pass-limit 32 Maximum entities removed per player per sweep. Minimum 1
trial-chamber-guard.vertical-radius 48 Blocks above and below the player that a sweep covers. Lower is cheaper, but it must still reach the chamber floor. Range 1 to 4096
trial-chamber-guard.event-scan-cooldown-ms 250 Minimum milliseconds between spawn-triggered sweeps for the same player. Minimum 0
blaze-spawner-drops.enabled true Blazes that came from a spawner can drop glowstone dust instead of a blaze rod
blaze-spawner-drops.glowstone-chance 0.5 Chance, from 0.0 to 1.0, that each blaze rod drop becomes glowstone dust
vault-protection.enabled true Turn vault protection on or off
vault-protection.material VAULT Block material that counts as a vault
vault-protection.block-loot true Cancel loot drops from vaults inside a toggled player's radius
vault-protection.block-interact true Stop toggled players from interacting with vaults
sounds.enabled true Master switch for every sound the plugin plays
sounds.gui-click.sound / volume / pitch ENTITY_CHICKEN_EGG / 0.5 / 1.1 Sound played on menu clicks. Volume 0.0 to 10.0, pitch 0.0 to 2.0
sounds.gui-error.sound / volume / pitch ENTITY_VILLAGER_NO / 0.8 / 1.0 Error sound. Same ranges as gui-click
permissions.toggle / reload / admin togglemobspawn.toggle / togglemobspawn.reload / togglemobspawn.admin Permission nodes the commands check

Both block lists take Bukkit EntityType names, for example ZOMBIE or CREEPER; unknown names are ignored with a console warning. The natural list also blocks ZOMBIE_VILLAGER, GUARDIAN and ELDER_GUARDIAN by default. When you update from an older config, PARCHED, CAMEL_HUSK and ZOMBIE_NAUTILUS are added to both lists. You can also edit both lists, clear-on-disable and debug in /mobadmin; changes made there are written to config.yml.

An older settings.debug key is moved to debug automatically.

database.yml

Key Default Description
storage-type YAML YAML, SQLITE, MYSQL or REDIS
flush-delay-ms 1000 Toggle changes are batched and written together after this many milliseconds
shutdown-timeout-seconds 10 Seconds to wait for the final save when the plugin shuts down
mysql.host / port / database / username / password localhost / 3306 / togglemobspawn / root / empty MySQL or MariaDB connection
mysql.pool.maximum-pool-size 2 Max pooled connections
mysql.pool.minimum-idle 1 Idle connections kept open
mysql.pool.max-lifetime-ms 1800000 Milliseconds before a pooled connection is recycled
mysql.pool.connection-timeout-ms 30000 Milliseconds to wait for a connection before failing
redis.host / port / password / database localhost / 6379 / empty / 0 Redis connection. Leave the password blank if your Redis has none
redis.timeout-ms 5000 Milliseconds before a Redis command times out
redis.key togglemobspawn:toggled Redis key holding the set of toggled player UUIDs

All storage work runs on its own dedicated thread. Storage settings are read at startup, so changes need a restart. If storage-type is invalid, or the chosen backend fails to start, the plugin falls back to YAML.

YAML and SQLITE are single-server. MYSQL and REDIS let several servers keep their toggles in the same place. Toggles are loaded when a server starts, so a change made on one server reaches the others on their next restart.

messages.yml

Every message is a section with its own switches. Each section can send chat lines, an action bar, a title and a sound, and overall-enabled: false turns the whole message off.

Key Description
toggled-on / toggled-off Shown when blocking is enabled or disabled. Placeholder: {radius}
status-on / status-off Shown by the status subcommand. Placeholder: {radius}
cleared-mobs Shown after mobs are cleared. Placeholders: {count}, {noun}
mob-allowed / mob-blocked Shown when a mob is changed in the inventory menu. Placeholders: {mob}, {list}
reloaded / reload-failed Shown after a reload
no-permission Shown when a command is denied
player-only Shown when the console runs a player-only command
unknown-subcommand Shown for an unknown subcommand. Placeholder: {label}
vault-loot-disabled / vault-interact-disabled Shown when vault protection blocks loot or interaction
help-toggle / help-admin Help pages for /mob and /mobadmin. Placeholder: {label}
words Short words filled into messages: mob-singular, mob-plural, list-natural, list-non-natural

Each section accepts these keys:

Key Description
overall-enabled Turn the whole message off
messages-enabled / messages Chat lines
actionbar-enabled / Actionbar Action bar text
title-enabled / title / subtitle Title and subtitle
title-fadein / title-stay / title-fadeout Title timing in ticks
sound-enabled / sound / sound-volume / sound-pitch Sound played with the message

The toggle messages ship with the action bar and title disabled. Colors accept & codes and &#RRGGBB hex, plus the {accent}, {success}, {error}, {warning}, {muted}, {separator}, {info} and {white} tokens from config.yml.

gui/whitelist.yml

The inventory menu opened by /mobadmin gui.

Key Default Description
title {accent}&lMob Spawn Blocker Menu title
size 36 27, 36, 45 or 54. The last row is the navigation bar, every row above it lists mobs
style.* Look of every item name and lore (headers, colors, call-to-action text)
states.* Text for the {state} placeholder
mob.* Name, info lines and click action of the mob spawn eggs
items.* Navigation bar items: previous, natural-tab, non-natural-tab, reload, clear-on-disable, debug, next. Each has a column (0 to 8), a material, a name, info lines and an action

The menu shows one spawn egg per mob and has a Natural Spawning tab and a Non-Natural Spawning tab. Click a mob to block or allow it on the active tab. The navigation bar also has page buttons (shown only when there is more than one page), reload, and toggles for clear-on-disable and debug. There is no close button; Esc closes the menu.

gui/admin-dialog.yml

The dialog menu opened by /mobadmin dialog, or by /mobadmin when settings.admin-menu-dialog is true.

Key Default Description
page-size 15 Mobs shown per dialog page
columns 3 Button columns
button-width 150 Width of each button in pixels
status.* / states.* Prefixes and state text for toggle buttons and hover texts
main.* Main menu title, body and button labels
list.* Mob list title, body and button labels
tooltips.* Hover texts of the buttons

The main menu shows how many mobs are blocked for natural and non-natural spawns, and has buttons for the mob list, clear-on-disable, debug logging and reload. The mob list has the same two tabs and paging as the inventory menu. Esc closes the dialog.

Both menus take effect immediately and use the same item style (style section in gui/whitelist.yml).

Placeholders

None. ToggleMobSpawn does not register a PlaceholderAPI expansion. The {radius}, {count}, {mob} style tokens in messages.yml are filled in by the plugin itself.

Integrations

None required. The plugin only uses the Paper/Folia API and its own storage backends (YAML, SQLite, MySQL, Redis).

Developer API

The jar ships a small interface, net.spxry.togglemobspawn.api.MobSpawningAPI. Add the jar as a compileOnly dependency to compile against it.

Getting the API

This version does not register the API with the Bukkit ServicesManager and exposes no static accessor, so there is no supported way to obtain an instance yet. The method list below is the interface contract for when it is exposed.

Methods

Signature Description
boolean isToggled(UUID uuid) Whether blocking is on for this player
boolean isToggled(Player player) Same, by player
void setToggled(UUID uuid, boolean toggled) Set blocking on or off
void setToggled(Player player, boolean toggled) Same, by player
boolean toggle(UUID uuid) Flip the state; returns the new state
boolean toggle(Player player) Same, by player
void clearMobs(Player player) Remove blocked mobs near the player
void clearMobs(Player player, int maxEntities) Same, capped at maxEntities removals
int getChunkRadius() Configured chunk radius
void reloadConfig() Reload plugin configuration

Events

The plugin fires no custom events.

FAQ

Why can't players use /mob? Both toggle permissions default to op. Grant togglemobspawn.toggle to the group that should have it.

/mob reload says I have no permission. Reload needs togglemobspawn.reload as well as togglemobspawn.toggle (or togglemobspawn.admin for /mobadmin reload). togglemobspawn.* includes all of them.

Mobs still appear near a player with blocking on. Only types listed in blocked-natural and blocked-non-natural are blocked, and only within chunk-radius chunks of a toggled player. Spawn reasons under spawn-reasons.always-allowed are never blocked. Check both lists, the radius and the spawn reasons.

/mob did not remove the mobs already near me. Only /mobspawn clears nearby mobs, and only when settings.clear-on-disable is true.

Why can't I open vaults? vault-protection stops players with blocking on from opening vaults and cancels vault loot near them. Set vault-protection.enabled to false, or turn off block-loot or block-interact individually.

Blazes from my spawner drop glowstone dust instead of blaze rods. That is blaze-spawner-drops. Lower glowstone-chance or set enabled to false to get normal drops. It applies to every blaze that came from a spawner, whether or not the killer has blocking on.

Does it work on Folia? Yes. Folia is supported.