本文整理汇总了Java中com.sk89q.worldedit.LocalSession类的典型用法代码示例。如果您正苦于以下问题:Java LocalSession类的具体用法?Java LocalSession怎么用?Java LocalSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LocalSession类属于com.sk89q.worldedit包,在下文中一共展示了LocalSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillr
import com.sk89q.worldedit.LocalSession; //导入依赖的package包/类
@Command(
aliases = {"/fillr"},
usage = "<pattern> <radius> [depth]",
desc = "Fill a hole recursively",
min = 2,
max = 3
)
@CommandPermissions("worldedit.fill.recursive")
@Logging(PLACEMENT)
public void fillr(Player player, LocalSession session, EditSession editSession, Pattern pattern, double radius, @Optional("-1") double depth) throws WorldEditException {
worldEdit.checkMaxRadius(radius);
Vector pos = session.getPlacementPosition(player);
if (depth == -1) depth = Integer.MAX_VALUE;
int affected = editSession.fillXZ(pos, pattern, radius, (int) depth, true);
player.print(BBC.getPrefix() + affected + " block(s) have been created.");
}
示例2: 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));
}
示例3: delete
import com.sk89q.worldedit.LocalSession; //导入依赖的package包/类
@Command(aliases = {"delete", "d"}, usage = "<filename>", desc = "Delete a saved schematic", help = "Delete a schematic from the schematic list", min = 1, max = 1)
@CommandPermissions("worldedit.schematic.delete")
public void delete(final Player player, final LocalSession session, final CommandContext args) throws WorldEditException {
final LocalConfiguration config = this.worldEdit.getConfiguration();
final String filename = args.getString(0);
final File dir = this.worldEdit.getWorkingDirectoryFile(config.saveDir);
final File f = this.worldEdit.getSafeSaveFile(player, dir, filename, "schematic", "schematic");
if (!f.exists()) {
player.printError("Schematic " + filename + " does not exist!");
return;
}
if (!f.delete()) {
player.printError("Deletion of " + filename + " failed! Maybe it is read-only.");
return;
}
BBC.FILE_DELETED.send(player, filename);
}
示例4: 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();
}
示例5: chunkInfo
import com.sk89q.worldedit.LocalSession; //导入依赖的package包/类
@Command(
aliases = {"chunkinfo"},
usage = "",
desc = "Get information about the chunk that you are inside",
min = 0,
max = 0
)
@CommandPermissions("worldedit.chunkinfo")
public void chunkInfo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
Vector pos = player.getBlockIn();
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
String folder1 = Integer.toString(MathUtils.divisorMod(chunkX, 64), 36);
String folder2 = Integer.toString(MathUtils.divisorMod(chunkZ, 64), 36);
String filename = "c." + Integer.toString(chunkX, 36)
+ "." + Integer.toString(chunkZ, 36) + ".dat";
player.print(BBC.getPrefix() + "Chunk: " + chunkX + ", " + chunkZ);
player.print(BBC.getPrefix() + "Old format: " + folder1 + "/" + folder2 + "/" + filename);
player.print(BBC.getPrefix() + "McRegion: region/" + McRegionChunkStore.getFilename(
new Vector2D(chunkX, chunkZ)));
}
示例6: 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);
}
示例7: hpos2
import com.sk89q.worldedit.LocalSession; //导入依赖的package包/类
@Command(
aliases = {"/hpos2"},
usage = "",
desc = "Set position 2 to targeted block",
min = 0,
max = 0
)
@CommandPermissions("worldedit.selection.hpos")
public void hpos2(Player player, LocalSession session, CommandContext args) throws WorldEditException {
Vector pos = player.getBlockTrace(300);
if (pos != null) {
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) {
BBC.SELECTOR_ALREADY_SET.send(player);
return;
}
session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos);
} else {
player.printError("No block in sight!");
}
}
示例8: up
import com.sk89q.worldedit.LocalSession; //导入依赖的package包/类
@Command(
aliases = {"up"},
usage = "<number>",
desc = "Go upwards some distance",
flags = "fg",
min = 1,
max = 1
)
@CommandPermissions("worldedit.navigation.up")
@Logging(POSITION)
public void up(Player player, LocalSession session, CommandContext args) throws WorldEditException {
final int distance = args.getInteger(0);
final boolean alwaysGlass = getAlwaysGlass(args);
if (player.ascendUpwards(distance, alwaysGlass)) {
BBC.WHOOSH.send(player);
} else {
BBC.UP_FAIL.send(player);
}
}
示例9: gtransform
import com.sk89q.worldedit.LocalSession; //导入依赖的package包/类
@Command(
aliases = {"/gtransform", "gtransform"},
usage = "[transform]",
desc = "Set the global transform",
min = 0,
max = -1
)
@CommandPermissions("worldedit.global-transform")
public void gtransform(Player player, EditSession editSession, LocalSession session, @Optional CommandContext context) throws WorldEditException {
if (context == null || context.argsLength() == 0) {
session.setTransform(null);
BBC.TRANSFORM_DISABLED.send(player);
} else {
ParserContext parserContext = new ParserContext();
parserContext.setActor(player);
parserContext.setWorld(player.getWorld());
parserContext.setSession(session);
parserContext.setExtent(editSession);
ResettableExtent transform = Fawe.get().getTransformParser().parseFromInput(context.getJoinedStrings(0), parserContext);
session.setTransform(transform);
BBC.TRANSFORM.send(player);
}
}
示例10: outset
import com.sk89q.worldedit.LocalSession; //导入依赖的package包/类
@Command(
aliases = {"/outset"},
usage = "<amount>",
desc = "Outset the selection area",
help =
"Expands the selection by the given amount in all directions.\n" +
"Flags:\n" +
" -h only expand horizontally\n" +
" -v only expand vertically\n",
flags = "hv",
min = 1,
max = 1
)
@Logging(REGION)
@CommandPermissions("worldedit.selection.outset")
public void outset(Player player, LocalSession session, CommandContext args) throws WorldEditException {
Region region = session.getSelection(player.getWorld());
region.expand(getChangesForEachDir(args));
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
BBC.SELECTION_OUTSET.send(player);
}
示例11: copy
import com.sk89q.worldedit.LocalSession; //导入依赖的package包/类
@Command(
aliases = {"copy"},
desc = "Lazily copy chunks to your anvil clipboard"
)
@CommandPermissions("worldedit.anvil.copychunks")
public void copy(Player player, LocalSession session, EditSession editSession, @Selection Region selection) throws WorldEditException {
if (!(selection instanceof CuboidRegion)) {
BBC.NO_REGION.send(player);
return;
}
CuboidRegion cuboid = (CuboidRegion) selection;
String worldName = Fawe.imp().getWorldName(editSession.getWorld());
FaweQueue tmp = SetQueue.IMP.getNewQueue(worldName, true, false);
MCAQueue queue = new MCAQueue(tmp);
Vector origin = session.getPlacementPosition(player);
MCAClipboard clipboard = new MCAClipboard(queue, cuboid, origin);
FawePlayer fp = FawePlayer.wrap(player);
fp.setMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD, clipboard);
BBC.COMMAND_COPY.send(player, selection.getArea());
}
示例12: getExtent
import com.sk89q.worldedit.LocalSession; //导入依赖的package包/类
@BindingMatch(
type = {Extent.class},
behavior = BindingBehavior.PROVIDES
)
public Extent getExtent(ArgumentStack context) throws ParameterException {
Extent extent = context.getContext().getLocals().get(EditSession.class);
if (extent != null) return extent;
extent = Request.request().getExtent();
if (extent != null) return extent;
Actor actor = context.getContext().getLocals().get(Actor.class);
if (actor == null) throw new ParameterException("No player to get a session for");
if (!(actor instanceof Player)) throw new ParameterException("Caller is not a player");
LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
EditSession editSession = session.createEditSession((Player) actor);
editSession.enableQueue();
context.getContext().getLocals().put(EditSession.class, editSession);
session.tellVersion(actor);
return editSession;
}
示例13: command
import com.sk89q.worldedit.LocalSession; //导入依赖的package包/类
@Command(
aliases = {"command", "cmd"},
usage = "<radius> [cmd1;cmd2...]",
desc = "Command brush",
help =
"Run the commands at the clicked position.\n" +
" - Your selection will be expanded to the specified size around each point\n" +
" - Placeholders: {x}, {y}, {z}, {world}, {size}",
min = 2,
max = 99
)
@CommandPermissions("worldedit.brush.command")
public BrushSettings command(Player player, LocalSession session, double radius, CommandContext args, CommandContext context) throws WorldEditException {
String cmd = args.getJoinedStrings(1);
return get(context)
.setBrush(new CommandBrush(cmd, radius))
.setSize(radius);
}
示例14: 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);
}
示例15: rotate
import com.sk89q.worldedit.LocalSession; //导入依赖的package包/类
@Command(
aliases = {"/rotate"},
usage = "<y-axis> [<x-axis>] [<z-axis>]",
desc = "Rotate the contents of the clipboard",
help = "Non-destructively rotate the contents of the clipboard.\n" +
"Angles are provided in degrees and a positive angle will result in a clockwise rotation. " +
"Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.\n"
)
@CommandPermissions("worldedit.clipboard.rotate")
public void rotate(Player player, LocalSession session, Double yRotate, @Optional Double xRotate, @Optional Double zRotate) throws WorldEditException {
ClipboardHolder holder = session.getClipboard();
AffineTransform transform = new AffineTransform();
transform = transform.rotateY(-(yRotate != null ? yRotate : 0));
transform = transform.rotateX(-(xRotate != null ? xRotate : 0));
transform = transform.rotateZ(-(zRotate != null ? zRotate : 0));
holder.setTransform(transform.combine(holder.getTransform()));
BBC.COMMAND_ROTATE.send(player);
if (!FawePlayer.wrap(player).hasPermission("fawe.tips"))
BBC.TIP_FLIP.or(BBC.TIP_DEFORM, BBC.TIP_TRANSFORM).send(player);
}