use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.
the class ToolUtilCommands method primary.
// FAWE start
@Command(name = "primary", aliases = { "/primary" }, desc = "Set the right click brush", descFooter = "Set the right click brush")
@CommandPermissions("worldedit.brush.primary")
public void primary(Player player, LocalSession session, @Arg(desc = "The brush command", variable = true) List<String> commandStr) throws WorldEditException {
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
BrushTool tool = session.getBrushTool(player, false);
session.setTool(item, null, player);
String cmd = "brush " + StringMan.join(commandStr, " ");
CommandEvent event = new CommandEvent(player, cmd);
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
BrushTool newTool = session.getBrushTool(item, player, false);
if (newTool != null && tool != null) {
newTool.setSecondary(tool.getSecondary());
}
}
use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCache method getTool.
public static BrushTool getTool(Player player, LocalSession session, BaseItem item) {
if (!item.hasNbtData()) {
return null;
}
Object key = getKey(item);
if (key == null) {
return null;
}
BrushTool cached = brushCache.get(key);
if (cached != null) {
return cached;
}
CompoundTag nbt = item.getNbtData();
if (nbt == null) {
return null;
}
StringTag json = (StringTag) nbt.getValue().get("weBrushJson");
/* if (json != null) {
try {
if (RECURSION.get() != null) return null;
RECURSION.set(true);
BrushTool tool = BrushTool.fromString(player, session, json.getValue());
tool.setHolder(item);
brushCache.put(key, tool);
return tool;
} catch (Exception throwable) {
getLogger(BrushCache.class).debug("Invalid brush for " + player + " holding " + item.getType() + ": " + json.getValue(), throwable);
item.setNbtData(null);
brushCache.remove(key);
} finally {
RECURSION.remove();
}
}*/
return null;
}
Aggregations