本文整理汇总了Java中com.sk89q.worldedit.EditSession类的典型用法代码示例。如果您正苦于以下问题:Java EditSession类的具体用法?Java EditSession怎么用?Java EditSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EditSession类属于com.sk89q.worldedit包,在下文中一共展示了EditSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.sk89q.worldedit.EditSession; //导入依赖的package包/类
protected void execute(Event event) {
String name = (String) this.name.getSingle(event);
World world = (World) this.world.getSingle(event);
ItemStack block = (ItemStack) this.block.getSingle(event);
RegionManager regionManager = WGBukkit.getRegionManager((org.bukkit.World) world);
if (!regionManager.hasRegion(name)) {
Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
return;
}
Vector v1 = regionManager.getRegion(name).getMaximumPoint();
Vector v2 = regionManager.getRegion(name).getMinimumPoint();
Region region = new CuboidRegion(v1, v2);
BaseBlock b = new BaseBlock(block.getTypeId(), block.getData().getData());
EditSession es = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
try {
es.setBlocks(region, b);
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: build
import com.sk89q.worldedit.EditSession; //导入依赖的package包/类
/**
* Build the operation.
*
* @return the operation
*/
public Operation build() {
Extent extent = clipboard;
if (!transform.isIdentity()) {
extent = new BlockTransformExtent(extent, transform, targetWorldData.getBlockRegistry());
}
ForwardExtentCopy copy = new ForwardExtentCopy(extent, clipboard.getRegion(), clipboard.getOrigin(), targetExtent, to);
copy.setTransform(transform);
copy.setCopyEntities(!ignoreEntities);
copy.setCopyBiomes((!ignoreBiomes) && (!(clipboard instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP.hasBiomes()));
if (this.canApply != null) {
copy.setFilterFunction(this.canApply);
}
if (targetExtent instanceof EditSession) {
Mask sourceMask = ((EditSession) targetExtent).getSourceMask();
if (sourceMask != null) {
new MaskTraverser(sourceMask).reset(extent);
copy.setSourceMask(sourceMask);
((EditSession) targetExtent).setSourceMask(null);
}
}
if (ignoreAirBlocks) {
copy.setSourceMask(new ExistingBlockMask(clipboard));
}
return copy;
}
示例3: catenaryBrush
import com.sk89q.worldedit.EditSession; //导入依赖的package包/类
@Command(
aliases = {"catenary", "cat", "gravityline", "saggedline"},
usage = "<pattern> [lengthFactor=1.2] [size=0]",
desc = "Create a hanging line between two points",
help = "Create a hanging line between two points.\n" +
"The lengthFactor controls how long the line is\n" +
"The -h flag creates only a shell\n" +
"The -s flag selects the clicked point after drawing\n",
min = 1,
max = 3
)
@CommandPermissions("worldedit.brush.spline")
public BrushSettings catenaryBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, @Optional("1.2") @Range(min=1) double lengthFactor, @Optional("0") double radius, @Switch('h') boolean shell, @Switch('s') boolean select, CommandContext context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
return get(context)
.setBrush(new CatenaryBrush(shell, select, lengthFactor))
.setSize(radius)
.setFill(fill);
}
示例4: targetMask
import com.sk89q.worldedit.EditSession; //导入依赖的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));
}
示例5: targetOffset
import com.sk89q.worldedit.EditSession; //导入依赖的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);
}
示例6: pyramid
import com.sk89q.worldedit.EditSession; //导入依赖的package包/类
@Command(
aliases = {"/pyramid"},
usage = "<pattern> <size>",
flags = "h",
desc = "Generate a filled pyramid",
min = 2,
max = 2
)
@CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT)
public void pyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
fp.checkConfirmationRadius(getArguments(context), size);
Vector pos = session.getPlacementPosition(player);
worldEdit.checkMaxRadius(size);
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
player.findFreePosition();
BBC.VISITOR_BLOCK.send(fp, affected);
}
示例7: replace
import com.sk89q.worldedit.EditSession; //导入依赖的package包/类
@Command(
aliases = {"/replace", "/re", "/rep", "/r"},
usage = "[from-mask] <to-pattern>",
desc = "Replace all blocks in the selection with another",
flags = "f",
min = 1,
max = 2
)
@CommandPermissions("worldedit.region.replace")
@Logging(REGION)
public void replace(FawePlayer player, EditSession editSession, @Selection Region region, @Optional Mask from, Pattern to, CommandContext context) throws WorldEditException {
player.checkConfirmationRegion(getArguments(context), region);
if (from == null) {
from = new ExistingBlockMask(editSession);
}
int affected = editSession.replaceBlocks(region, from, to);
BBC.VISITOR_BLOCK.send(player, affected);
if (!player.hasPermission("fawe.tips"))
BBC.TIP_REPLACE_ID.or(BBC.TIP_REPLACE_LIGHT, BBC.TIP_REPLACE_MARKER, BBC.TIP_TAB_COMPLETE).send(player);
}
示例8: thaw
import com.sk89q.worldedit.EditSession; //导入依赖的package包/类
@Command(
aliases = {"/thaw", "thaw"},
usage = "[radius]",
desc = "Thaws the area",
min = 0,
max = 1
)
@CommandPermissions("worldedit.thaw")
@Logging(PLACEMENT)
public void thaw(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
int affected = editSession.thaw(session.getPlacementPosition(player), size);
player.print(BBC.getPrefix() + affected + " surfaces thawed.");
}
示例9: swap
import com.sk89q.worldedit.EditSession; //导入依赖的package包/类
@Override
public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) {
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
EditSession sessionA = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession sessionB = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
CuboidRegion regionA = new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ()));
CuboidRegion regionB = new CuboidRegion(new Vector(pos3.getX(), pos3.getY(), pos3.getZ()), new Vector(pos4.getX(), pos4.getY(), pos4.getZ()));
ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, sessionB, regionB.getMinimumPoint());
ForwardExtentCopy copyB = new ForwardExtentCopy(sessionB, regionB, sessionA, regionA.getMinimumPoint());
try {
Operations.completeLegacy(copyA);
Operations.completeLegacy(copyB);
sessionA.flushQueue();
sessionB.flushQueue();
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
}
TaskManager.IMP.task(whenDone);
}
});
}
示例10: gtransform
import com.sk89q.worldedit.EditSession; //导入依赖的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);
}
}
示例11: material
import com.sk89q.worldedit.EditSession; //导入依赖的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);
}
示例12: recursiveBrush
import com.sk89q.worldedit.EditSession; //导入依赖的package包/类
@Command(
aliases = {"recursive", "recurse", "r"},
usage = "<pattern-to> [radius=5]",
desc = "Set all connected blocks",
help = "Set all connected blocks\n" +
"The -d flag Will apply in depth first order\n" +
"Note: Set a mask to recurse along specific blocks",
min = 0,
max = 3
)
@CommandPermissions("worldedit.brush.recursive")
public BrushSettings recursiveBrush(Player player, LocalSession session, EditSession editSession, Pattern fill, @Optional("5") double radius, @Switch('d') boolean depthFirst, CommandContext context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
return get(context)
.setBrush(new RecurseBrush(depthFirst))
.setSize(radius)
.setFill(fill)
.setMask(new IdMask(editSession));
}
示例13: execute
import com.sk89q.worldedit.EditSession; //导入依赖的package包/类
@Override
public boolean execute(final FawePlayer player, final String... args) {
if (player == null) {
return false;
}
UUID uuid = player.getUUID();
Collection<FaweQueue> queues = SetQueue.IMP.getAllQueues();
int cancelled = 0;
player.clearActions();
for (FaweQueue queue : queues) {
Collection<EditSession> sessions = queue.getEditSessions();
for (EditSession session : sessions) {
FawePlayer currentPlayer = session.getPlayer();
if (currentPlayer == player) {
if (session.cancel()) {
cancelled++;
}
}
}
}
BBC.WORLDEDIT_CANCEL_COUNT.send(player, cancelled);
return true;
}
示例14: replace
import com.sk89q.worldedit.EditSession; //导入依赖的package包/类
@Command(
aliases = {"replace", "r"},
usage = "[from-block] <to-block>",
desc = "Replace all blocks in the selection with another"
)
@CommandPermissions("worldedit.anvil.replace")
public void replace(Player player, EditSession editSession, @Selection Region selection, @Optional String from, String to, @Switch('d') boolean useData) throws WorldEditException {
final FaweBlockMatcher matchFrom;
if (from == null) {
matchFrom = FaweBlockMatcher.NOT_AIR;
} else {
matchFrom = FaweBlockMatcher.fromBlocks(worldEdit.getBlocks(player, from, true), useData || from.contains(":"));
}
final FaweBlockMatcher matchTo = FaweBlockMatcher.setBlocks(worldEdit.getBlocks(player, to, true));
ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo);
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
if (result != null) {
player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
}
}
示例15: build
import com.sk89q.worldedit.EditSession; //导入依赖的package包/类
@Override
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
int radius = (int) size;
CuboidRegionSelector selector = new CuboidRegionSelector(editSession.getWorld(), position.subtract(radius, radius, radius), position.add(radius, radius, radius));
String replaced = command.replace("{x}", position.getBlockX() + "")
.replace("{y}", Integer.toString(position.getBlockY()))
.replace("{z}", Integer.toString(position.getBlockZ()))
.replace("{world}", editSession.getQueue().getWorldName())
.replace("{size}", Integer.toString(radius));
FawePlayer fp = editSession.getPlayer();
Player player = fp.getPlayer();
WorldVectorFace face = player.getBlockTraceFace(256, true);
if (face == null) {
position = position.add(0, 1, 1);
} else {
position = face.getFaceVector();
}
fp.setSelection(selector);
PlayerWrapper wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(player, new Location(player.getExtent(), position)));
List<String> cmds = StringMan.split(replaced, ';');
for (String cmd : cmds) {
CommandEvent event = new CommandEvent(wePlayer, cmd);
CommandManager.getInstance().handleCommandOnCurrentThread(event);
}
}