WorldEdit logging should only log modified blocks

Fixes #757
This commit is contained in:
Brokkonaut
2019-06-23 05:22:18 +02:00
parent e6b0108bc5
commit 9b5e0c9025

View File

@ -81,19 +81,23 @@ public class WorldEditLoggingHook {
return; return;
} }
Location location = new Location(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Location location = BukkitAdapter.adapt(world, pt);
Block origin = location.getBlock(); Block blockBefore = location.getBlock();
Material typeBefore = origin.getType(); BlockData blockDataBefore = blockBefore.getBlockData();
Material typeBefore = blockDataBefore.getMaterial();
BlockData blockDataNew = BukkitAdapter.adapt(block);
if (!blockDataBefore.equals(blockDataNew)) {
// Check to see if we've broken a sign // Check to see if we've broken a sign
if (BlockStateCodecs.hasCodec(typeBefore)) { if (BlockStateCodecs.hasCodec(typeBefore)) {
plugin.getConsumer().queueBlockBreak(lbActor, origin.getState()); plugin.getConsumer().queueBlockBreak(lbActor, blockBefore.getState());
} else if (!origin.isEmpty()) { } else if (!BukkitUtils.isEmpty(typeBefore)) {
plugin.getConsumer().queueBlockBreak(lbActor, location, origin.getBlockData()); plugin.getConsumer().queueBlockBreak(lbActor, location, blockDataBefore);
}
if (!BukkitUtils.isEmpty(blockDataNew.getMaterial())) {
plugin.getConsumer().queueBlockPlace(lbActor, location, blockDataNew);
} }
BlockData newBlock = BukkitAdapter.adapt(block);
if (newBlock != null && !BukkitUtils.isEmpty(newBlock.getMaterial())) {
plugin.getConsumer().queueBlockPlace(lbActor, location, newBlock);
} }
} }
}); });