forked from LogBlock/LogBlock
cleanup sign logging
This commit is contained in:
@@ -36,7 +36,6 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.block.sign.Side;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -48,7 +47,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
import de.diddiz.LogBlock.EntityChange.EntityChangeType;
|
||||
import de.diddiz.LogBlock.blockstate.BlockStateCodecSign;
|
||||
import de.diddiz.LogBlock.blockstate.BlockStateCodecs;
|
||||
import de.diddiz.LogBlock.config.Config;
|
||||
import de.diddiz.LogBlock.events.BlockChangePreLogEvent;
|
||||
@@ -332,27 +330,6 @@ public class Consumer extends Thread {
|
||||
addQueueLast(new KillRow(location, killer == null ? null : killer, victim, weapon == null ? 0 : MaterialConverter.getOrAddMaterialId(weapon.getType())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an actor placing a sign along with its contents
|
||||
*
|
||||
* @param actor
|
||||
* Actor placing the sign
|
||||
* @param loc
|
||||
* Location of the placed sign
|
||||
* @param type
|
||||
* BlockData of the sign
|
||||
* @param side
|
||||
* @param lines
|
||||
* The four lines on the sign.
|
||||
*/
|
||||
public void queueSignChange(Actor actor, Location loc, BlockState state, Side side, String[] lines) {
|
||||
BlockData type = state.getBlockData();
|
||||
if (!BukkitUtils.isSign(type.getMaterial())) {
|
||||
return;
|
||||
}
|
||||
queueBlock(actor, loc, type, type, null, BlockStateCodecSign.INSTANCE.serialize(state, side, lines), null);
|
||||
}
|
||||
|
||||
public void queueChat(Actor player, String message) {
|
||||
if (!Config.ignoredChat.isEmpty()) {
|
||||
String lowerCaseMessage = message.toLowerCase();
|
||||
|
@@ -638,6 +638,7 @@ class Updater {
|
||||
|
||||
if (configVersion.compareTo(new ComparableVersion("1.13.1")) < 0) {
|
||||
logblock.getLogger().info("Updating tables to 1.13.1 ...");
|
||||
BlockStateCodecSign signCodec = new BlockStateCodecSign();
|
||||
try (Connection conn = logblock.getConnection()) {
|
||||
conn.setAutoCommit(false);
|
||||
final Statement st = conn.createStatement();
|
||||
@@ -675,7 +676,7 @@ class Updater {
|
||||
|
||||
if (!nullBlock && signText != null) {
|
||||
String[] lines = signText.split("\0", 4);
|
||||
byte[] bytes = Utils.serializeYamlConfiguration(BlockStateCodecSign.INSTANCE.serialize(null, Side.FRONT, lines));
|
||||
byte[] bytes = Utils.serializeYamlConfiguration(signCodec.serialize(null, Side.FRONT, lines));
|
||||
|
||||
Material replacedMaterial = MaterialConverter.getBlockData(replaced, -1).getMaterial();
|
||||
Material typeMaterial = MaterialConverter.getBlockData(type, -1).getMaterial();
|
||||
|
@@ -19,9 +19,6 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public class BlockStateCodecSign implements BlockStateCodec {
|
||||
|
||||
public static final BlockStateCodecSign INSTANCE = new BlockStateCodecSign();
|
||||
|
||||
@Override
|
||||
public Material[] getApplicableMaterials() {
|
||||
return BukkitUtils.getAllSignMaterials().toArray(new Material[BukkitUtils.getAllSignMaterials().size()]);
|
||||
@@ -122,6 +119,16 @@ public class BlockStateCodecSign implements BlockStateCodec {
|
||||
signSide.setColor(signColor);
|
||||
signSide.setGlowingText(glowing);
|
||||
}
|
||||
} else {
|
||||
sign.setEditable(true);
|
||||
for (Side side : Side.values()) {
|
||||
SignSide signSide = sign.getSide(side);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
signSide.setLine(i, "");
|
||||
}
|
||||
signSide.setColor(DyeColor.BLACK);
|
||||
signSide.setGlowingText(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ public class BlockStateCodecs {
|
||||
}
|
||||
|
||||
static {
|
||||
registerCodec(BlockStateCodecSign.INSTANCE);
|
||||
registerCodec(new BlockStateCodecSign());
|
||||
registerCodec(new BlockStateCodecSkull());
|
||||
registerCodec(new BlockStateCodecBanner());
|
||||
registerCodec(new BlockStateCodecSpawner());
|
||||
|
@@ -3,6 +3,9 @@ package de.diddiz.LogBlock.listeners;
|
||||
import de.diddiz.LogBlock.Actor;
|
||||
import de.diddiz.LogBlock.LogBlock;
|
||||
import de.diddiz.LogBlock.Logging;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.sign.SignSide;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
@@ -17,7 +20,14 @@ public class SignChangeLogging extends LoggingListener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
if (isLogging(event.getBlock().getWorld(), Logging.SIGNTEXT)) {
|
||||
consumer.queueSignChange(Actor.actorFromEntity(event.getPlayer()), event.getBlock().getLocation(), event.getBlock().getState(), event.getSide(), event.getLines());
|
||||
BlockState newState = event.getBlock().getState();
|
||||
if (newState instanceof Sign sign) {
|
||||
SignSide signSide = sign.getSide(event.getSide());
|
||||
for (int i = 0; i < 4; i++) {
|
||||
signSide.setLine(i, event.getLine(i));
|
||||
}
|
||||
consumer.queueBlockReplace(Actor.actorFromEntity(event.getPlayer()), event.getBlock().getState(), newState);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user