Fixed blocks broken by portal events not being logged (#45)

This commit is contained in:
Intelli 2021-07-19 16:29:43 -06:00
parent 03bac937c3
commit fae4c9e690

View File

@ -11,6 +11,7 @@ import org.bukkit.event.world.PortalCreateEvent;
import net.coreprotect.config.Config; import net.coreprotect.config.Config;
import net.coreprotect.consumer.Queue; import net.coreprotect.consumer.Queue;
import net.coreprotect.database.Lookup; import net.coreprotect.database.Lookup;
import net.coreprotect.utility.Util;
public final class PortalCreateListener extends Queue implements Listener { 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()) { for (BlockState blockState : event.getBlocks()) {
Material type = blockState.getType(); Material type = blockState.getType();
if (user.equals("#portal") || !type.equals(Material.OBSIDIAN)) { BlockState oldBlock = blockState.getBlock().getState();
Queue.queueBlockPlace(user, blockState, blockState.getBlock().getType(), null, type, -1, 0, blockState.getBlockData().getAsString()); 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());
} }
} }
} }