A Paper/Purpur plugin that plays configured music when a player enters WorldGuard regions (regions are typically created/managed using WorldEdit + WorldGuard).
api-version in plugin.yml: 1.21)depend: [WorldGuard])namespace:key)plugins/.plugins/RegionMusic/config.yml, then restart the server.If multiple WorldGuard regions apply at the player's location, the plugin selects the best region like this:
regions.<regionId> in config.yml are considered.priority wins.id (alphabetical order).Music is played for that selected region.
File: plugins/RegionMusic/config.yml
Minimal setup (1 track per region):
regions:
spawn:
sound: "msr:spawn_theme"
category: "MUSIC"
volume: 1.0
pitch: 1.0
stopOnExit: true
You can define a playlist via sounds:. Tracks are played in a shuffled order without repeats until the list is exhausted, then the list is reshuffled.
regions:
spawn:
sounds:
- "msr:spawn_theme"
- "msr:hscene2"
- "msr:hscene3"
category: "MUSIC"
volume: 1.0
pitch: 1.0
stopOnExit: true
Paper/Spigot does not provide a “sound finished” event, so to automatically play the next track you must configure durations.
regions:
spawn:
sounds:
- "msr:spawn_theme"
- "msr:hscene2"
category: "MUSIC"
continuous: true
durations:
"msr:spawn_theme": 2400 # ticks (20 ticks = 1 second)
"msr:hscene2": 1360
gapTicks: 0
stopPreviousOnNext: true
Supported duration options:
durationTicks: default duration for any track in this region (ticks).durationSeconds: same, but in seconds.durations:: a map soundKey -> ticks (overrides the default per track).If durations are inaccurate:
stopPreviousOnNext: true the previous track will be stopped (audible cut).You can force a given track to repeat N times consecutively before advancing to the next one:
regions:
spawn:
sounds:
- "msr:spawn_theme"
- "msr:hscene2"
continuous: true
durations:
"msr:spawn_theme": 2400
"msr:hscene2": 1360
repeats:
"msr:hscene2": 3
Values < 1 are treated as 1.
To prevent region music from overlapping vanilla background music, you can stop the MUSIC category on enter:
regions:
spawn:
stopVanillaMusicOnEnter: true
Notes:
SoundCategory.MUSIC.MUSIC to avoid rare client packet-order races.sound: string - a single track (legacy).sounds: [string] - a list of tracks (recommended).category: string - Bukkit category (MUSIC, RECORDS, ...), default: MUSIC.volume: number - default: 1.0.pitch: number - default: 1.0.stopOnExit: boolean - stop the currently playing track when leaving all configured regions, default: true.stopVanillaMusicOnEnter: boolean - stop SoundCategory.MUSIC when entering, default: true.continuous: boolean - keep playing the playlist while the player stays in the region, default: false.durationTicks: int / durationSeconds: number - default duration for continuous.durations: { "<soundKey>": <ticks> } - per-track durations (ticks).gapTicks: int - silence gap between tracks, default: 0.stopPreviousOnNext: boolean - stop the previous track right before starting the next one, default: true.repeats: { "<soundKey>": <count> } - repeat a specific track N times consecutively.If you use custom sounds like msr:spawn_theme, clients must have a resource pack enabled that contains:
assets/msr/sounds.json (or another namespace instead of msr)assets/msr/sounds/<name>.oggImportant:
.ogg must be Ogg Vorbis (not an MP3 renamed to .ogg).soundKey must be lowercase (Minecraft ResourceLocation rule).Quick client-side test:
/playsound msr:spawn_theme music @s ~ ~ ~ 1 1
If you get silence or an “unknown soundEvent” error, the issue is in the resource pack / key, not the plugin.

A Paper/Purpur plugin that plays configured music when a player enters WorldGuard regions (regions are typically created/managed using WorldEdit + WorldGuard).