mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-04-09 21:46:19 +02:00
Add per-arena setting auto-leave-on-end
.
Introduces a new arena setting to force spectators to leave the arena when the current session ends. If set to `true`, it "overrides" the behavior of `spectate-on-death: true` when players respawn, such that they only become spectators if there is an active arena session. The respawn behavior technically means that it is possible for a player to begin spectating "the next session" if a new session begins between them dying and clicking Respawn on the death screen. Ideally, we would want the player to auto-leave, because the session _they_ participated in ended, but we don't have a concept of "previous sessions", so this quirky behavior will have to do. Closes #682
This commit is contained in:
parent
52226fa1c9
commit
c143cc81c9
@ -14,6 +14,7 @@ These changes will (most likely) be included in the next version.
|
|||||||
### Added
|
### Added
|
||||||
- New monster variant `angry-bees` can be used to spawn angry bees.
|
- New monster variant `angry-bees` can be used to spawn angry bees.
|
||||||
- Pet names are now per-class configurable via the optional `pet-name` property, which defaults to `<display-name>'s pet` (the `<player-name>` variable is also supported).
|
- Pet names are now per-class configurable via the optional `pet-name` property, which defaults to `<display-name>'s pet` (the `<player-name>` variable is also supported).
|
||||||
|
- New per-arena setting `auto-leave-on-end` can be used to automatically "kick" spectators when the current session ends.
|
||||||
- (API) MobArena's internal command handler now supports registering pre-instantiated subcommand instances. This should make it easier for extensions to avoid the Singleton anti-pattern for command dependencies.
|
- (API) MobArena's internal command handler now supports registering pre-instantiated subcommand instances. This should make it easier for extensions to avoid the Singleton anti-pattern for command dependencies.
|
||||||
- (API) MobArena now fires MobArenaPreReloadEvent and MobArenaReloadEvent before and after, respectively, reloading its config-file. This should allow extensions and other plugins to better respond to configuration changes.
|
- (API) MobArena now fires MobArenaPreReloadEvent and MobArenaReloadEvent before and after, respectively, reloading its config-file. This should allow extensions and other plugins to better respond to configuration changes.
|
||||||
|
|
||||||
|
@ -643,6 +643,11 @@ public class ArenaImpl implements Arena
|
|||||||
// Restore enabled status.
|
// Restore enabled status.
|
||||||
enabled = en;
|
enabled = en;
|
||||||
|
|
||||||
|
// Auto-leave
|
||||||
|
if (settings.getBoolean("auto-leave-on-end", false)) {
|
||||||
|
specPlayers.forEach(this::playerLeave);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -903,11 +908,19 @@ public class ArenaImpl implements Arena
|
|||||||
specPlayers.add(p);
|
specPlayers.add(p);
|
||||||
|
|
||||||
if (settings.getBoolean("spectate-on-death", true)) {
|
if (settings.getBoolean("spectate-on-death", true)) {
|
||||||
messenger.tell(p, Msg.SPEC_PLAYER_SPECTATE);
|
// At this point, we know that we want players to become
|
||||||
} else {
|
// spectators when they respawn, but if we also want them
|
||||||
plugin.getServer().getScheduler()
|
// to auto-leave on arena end, we first need to make sure
|
||||||
.scheduleSyncDelayedTask(plugin, () -> playerLeave(p));
|
// the arena is running. If not, the session has probably
|
||||||
|
// ended, so we fall through to schedule an auto-leave.
|
||||||
|
if (!settings.getBoolean("auto-leave-on-end", false) || running) {
|
||||||
|
messenger.tell(p, Msg.SPEC_PLAYER_SPECTATE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.getServer().getScheduler()
|
||||||
|
.scheduleSyncDelayedTask(plugin, () -> playerLeave(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,6 +15,7 @@ pvp-enabled: false
|
|||||||
monster-infight: false
|
monster-infight: false
|
||||||
allow-teleporting: false
|
allow-teleporting: false
|
||||||
spectate-on-death: true
|
spectate-on-death: true
|
||||||
|
auto-leave-on-end: false
|
||||||
share-items-in-arena: true
|
share-items-in-arena: true
|
||||||
min-players: 0
|
min-players: 0
|
||||||
max-players: 0
|
max-players: 0
|
||||||
|
Loading…
Reference in New Issue
Block a user