Don't kill owned road entities (leashed / named) (#3829)

This commit is contained in:
BlockyTheDev 2022-10-10 18:41:25 +02:00 committed by GitHub
parent 3effaefda7
commit d5445cfbef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -849,11 +849,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
// managed elsewhere // managed elsewhere
continue; continue;
case "SHULKER": case "SHULKER":
if (Settings.Enabled_Components.KILL_ROAD_MOBS) { if (Settings.Enabled_Components.KILL_ROAD_MOBS && (Settings.Enabled_Components.KILL_NAMED_ROAD_MOBS || entity.getCustomName() == null)) {
LivingEntity livingEntity = (LivingEntity) entity; LivingEntity livingEntity = (LivingEntity) entity;
List<MetadataValue> meta = entity.getMetadata("shulkerPlot"); List<MetadataValue> meta = entity.getMetadata("shulkerPlot");
if (!meta.isEmpty()) { if (!meta.isEmpty()) {
if (livingEntity.isLeashed()) { if (livingEntity.isLeashed() && !Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS) {
continue; continue;
} }
List<MetadataValue> keep = entity.getMetadata("keep"); List<MetadataValue> keep = entity.getMetadata("keep");
@ -973,7 +973,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|| !entity.hasMetadata("keep")) { || !entity.hasMetadata("keep")) {
Entity passenger = entity.getPassenger(); Entity passenger = entity.getPassenger();
if ((Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS if ((Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS
|| !(passenger instanceof Player)) && entity.getMetadata("keep").isEmpty()) { || !((passenger instanceof Player) || livingEntity.isLeashed()))
&& (Settings.Enabled_Components.KILL_NAMED_ROAD_MOBS || entity.getCustomName() == null)
&& entity.getMetadata("keep").isEmpty()) {
if (entity.hasMetadata("ps-tmp-teleport")) { if (entity.hasMetadata("ps-tmp-teleport")) {
continue; continue;
} }
@ -983,8 +985,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
} }
} else { } else {
Entity passenger = entity.getPassenger(); Entity passenger = entity.getPassenger();
if ((Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS if ((Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS || !(passenger instanceof Player))
|| !(passenger instanceof Player)) && entity.getMetadata("keep").isEmpty()) { && (Settings.Enabled_Components.KILL_NAMED_ROAD_MOBS && entity.getCustomName() != null)
&& entity.getMetadata("keep").isEmpty()) {
if (entity.hasMetadata("ps-tmp-teleport")) { if (entity.hasMetadata("ps-tmp-teleport")) {
continue; continue;
} }

View File

@ -759,6 +759,8 @@ public class Settings extends Config {
@Comment("Also kill any road mobs that are being ridden, or are leashed") @Comment("Also kill any road mobs that are being ridden, or are leashed")
public static boolean public static boolean
KILL_OWNED_ROAD_MOBS = false; KILL_OWNED_ROAD_MOBS = false;
@Comment("Also kill any road mobs that are named")
public static boolean KILL_NAMED_ROAD_MOBS = false;
@Comment("Kill items on roads (Stick, Paper, etc.)") @Comment("Kill items on roads (Stick, Paper, etc.)")
public static boolean KILL_ROAD_ITEMS = false; public static boolean KILL_ROAD_ITEMS = false;
@Comment("Kill vehicles on roads (Boat, Minecart, etc.)") @Comment("Kill vehicles on roads (Boat, Minecart, etc.)")