本文整理汇总了Java中com.sk89q.worldedit.LocalSession.getBrushTool方法的典型用法代码示例。如果您正苦于以下问题:Java LocalSession.getBrushTool方法的具体用法?Java LocalSession.getBrushTool怎么用?Java LocalSession.getBrushTool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sk89q.worldedit.LocalSession
的用法示例。
在下文中一共展示了LocalSession.getBrushTool方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: primary
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
aliases = {"primary"},
usage = "[brush-arguments]",
desc = "Set the right click brush",
help = "Set the right click brush",
min = 1
)
public void primary(Player player, LocalSession session, CommandContext args) throws WorldEditException {
BaseBlock item = player.getBlockInHand();
BrushTool tool = session.getBrushTool(player, false);
session.setTool(item, null, player);
String cmd = "brush " + args.getJoinedStrings(0);
CommandEvent event = new CommandEvent(player, cmd);
CommandManager.getInstance().handleCommandOnCurrentThread(event);
BrushTool newTool = session.getBrushTool(item, player, false);
if (newTool != null && tool != null) {
newTool.setSecondary(tool.getSecondary());
}
}
示例2: secondary
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
aliases = {"secondary"},
usage = "[brush-arguments]",
desc = "Set the left click brush",
help = "Set the left click brush",
min = 1
)
public void secondary(Player player, LocalSession session, CommandContext args) throws WorldEditException {
BaseBlock item = player.getBlockInHand();
BrushTool tool = session.getBrushTool(player, false);
session.setTool(item, null, player);
String cmd = "brush " + args.getJoinedStrings(0);
CommandEvent event = new CommandEvent(player, cmd);
CommandManager.getInstance().handleCommandOnCurrentThread(event);
BrushTool newTool = session.getBrushTool(item, player, false);
if (newTool != null && tool != null) {
newTool.setPrimary(tool.getPrimary());
}
}
示例3: visual
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
aliases = {"visualize", "visual", "vis"},
usage = "[mode=0]",
desc = "Toggle between different visualization modes",
help = "Toggle between different visualization modes\n" +
"0 = No visualization\n" +
"1 = Single block at target position\n" +
"2 = Glass showing what blocks will be changed",
min = 0,
max = 1
)
public void visual(Player player, LocalSession session, @Range(min = 0, max = 2)int mode) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
BBC.BRUSH_NONE.send(player);
return;
}
VisualMode[] modes = VisualMode.values();
VisualMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
tool.setVisualMode(player, newMode);
BBC.BRUSH_VISUAL_MODE_SET.send(player, newMode);
}
示例4: target
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
aliases = {"target", "tar"},
usage = "[mode]",
desc = "Toggle between different target modes",
min = 0,
max = 1
)
public void target(Player player, LocalSession session, @Optional("0") int mode) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
BBC.BRUSH_NONE.send(player);
return;
}
TargetMode[] modes = TargetMode.values();
TargetMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
tool.setTargetMode(newMode);
BBC.BRUSH_TARGET_MODE_SET.send(player, newMode);
}
示例5: targetMask
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
aliases = {"targetmask", "tarmask", "tm"},
usage = "[mask]",
desc = "Set the targeting mask",
min = 1,
max = -1
)
public void targetMask(Player player, EditSession editSession, LocalSession session, CommandContext context) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
BBC.BRUSH_NONE.send(player);
return;
}
ParserContext parserContext = new ParserContext();
parserContext.setActor(player);
parserContext.setWorld(player.getWorld());
parserContext.setSession(session);
parserContext.setExtent(editSession);
Mask mask = worldEdit.getMaskFactory().parseFromInput(context.getJoinedStrings(0), parserContext);
tool.setTargetMask(mask);
BBC.BRUSH_TARGET_MASK_SET.send(player, context.getJoinedStrings(0));
}
示例6: targetOffset
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
aliases = {"targetoffset", "to"},
usage = "[mask]",
desc = "Set the targeting mask",
min = 1,
max = -1
)
public void targetOffset(Player player, EditSession editSession, LocalSession session, int offset) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
BBC.BRUSH_NONE.send(player);
return;
}
tool.setTargetOffset(offset);
BBC.BRUSH_TARGET_OFFSET_SET.send(player, offset);
}
示例7: scroll
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
aliases = {"scroll"},
usage = "[none|clipboard|mask|pattern|range|size|visual|target]",
desc = "Toggle between different target modes",
min = 1,
max = -1
)
public void scroll(Player player, EditSession editSession, LocalSession session, @Optional @Switch('h') boolean offHand, CommandContext args) throws WorldEditException {
BrushTool bt = session.getBrushTool(player, false);
if (bt == null) {
BBC.BRUSH_NONE.send(player);
return;
}
BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext();
ScrollAction action = ScrollAction.fromArguments(bt, player, session, args.getJoinedStrings(0), true);
settings.setScrollAction(action);
if (args.getString(0).equalsIgnoreCase("none")) {
BBC.BRUSH_SCROLL_ACTION_UNSET.send(player);
} else if (action != null) {
String full = args.getJoinedStrings(0);
settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, full);
BBC.BRUSH_SCROLL_ACTION_SET.send(player, full);
}
bt.update();
}
示例8: material
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
aliases = {"mat", "material"},
usage = "[pattern]",
desc = "Set the brush material",
min = 1,
max = 1
)
@CommandPermissions("worldedit.brush.options.material")
public void material(Player player, EditSession editSession, LocalSession session, Pattern pattern, @Switch('h') boolean offHand, CommandContext context) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(BBC.getPrefix() + BBC.BRUSH_NONE.f());
return;
}
if (context.argsLength() == 0) {
BBC.BRUSH_TRANSFORM_DISABLED.send(player);
tool.setFill(null);
return;
}
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
settings.setFill(pattern);
settings.addSetting(BrushSettings.SettingType.FILL, context.getString(context.argsLength() - 1));
tool.update();
BBC.BRUSH_MATERIAL.send(player);
}
示例9: size
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
aliases = {"size"},
usage = "[pattern]",
desc = "Set the brush size",
min = 1,
max = 1
)
@CommandPermissions("worldedit.brush.options.size")
public void size(Player player, LocalSession session, CommandContext args, @Switch('h') boolean offHand) throws WorldEditException {
int radius = args.getInteger(0);
worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(BBC.getPrefix() + BBC.BRUSH_NONE.f());
return;
}
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
settings.setSize(radius);
tool.update();
BBC.BRUSH_SIZE.send(player);
}
示例10: saveBrush
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
aliases = {"savebrush", "save"},
usage = "[name]",
desc = "Save your current brush",
help = "Save your current brush\n" +
"use the -g flag to save globally",
min = 1
)
@CommandPermissions("worldedit.brush.save")
public void saveBrush(Player player, LocalSession session, String name, @Switch('g') boolean root) throws WorldEditException, IOException {
BrushTool tool = session.getBrushTool(player);
if (tool != null) {
root |= name.startsWith("../");
name = FileSystems.getDefault().getPath(name).getFileName().toString();
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
name = name.endsWith(".jsgz") ? name : name + ".jsgz";
File file;
if (root && player.hasPermission("worldedit.brush.save.other")) {
file = new File(folder, name);
} else {
file = new File(folder, player.getUniqueId() + File.separator + name);
}
File parent = file.getParentFile();
if (!parent.exists()) {
parent.mkdirs();
}
file.createNewFile();
try (DataOutputStream out = new DataOutputStream(new PGZIPOutputStream(new FileOutputStream(file)))) {
out.writeUTF(tool.toString());
} catch (Throwable e) {
e.printStackTrace();
}
BBC.SCHEMATIC_SAVED.send(player, name);
} else {
BBC.BRUSH_NONE.send(player);
}
}
示例11: smask
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
aliases = {"smask", "/smask", "/sourcemask", "sourcemask"},
usage = "[mask]",
desc = "Set the brush source mask",
help = "Set the brush source mask",
min = 0,
max = -1
)
@CommandPermissions("worldedit.brush.options.mask")
public void smask(Player player, LocalSession session, EditSession editSession, @Optional @Switch('h') boolean offHand, CommandContext context) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(BBC.getPrefix() + BBC.BRUSH_NONE.f());
return;
}
if (context.argsLength() == 0) {
BBC.BRUSH_SOURCE_MASK_DISABLED.send(player);
tool.setSourceMask(null);
return;
}
ParserContext parserContext = new ParserContext();
parserContext.setActor(player);
parserContext.setWorld(player.getWorld());
parserContext.setSession(session);
parserContext.setExtent(editSession);
Mask mask = worldEdit.getMaskFactory().parseFromInput(context.getJoinedStrings(0), parserContext);
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, context.getString(context.argsLength() - 1));
settings.setSourceMask(mask);
tool.update();
BBC.BRUSH_SOURCE_MASK.send(player);
}
示例12: process
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Override
public BrushSettings process(CommandLocals locals, BrushSettings settings) throws Command.CommandException, WorldEditException {
Actor actor = locals.get(Actor.class);
LocalSession session = worldEdit.getSessionManager().get(actor);
session.setTool(null, (Player) actor);
BrushTool tool = session.getBrushTool((Player) actor);
if (tool != null) {
tool.setPrimary(settings);
tool.setSecondary(settings);
BBC.BRUSH_EQUIPPED.send(actor, ((String) locals.get("arguments")).split(" ")[1]);
}
return null;
}