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:29:51 +01:00
parent 457bf2ffff
commit 511d16f45a
2 changed files with 11 additions and 0 deletions
@@ -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);
}