Java Code Examples for com.sk89q.worldedit.LocalSession#createEditSession()
The following examples show how to use
com.sk89q.worldedit.LocalSession#createEditSession() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FawePrimitiveBinding.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@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; }
Example 2
Source File: SinglePickaxe.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { World world = (World) clicked.getExtent(); final int blockType = world.getBlockType(clicked.toVector()); if (blockType == BlockID.BEDROCK && !player.canDestroyBedrock()) { return true; } EditSession editSession = session.createEditSession(player); editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop); try { if (editSession.setBlock(clicked.getBlockX(), clicked.getBlockY(), clicked.getBlockZ(), EditSession.nullBlock)) { world.playEffect(clicked.toVector(), 2001, blockType); } } finally { editSession.flushQueue(); session.remember(editSession); } return true; }
Example 3
Source File: FloodFillTool.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { World world = (World) clicked.getExtent(); int initialType = world.getBlockType(clicked.toVector()); if (initialType == BlockID.AIR) { return true; } if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) { return true; } EditSession editSession = session.createEditSession(player); try { recurse(server, editSession, world, clicked.toVector().toBlockVector(), clicked.toVector(), range, initialType, new HashSet<BlockVector>()); } catch (WorldEditException e) { throw new RuntimeException(e); } editSession.flushQueue(); session.remember(editSession); return true; }
Example 4
Source File: WorldEditBinding.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
/** * Gets an {@link EditSession} from a {@link ArgumentStack}. * * @param context the context * @return an edit session * @throws ParameterException on other error */ @BindingMatch(type = EditSession.class, behavior = BindingBehavior.PROVIDES) public EditSession getEditSession(ArgumentStack context) throws ParameterException { Player sender = getPlayer(context); LocalSession session = worldEdit.getSessionManager().get(sender); EditSession editSession = session.createEditSession(sender); editSession.enableQueue(); context.getContext().getLocals().put(EditSession.class, editSession); session.tellVersion(sender); return editSession; }
Example 5
Source File: RecursivePickaxe.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { World world = (World) clicked.getExtent(); final Vector pos = clicked.toVector(); EditSession editSession = session.createEditSession(player); BaseBlock block = editSession.getBlock(pos); int initialType = block.getType(); if (initialType == BlockID.AIR || (initialType == BlockID.BEDROCK && !player.canDestroyBedrock())) { editSession.flushQueue(); return true; } editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); final int radius = (int) range; final BlockReplace replace = new BlockReplace(editSession, (editSession.nullBlock)); editSession.setMask((Mask) null); RecursiveVisitor visitor = new RecursiveVisitor(new IdMask(editSession), replace, radius, editSession); visitor.visit(pos); Operations.completeBlindly(visitor); editSession.flushQueue(); session.remember(editSession); return true; }
Example 6
Source File: AreaPickaxe.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { int ox = clicked.getBlockX(); int oy = clicked.getBlockY(); int oz = clicked.getBlockZ(); int initialType = ((World) clicked.getExtent()).getBlockType(clicked.toVector()); if (initialType == 0) { return true; } if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) { return true; } EditSession editSession = session.createEditSession(player); editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); for (int x = ox - range; x <= ox + range; ++x) { for (int z = oz - range; z <= oz + range; ++z) { for (int y = oy + range; y >= oy - range; --y) { if (editSession.getLazyBlock(x, y, z).getId() != initialType) { continue; } editSession.setBlock(x, y, z, air); } } } editSession.flushQueue(); session.remember(editSession); return true; }
Example 7
Source File: LongRangeBuildTool.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) { WorldVectorFace pos = getTargetFace(player); if (pos == null) return false; EditSession eS = session.createEditSession(player); if (secondary.getType() == BlockID.AIR) { eS.setBlockFast(pos, secondary); } else { eS.setBlockFast(pos.getFaceVector(), secondary); } eS.flushQueue(); return true; }
Example 8
Source File: LongRangeBuildTool.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) { WorldVectorFace pos = getTargetFace(player); if (pos == null) return false; EditSession eS = session.createEditSession(player); if (primary.getType() == BlockID.AIR) { eS.setBlockFast(pos, primary); } else { eS.setBlockFast(pos.getFaceVector(), primary); } eS.flushQueue(); return true; }