Add per-arena setting `monster-teleporting`.

This setting allows server owners to allow arena monsters to teleport
around _while inside the region_. They still can't teleport out of the
region.

Taken at face value, this should just be the default behavior. However,
due to arena regions being boxes, any non-box shaped arena will need a
region that covers more than the physical arena structure, which means
mobs like Endermen will be able to teleport into possibly unreachable
areas of the physical structure. So we have to make do with a setting.

Closes #762
This commit is contained in:
Andreas Troelsen 2023-11-13 16:24:40 +01:00
parent 457bf2ffff
commit 511d16f45a
2 changed files with 11 additions and 0 deletions

View File

@ -14,6 +14,7 @@ These changes will (most likely) be included in the next version.
### Added
- Support for chest references in item syntax. The new `inv` syntax allows for referencing container indices in the config-file. This should help bridge the gap between class chests and various other parts of the config-file, such as rewards and upgrade waves.
- Support for saved items. The new `/ma save-item` command can be used to save the currently held item to disk, which allows it to be used in various places in the config-file. This should help bridge the gap between the config-file and class chests for config-file centric setups.
- New per-arena setting `monster-teleporting` allows monsters to teleport _inside_ the arena region. This should allow for stuff like `/tp` commands and for Endermen to "do their thing".
- New permission `mobarena.admin.errors` for better error visibility. Players with this permission will get a message if an arena encounters an error. Currently, the only such error is the one resulting from Spigot's "max max health" setting throwing an exception when monster health is set "too high".
### Fixed

View File

@ -121,6 +121,7 @@ public class ArenaListener
private boolean lockFoodLevel;
private boolean useClassChests;
private boolean allowTeleport;
private boolean monsterTeleport;
private boolean canShare;
private boolean autoIgniteTNT;
private int autoIgniteFuse;
@ -145,6 +146,7 @@ public class ArenaListener
this.foodRegen = s.getBoolean("food-regen", false);
this.lockFoodLevel = s.getBoolean("lock-food-level", true);
this.allowTeleport = s.getBoolean("allow-teleporting", false);
this.monsterTeleport = s.getBoolean("monster-teleporting", false);
this.canShare = s.getBoolean("share-items-in-arena", true);
this.autoIgniteTNT = s.getBoolean("auto-ignite-tnt", false);
this.autoIgniteFuse = s.getInt("auto-ignite-fuse", 80);
@ -893,6 +895,14 @@ public class ArenaListener
if (monsters.hasPet(event.getEntity()) && region.contains(event.getTo())) {
return;
}
if (isArenaMonster(event.getEntity())) {
if (!monsterTeleport || !region.contains(event.getTo())) {
event.setCancelled(true);
}
return;
}
if (region.contains(event.getFrom()) || region.contains(event.getTo())) {
event.setCancelled(true);
}