From fae4c9e690563151d932ff630f1ad0f0f2493acf Mon Sep 17 00:00:00 2001 From: Intelli Date: Mon, 19 Jul 2021 16:29:43 -0600 Subject: [PATCH] Fixed blocks broken by portal events not being logged (#45) --- .../listener/world/PortalCreateListener.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/coreprotect/listener/world/PortalCreateListener.java b/src/main/java/net/coreprotect/listener/world/PortalCreateListener.java index f39b959..0a7c59b 100644 --- a/src/main/java/net/coreprotect/listener/world/PortalCreateListener.java +++ b/src/main/java/net/coreprotect/listener/world/PortalCreateListener.java @@ -11,6 +11,7 @@ import org.bukkit.event.world.PortalCreateEvent; import net.coreprotect.config.Config; import net.coreprotect.consumer.Queue; import net.coreprotect.database.Lookup; +import net.coreprotect.utility.Util; public final class PortalCreateListener extends Queue implements Listener { @@ -35,8 +36,16 @@ public final class PortalCreateListener extends Queue implements Listener { for (BlockState blockState : event.getBlocks()) { Material type = blockState.getType(); - if (user.equals("#portal") || !type.equals(Material.OBSIDIAN)) { - Queue.queueBlockPlace(user, blockState, blockState.getBlock().getType(), null, type, -1, 0, blockState.getBlockData().getAsString()); + BlockState oldBlock = blockState.getBlock().getState(); + if (oldBlock.equals(blockState)) { + continue; + } + + if (Util.isAir(type)) { + Queue.queueBlockBreak(user, oldBlock, oldBlock.getType(), oldBlock.getBlockData().getAsString(), 0); + } + else { + Queue.queueBlockPlace(user, blockState, oldBlock.getType(), oldBlock, type, -1, 0, blockState.getBlockData().getAsString()); } } }