Do not remove entitys with CUSTOM spawn-reason on CreatureSpawnEvent. (#4297)

Do not remove entitys with CUSTOM spawn-reason.
This commit is contained in:
Nico Lube 2024-01-21 12:33:53 +01:00 committed by GitHub
parent a1d94af242
commit fccc146053
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -779,6 +779,10 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
Iterator<Entity> iterator = entities.iterator(); Iterator<Entity> iterator = entities.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Entity entity = iterator.next(); Entity entity = iterator.next();
final String spawnReason = entity.getEntitySpawnReason().name();
if ("CUSTOM".equals(spawnReason)) {
continue;
}
switch (entity.getType().toString()) { switch (entity.getType().toString()) {
case "EGG": case "EGG":
case "FISHING_HOOK": case "FISHING_HOOK":
@ -867,8 +871,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
if (livingEntity.isLeashed() && !Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS) { if (livingEntity.isLeashed() && !Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS) {
continue; continue;
} }
List<MetadataValue> keep = entity.getMetadata("keep"); if (entity.hasMetadata("keep")) {
if (!keep.isEmpty()) {
continue; continue;
} }

View File

@ -120,7 +120,10 @@ public class EntitySpawnListener implements Listener {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
Location location = BukkitUtil.adapt(entity.getLocation()); Location location = BukkitUtil.adapt(entity.getLocation());
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
if (!location.isPlotArea()) { if (!location.isPlotArea() || area == null) {
return;
}
if (area.isSpawnCustom() && "CUSTOM".equals(entity.getEntitySpawnReason().name())) {
return; return;
} }
Plot plot = location.getOwnedPlotAbs(); Plot plot = location.getOwnedPlotAbs();