Fixes #972
This commit is contained in:
parent
7997c60db4
commit
a7aef5bfd2
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,14 @@ public class BrushSettings {
|
||||
}
|
||||
|
||||
public BrushSettings setBrush(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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user