From aa06bc19d26ac961073c6bda6e5d46472b297bc7 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 15 Apr 2016 06:29:30 +1000 Subject: [PATCH] Workaround for WorldEdit's sign bug --- .../fawe/object/extent/FastWorldEditExtent.java | 9 +++++++-- .../fawe/object/extent/ProcessedWEExtent.java | 11 ++++++++--- .../main/java/com/boydti/fawe/util/MainUtil.java | 13 ++++++++++--- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java b/core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java index 204c1628..cff305c3 100644 --- a/core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java +++ b/core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.extent; import com.boydti.fawe.FaweCache; import com.boydti.fawe.util.FaweQueue; +import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.TaskManager; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.EditSession; @@ -93,6 +94,12 @@ public class FastWorldEditExtent extends FaweExtent { final int y = location.getBlockY(); final int z = location.getBlockZ(); switch (id) { + case 63: + case 68: + if (block.hasNbtData() && !MainUtil.isValidSign(block.getNbtData())) { + queue.setBlock(x, y, z, id, FaweCache.hasData(id) ? (byte) block.getData() : 0); + return true; + } case 54: case 130: case 142: @@ -106,9 +113,7 @@ public class FastWorldEditExtent extends FaweExtent { case 138: case 176: case 177: - case 63: case 119: - case 68: case 323: case 117: case 116: diff --git a/core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java b/core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java index 867ece92..0a53fd05 100644 --- a/core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java +++ b/core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java @@ -5,6 +5,7 @@ import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.util.FaweQueue; +import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.WEManager; import com.sk89q.worldedit.BlockVector; @@ -108,7 +109,13 @@ public class ProcessedWEExtent extends FaweExtent { @Override public boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException { final short id = (short) block.getType(); + boolean nbt = true; switch (id) { + case 63: + case 68: + if (block.hasNbtData() && !MainUtil.isValidSign(block.getNbtData())) { + nbt = false; + } case 54: case 130: case 142: @@ -122,9 +129,7 @@ public class ProcessedWEExtent extends FaweExtent { case 138: case 176: case 177: - case 63: case 119: - case 68: case 323: case 117: case 116: @@ -158,7 +163,7 @@ public class ProcessedWEExtent extends FaweExtent { } return false; } - if (block.hasNbtData()) { + if (block.hasNbtData() && nbt) { final Vector loc = new Vector(location.x, location.y, location.z); queue.addTask(x >> 4, z >> 4, new Runnable() { @Override diff --git a/core/src/main/java/com/boydti/fawe/util/MainUtil.java b/core/src/main/java/com/boydti/fawe/util/MainUtil.java index fb22cadf..d484fd6c 100644 --- a/core/src/main/java/com/boydti/fawe/util/MainUtil.java +++ b/core/src/main/java/com/boydti/fawe/util/MainUtil.java @@ -8,6 +8,7 @@ import com.sk89q.jnbt.EndTag; import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.Tag; import java.io.File; +import java.util.Map; import java.util.Map.Entry; public class MainUtil { @@ -53,12 +54,13 @@ public class MainUtil { if (tag instanceof EndTag) { return false; } - if (tag instanceof ListTag) { - if (((ListTag) tag).getType() == EndTag.class) { + else if (tag instanceof ListTag) { + ListTag lt = (ListTag) tag; + if ((lt).getType() == EndTag.class) { return false; } } - if (tag instanceof CompoundTag) { + else if (tag instanceof CompoundTag) { for (Entry entry : ((CompoundTag) tag).getValue().entrySet()) { if (!isValidTag(entry.getValue())) { return false; @@ -67,4 +69,9 @@ public class MainUtil { } return true; } + + public static boolean isValidSign(CompoundTag tag) { + Map values = tag.getValue(); + return values.size() > 4 && values.containsKey("Text1"); + } }