This commit is contained in:
Jesse Boyd 2018-04-17 06:08:10 +10:00
parent 7997c60db4
commit a7aef5bfd2
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 17 additions and 2 deletions

View File

@ -49,21 +49,29 @@ public class BrushBoundBaseBlock extends BaseBlock implements BrushHolder {
this.session = session;
}
private static final ThreadLocal<Boolean> RECURSION = new ThreadLocal<>();
@Override
public BrushTool getTool() {
if (tool == null && hasNbtData()) {
StringTag json = (StringTag) getNbtData().getValue().get("weBrushJson");
if (json != null) {
try {
if (RECURSION.get() != null) return null;
RECURSION.set(true);
this.tool = BrushTool.fromString(player, session, json.getValue());
this.tool.setHolder(this);
brushCache.put(getKey(item), tool);
} catch (Throwable ignore) {
Fawe.debug("Invalid brush for " + player + " holding " + item + ": " + json.getValue());
ignore.printStackTrace();
Fawe.debug("Invalid brush for " + player + " holding " + item.getType() + ": " + json.getValue());
if (item != null) {
item = Fawe.<FaweBukkit>imp().getItemUtil().setNBT(item, null);
brushCache.remove(getKey(item));
}
} finally {
RECURSION.remove();
}
}
}

View File

@ -121,7 +121,14 @@ public class BrushSettings {
}
public BrushSettings setBrush(Brush brush) {
this.brush = brush;
Brush tmp = this.brush;
if (tmp != brush) {
if (brush == null || (tmp != null && tmp.getClass() != brush.getClass())) {
// clear
clear();
}
this.brush = brush;
}
return this;
}