Improve sign logging

Fixes #407
This commit is contained in:
Brokkonaut
2018-08-01 20:28:21 +02:00
parent 95b7be57fc
commit 37ce2303dc
4 changed files with 14 additions and 11 deletions

View File

@ -128,6 +128,10 @@ public class BlockChange implements LookupCacheElement {
msg.append("stepped on ").append(type.getMaterial().name());
} else if (type.getMaterial() == Material.TRIPWIRE) {
msg.append("ran into ").append(type.getMaterial().name());
} else if (type.getMaterial() == Material.SIGN || type.getMaterial() == Material.WALL_SIGN) {
msg.append("edited a ").append(type.getMaterial().name()).append(" to ").append(typeDetails);
} else {
msg.append("replaced ").append(replaced.getMaterial().name()).append(replacedDetails).append(" with ").append(type.getMaterial().name()).append(typeDetails);
}
} else if (BukkitUtils.isEmpty(type.getMaterial())) {
msg.append("destroyed ").append(replaced.getMaterial().name()).append(replacedDetails);

View File

@ -360,7 +360,7 @@ public class Consumer extends TimerTask {
if ((type.getMaterial() != Material.SIGN && type.getMaterial() != Material.WALL_SIGN) || lines == null || lines.length != 4) {
return;
}
queueBlock(actor, loc, null, type, null, Utils.serializeYamlConfiguration(BlockStateCodecSign.serialize(lines)), null);
queueBlock(actor, loc, type, type, null, Utils.serializeYamlConfiguration(BlockStateCodecSign.serialize(lines)), null);
}
/**

View File

@ -200,6 +200,15 @@ public class WorldEditor implements Runnable {
throw new WorldEditorException("Not enough space left in " + block.getType(), block.getLocation());
}
}
} else if (BlockStateCodecs.hasCodec(replacedBlock.getMaterial())) {
block.setBlockData(replacedBlock);
state = block.getState();
try {
BlockStateCodecs.deserialize(state, replacedState);
state.update();
} catch (Exception e) {
throw new WorldEditorException("Failed to restore blockstate of " + block.getType() + ": " + e, block.getLocation());
}
} else if (!block.getBlockData().equals(replacedBlock)) {
block.setBlockData(replacedBlock);
} else {

View File

@ -13,8 +13,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.inventory.meta.ItemMeta;
import static de.diddiz.LogBlock.config.Config.isLogging;
@ -29,14 +27,6 @@ public class BlockPlaceLogging extends LoggingListener {
final BlockState before = event.getBlockReplacedState();
final BlockState after = event.getBlockPlaced().getState();
final Actor actor = Actor.actorFromEntity(event.getPlayer());
// Sign logging is handled elsewhere
if (Config.isLogging(after.getWorld(), Logging.SIGNTEXT) && (after.getType() == Material.SIGN || after.getType() == Material.WALL_SIGN)) {
ItemMeta inHandMeta = event.getItemInHand() != null ? event.getItemInHand().getItemMeta() : null;
if (!(inHandMeta instanceof BlockStateMeta) || !((BlockStateMeta) inHandMeta).hasBlockState()) {
return;
}
}
LoggingUtil.smartLogBlockPlace(consumer, actor, before, after);
}