From d5445cfbef50fa505ef3748c113058333d2271f0 Mon Sep 17 00:00:00 2001 From: BlockyTheDev <86119630+BlockyTheDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 18:41:25 +0200 Subject: [PATCH] Don't kill owned road entities (leashed / named) (#3829) --- .../java/com/plotsquared/bukkit/BukkitPlatform.java | 13 ++++++++----- .../plotsquared/core/configuration/Settings.java | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index b19130c1c..b44707348 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -849,11 +849,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl // managed elsewhere continue; 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; List meta = entity.getMetadata("shulkerPlot"); if (!meta.isEmpty()) { - if (livingEntity.isLeashed()) { + if (livingEntity.isLeashed() && !Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS) { continue; } List keep = entity.getMetadata("keep"); @@ -973,7 +973,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl || !entity.hasMetadata("keep")) { Entity passenger = entity.getPassenger(); 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")) { continue; } @@ -983,8 +985,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl } } else { Entity passenger = entity.getPassenger(); - if ((Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS - || !(passenger instanceof Player)) && entity.getMetadata("keep").isEmpty()) { + if ((Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS || !(passenger instanceof Player)) + && (Settings.Enabled_Components.KILL_NAMED_ROAD_MOBS && entity.getCustomName() != null) + && entity.getMetadata("keep").isEmpty()) { if (entity.hasMetadata("ps-tmp-teleport")) { continue; } diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java index 4e5ac9bc5..025c779ee 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java @@ -759,6 +759,8 @@ public class Settings extends Config { @Comment("Also kill any road mobs that are being ridden, or are leashed") public static boolean 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.)") public static boolean KILL_ROAD_ITEMS = false; @Comment("Kill vehicles on roads (Boat, Minecart, etc.)")