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;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final ThreadLocal<Boolean> RECURSION = new ThreadLocal<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BrushTool getTool() {
|
public BrushTool getTool() {
|
||||||
if (tool == null && hasNbtData()) {
|
if (tool == null && hasNbtData()) {
|
||||||
StringTag json = (StringTag) getNbtData().getValue().get("weBrushJson");
|
StringTag json = (StringTag) getNbtData().getValue().get("weBrushJson");
|
||||||
if (json != null) {
|
if (json != null) {
|
||||||
try {
|
try {
|
||||||
|
if (RECURSION.get() != null) return null;
|
||||||
|
RECURSION.set(true);
|
||||||
|
|
||||||
this.tool = BrushTool.fromString(player, session, json.getValue());
|
this.tool = BrushTool.fromString(player, session, json.getValue());
|
||||||
this.tool.setHolder(this);
|
this.tool.setHolder(this);
|
||||||
brushCache.put(getKey(item), tool);
|
brushCache.put(getKey(item), tool);
|
||||||
} catch (Throwable ignore) {
|
} 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) {
|
if (item != null) {
|
||||||
item = Fawe.<FaweBukkit>imp().getItemUtil().setNBT(item, null);
|
item = Fawe.<FaweBukkit>imp().getItemUtil().setNBT(item, null);
|
||||||
brushCache.remove(getKey(item));
|
brushCache.remove(getKey(item));
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
RECURSION.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,14 @@ public class BrushSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BrushSettings setBrush(Brush brush) {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user