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();
// Check to see if we've broken a sign BlockData blockDataNew = BukkitAdapter.adapt(block);
if (BlockStateCodecs.hasCodec(typeBefore)) {
plugin.getConsumer().queueBlockBreak(lbActor, origin.getState()); if (!blockDataBefore.equals(blockDataNew)) {
} else if (!origin.isEmpty()) { // Check to see if we've broken a sign
plugin.getConsumer().queueBlockBreak(lbActor, location, origin.getBlockData()); if (BlockStateCodecs.hasCodec(typeBefore)) {
} plugin.getConsumer().queueBlockBreak(lbActor, blockBefore.getState());
BlockData newBlock = BukkitAdapter.adapt(block); } else if (!BukkitUtils.isEmpty(typeBefore)) {
if (newBlock != null && !BukkitUtils.isEmpty(newBlock.getMaterial())) { plugin.getConsumer().queueBlockBreak(lbActor, location, blockDataBefore);
plugin.getConsumer().queueBlockPlace(lbActor, location, newBlock); }
if (!BukkitUtils.isEmpty(blockDataNew.getMaterial())) {
plugin.getConsumer().queueBlockPlace(lbActor, location, blockDataNew);
}
} }
} }
}); });