From 69b31483f49edac7246e41977f7221b32922a70a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 12 Mar 2023 21:04:56 +0100 Subject: [PATCH] Fix -builddestroyonly Trace option Signed-off-by: yoyosource --- .../de/steamwar/bausystem/features/region/TNTListener.java | 3 ++- .../bausystem/features/tracer/record/Recorder.java | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java index 6bb5b15b..958471e2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java @@ -35,6 +35,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent; @@ -83,7 +84,7 @@ public class TNTListener implements Listener { explode(event.blockList(), event.getBlock().getLocation(), null, null); } - @EventHandler + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onExplode(EntityExplodeEvent event) { explode(event.blockList(), event.getLocation(), EventType.TNTExplodeInBuild, event); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java index 2d74492d..fe941f5f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java @@ -32,6 +32,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntitySpawnEvent; @@ -180,7 +181,7 @@ public class Recorder implements Listener { }); } - @EventHandler + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { Entity entity = event.getEntity(); if (!(entity instanceof TNTPrimed)) { @@ -188,7 +189,9 @@ public class Recorder implements Listener { } TraceRecorder traceRecorder = get((TNTPrimed) entity); Region region = tntTraceRecorderMap.get((TNTPrimed) entity); - traceRecorder.explode((TNTPrimed) entity, !event.blockList().isEmpty() && region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)); + boolean inBuildRegion = event.blockList().stream().anyMatch(block -> region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)); + System.out.println(event.blockList() + " " + inBuildRegion); + traceRecorder.explode((TNTPrimed) entity, inBuildRegion); tntTraceRecorderMap.remove(entity); tick(); }