com.sk89q.worldedit.extension.platform.Actor Java Examples
The following examples show how to use
com.sk89q.worldedit.extension.platform.Actor.
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: ConvexPolyhedralRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public void describeCUI(LocalSession session, Actor player) { checkNotNull(player); checkNotNull(session); Collection<Vector> vertices = region.getVertices(); Collection<Triangle> triangles = region.getTriangles(); Map<Vector, Integer> vertexIds = new HashMap<Vector, Integer>(vertices.size()); int lastVertexId = -1; for (Vector vertex : vertices) { vertexIds.put(vertex, ++lastVertexId); session.dispatchCUIEvent(player, new SelectionPointEvent(lastVertexId, vertex, getArea())); } for (Triangle triangle : triangles) { final int[] v = new int[3]; for (int i = 0; i < 3; ++i) { v[i] = vertexIds.get(triangle.getVertex(i)); } session.dispatchCUIEvent(player, new SelectionPolygonEvent(v)); } }
Example #2
Source File: WorldEditBinding.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
/** * Gets an {@link BaseBlock} from a {@link ArgumentStack}. * * @param context the context * @return a pattern * @throws ParameterException on error * @throws WorldEditException on error */ @BindingMatch(type = BaseBlock.class, behavior = BindingBehavior.CONSUMES, consumedCount = 1) public BaseBlock getBaseBlock(ArgumentStack context) throws ParameterException, WorldEditException { Actor actor = context.getContext().getLocals().get(Actor.class); ParserContext parserContext = new ParserContext(); parserContext.setActor(context.getContext().getLocals().get(Actor.class)); if (actor instanceof Entity) { Extent extent = ((Entity) actor).getExtent(); if (extent instanceof World) { parserContext.setWorld((World) extent); } } parserContext.setSession(worldEdit.getSessionManager().get(actor)); try { return worldEdit.getBlockFactory().parseFromInput(context.next(), parserContext); } catch (NoMatchException e) { throw new ParameterException(e.getMessage(), e); } }
Example #3
Source File: WorldEditBinding.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
/** * Gets an {@link Pattern} from a {@link ArgumentStack}. * * @param context the context * @return a pattern * @throws ParameterException on error * @throws WorldEditException on error */ @BindingMatch(type = Pattern.class, behavior = BindingBehavior.CONSUMES, consumedCount = 1) public Pattern getPattern(ArgumentStack context) throws ParameterException, WorldEditException { Actor actor = context.getContext().getLocals().get(Actor.class); ParserContext parserContext = new ParserContext(); parserContext.setActor(context.getContext().getLocals().get(Actor.class)); if (actor instanceof Entity) { Extent extent = ((Entity) actor).getExtent(); if (extent instanceof World) { parserContext.setWorld((World) extent); } } parserContext.setSession(worldEdit.getSessionManager().get(actor)); try { return worldEdit.getPatternFactory().parseFromInput(context.next(), parserContext); } catch (NoMatchException e) { throw new ParameterException(e.getMessage(), e); } }
Example #4
Source File: WorldEditBinding.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
/** * Gets an {@link Mask} from a {@link ArgumentStack}. * * @param context the context * @return a pattern * @throws ParameterException on error * @throws WorldEditException on error */ @BindingMatch(type = Mask.class, behavior = BindingBehavior.CONSUMES, consumedCount = 1) public Mask getMask(ArgumentStack context) throws ParameterException, WorldEditException { Actor actor = context.getContext().getLocals().get(Actor.class); ParserContext parserContext = new ParserContext(); parserContext.setActor(context.getContext().getLocals().get(Actor.class)); if (actor instanceof Entity) { Extent extent = ((Entity) actor).getExtent(); if (extent instanceof World) { parserContext.setWorld((World) extent); } } parserContext.setSession(worldEdit.getSessionManager().get(actor)); try { return worldEdit.getMaskFactory().parseFromInput(context.next(), parserContext); } catch (NoMatchException e) { throw new ParameterException(e.getMessage(), e); } }
Example #5
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 #6
Source File: BrushProcessor.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
public BrushSettings set(LocalSession session, CommandContext context, Brush brush) throws InvalidToolBindException { CommandLocals locals = context.getLocals(); Actor actor = locals.get(Actor.class); BrushSettings bs = new BrushSettings(); BrushTool tool = session.getBrushTool((Player) actor, false); if (tool != null) { BrushSettings currentContext = tool.getContext(); if (currentContext != null) { Brush currentBrush = currentContext.getBrush(); if (currentBrush != null && currentBrush.getClass() == brush.getClass()) { bs = currentContext; } } } bs.addPermissions(getPermissions()); if (locals != null) { String args = (String) locals.get("arguments"); if (args != null) { bs.addSetting(BrushSettings.SettingType.BRUSH, args.substring(args.indexOf(' ') + 1)); } } return bs.setBrush(brush); }
Example #7
Source File: PolyhedralRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public void describeCUI(LocalSession session, Actor player) { checkNotNull(player); checkNotNull(session); Collection<Vector> vertices = region.getVertices(); Collection<Triangle> triangles = region.getTriangles(); Map<Vector, Integer> vertexIds = new HashMap<Vector, Integer>(vertices.size()); int lastVertexId = -1; for (Vector vertex : vertices) { vertexIds.put(vertex, ++lastVertexId); session.dispatchCUIEvent(player, new SelectionPointEvent(lastVertexId, vertex, getArea())); } for (Triangle triangle : triangles) { final int[] v = new int[3]; for (int i = 0; i < 3; ++i) { v[i] = vertexIds.get(triangle.getVertex(i)); } session.dispatchCUIEvent(player, new SelectionPolygonEvent(v)); } }
Example #8
Source File: WorldEditCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Command( aliases = {"threads"}, usage = "", desc = "Print all thread stacks", min = 0, max = 0 ) @CommandPermissions("worldedit.threads") public void threads(Actor actor) throws WorldEditException { Map<Thread, StackTraceElement[]> stacks = Thread.getAllStackTraces(); for (Map.Entry<Thread, StackTraceElement[]> entry : stacks.entrySet()) { Thread thread = entry.getKey(); actor.printDebug("--------------------------------------------------------------------------------------------"); actor.printDebug("Thread: " + thread.getName() + " | Id: " + thread.getId() + " | Alive: " + thread.isAlive()); for (StackTraceElement elem : entry.getValue()) { actor.printDebug(elem.toString()); } } }
Example #9
Source File: LocalSession.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
/** * Describe the selection to the CUI actor. * * @param actor the actor */ public void describeCUI(Actor actor) { checkNotNull(actor); if (selector instanceof CUIRegion) { CUIRegion tempSel = (CUIRegion) selector; if (tempSel.getProtocolVersion() > cuiVersion) { tempSel.describeLegacyCUI(this, actor); } else { tempSel.describeCUI(this, actor); } } }
Example #10
Source File: PatternCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Command( aliases = {"#spread", "#randomoffset"}, desc = "Randomly spread blocks", usage = "<dx> <dy> <dz> <pattern>", min = 4, max = 4 ) public Pattern spread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) { return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z); }
Example #11
Source File: WorldEditBinding.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
/** * Gets an {@link Actor} from a {@link ArgumentStack}. * * @param context the context * @return a local player * @throws ParameterException on error */ @BindingMatch(type = Actor.class, behavior = BindingBehavior.PROVIDES) public Actor getActor(ArgumentStack context) throws ParameterException { Actor sender = context.getContext().getLocals().get(Actor.class); if (sender == null) { throw new ParameterException("Missing 'Actor'"); } else { return sender; } }
Example #12
Source File: WorldEditBinding.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
/** * Gets an {@link Player} from a {@link ArgumentStack}. * * @param context the context * @return a local player * @throws ParameterException on error */ @BindingMatch(type = Player.class, behavior = BindingBehavior.PROVIDES) public Player getPlayer(ArgumentStack context) throws ParameterException { Actor sender = context.getContext().getLocals().get(Actor.class); if (sender == null) { throw new ParameterException("No player to get a session for"); } else if (sender instanceof Player) { return (Player) sender; } else { throw new ParameterException("Caller is not a player"); } }
Example #13
Source File: BrushProcessor.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public BrushSettings process(CommandLocals locals, BrushSettings settings) throws 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; }
Example #14
Source File: PlotWorldEditListener.java From PlotMe-Core with GNU General Public License v3.0 | 5 votes |
@Subscribe(priority = EventHandler.Priority.VERY_EARLY) public void worldEditListener(EditSessionEvent event) { Actor actor = event.getActor(); if (event.getWorld() == null) { return; } World world1 = PlotMe_CorePlugin.getInstance().getServer().getWorld(event.getWorld().getName()); BukkitWorld adapt = BukkitUtil.adapt(world1); if (PlotMeCoreManager.getInstance().isPlotWorld(adapt)) { if (actor != null && actor.isPlayer()) { event.setExtent(new PlotMeWorldEdit(api, event.getExtent(), event.getActor())); } } }
Example #15
Source File: TransformCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Command( aliases = {"#spread", "#randomoffset"}, desc = "Random offset transform", usage = "<dx> <dy> <dz> [transform]", min = 3, max = 4 ) public ResettableExtent randomoffset(Actor actor, LocalSession session, double x, double y, double z, @Optional("#null") ResettableExtent other) { return new RandomOffsetTransform(other, (int) x, (int) y, (int) z); }
Example #16
Source File: TransformCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Command( aliases = {"#offset"}, desc = "Offset transform", usage = "<dx> <dy> <dz> [transform]", min = 3, max = 4 ) public ResettableExtent offset(Actor actor, LocalSession session, double x, double y, double z, @Optional("#null") ResettableExtent other) { return new OffsetExtent(other, (int) x, (int) y, (int) z); }
Example #17
Source File: TransformCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Command( aliases = {"#linear3d", "#l3d"}, desc = "Use the x,y,z coordinate to pick a transform from the list", usage = "<transform>", min = 1, max = 2 ) public ResettableExtent linear3d(Actor actor, LocalSession session, @Optional("#null") ResettableExtent other) { if (other instanceof RandomTransform) { Set<ResettableExtent> extents = ((RandomTransform) other).getExtents(); return new Linear3DTransform(extents.toArray(new ResettableExtent[extents.size()])); } return other; }
Example #18
Source File: TransformCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Command( aliases = {"#linear", "#l"}, desc = "Sequentially pick from a list of transform", usage = "<transform>", min = 1, max = 2 ) public ResettableExtent linear(Actor actor, LocalSession session, @Optional("#null") ResettableExtent other) { if (other instanceof RandomTransform) { Set<ResettableExtent> extents = ((RandomTransform) other).getExtents(); return new LinearTransform(extents.toArray(new ResettableExtent[extents.size()])); } return other; }
Example #19
Source File: UtilityCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Command( aliases = {"/help"}, usage = "[<command>]", desc = "Displays help for WorldEdit commands", min = 0, max = -1 ) public void help(Actor actor, CommandContext args) throws WorldEditException { help(args, worldEdit, actor); }
Example #20
Source File: LocalSession.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
/** * Send the selection information. * * @param actor the actor */ public void dispatchCUISelection(Actor actor) { checkNotNull(actor); if (selector instanceof CUIRegion) { CUIRegion tempSel = (CUIRegion) selector; if (tempSel.getProtocolVersion() > cuiVersion) { dispatchCUIEvent(actor, new SelectionShapeEvent(tempSel.getLegacyTypeID())); tempSel.describeLegacyCUI(this, actor); } else { dispatchCUIEvent(actor, new SelectionShapeEvent(tempSel.getTypeID())); tempSel.describeCUI(this, actor); } } }
Example #21
Source File: LocalSession.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
/** * Dispatch a CUI event but only if the actor has CUI support. * * @param actor the actor * @param event the event */ public void dispatchCUIEvent(Actor actor, CUIEvent event) { checkNotNull(actor); checkNotNull(event); if (hasCUISupport) { actor.dispatchCUIEvent(event); } else if (actor.isPlayer()) { CUI cui = Fawe.get().getCUI(actor); if (cui != null) cui.dispatchCUIEvent(event); } }
Example #22
Source File: PlotMeWorldEdit.java From PlotMe-Core with GNU General Public License v3.0 | 5 votes |
public PlotMeWorldEdit(PlotMe_Core api, Extent extent, Actor actor) { super(extent); this.api = api; this.extent = extent; this.actor = actor; player = api.getServerBridge().getPlayer(actor.getUniqueId()); }
Example #23
Source File: PatternCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Command( aliases = {"#iddatamask"}, desc = "Use the pattern's id and the existing blocks data with the provided mask", help = "Use the pattern's id and the existing blocks data with the provided mask\n" + " - Use to replace slabs or where the data values needs to be shifted instead of set", usage = "<bitmask=15> <pattern>", min = 2, max = 2 ) public Pattern iddatamask(Actor actor, LocalSession session, Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) { return new IdDataMaskPattern(extent, pattern, bitmask); }
Example #24
Source File: PatternCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Command( aliases = {"#!z", "#nz", "#noz"}, desc = "The pattern will not be provided the z axis info", usage = "<pattern>", min = 1, max = 1 ) public Pattern noz(Actor actor, LocalSession session, Extent extent, Pattern pattern) { return new NoZPattern(pattern); }
Example #25
Source File: PatternCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Command( aliases = {"#linear3d", "#l3d"}, desc = "Use the x,y,z coordinate to pick a block from the list", usage = "<pattern>", min = 1, max = 1 ) public Pattern linear3d(Actor actor, LocalSession session, Pattern other) { if (other instanceof RandomPattern) { Set<Pattern> patterns = ((RandomPattern) other).getPatterns(); return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()])); } return other; }
Example #26
Source File: PatternCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Command( aliases = {"#!y", "#ny", "#noy"}, desc = "The pattern will not be provided the y axis info", usage = "<pattern>", min = 1, max = 1 ) public Pattern noy(Actor actor, LocalSession session, Extent extent, Pattern pattern) { return new NoYPattern(pattern); }
Example #27
Source File: ConvexPolyhedralRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void describeLegacyCUI(LocalSession session, Actor player) { checkNotNull(player); checkNotNull(session); if (isDefined()) { session.dispatchCUIEvent(player, new SelectionPointEvent(0, region.getMinimumPoint(), getArea())); session.dispatchCUIEvent(player, new SelectionPointEvent(1, region.getMaximumPoint(), getArea())); } }
Example #28
Source File: PatternCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Command( aliases = {"#linear", "#l"}, desc = "Sequentially set blocks from a list of patterns", usage = "<pattern>", min = 1, max = 1 ) public Pattern linear(Actor actor, LocalSession session, Pattern other) { if (other instanceof RandomPattern) { Set<Pattern> patterns = ((RandomPattern) other).getPatterns(); return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()])); } return other; }
Example #29
Source File: ConvexPolyhedralRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) { checkNotNull(player); checkNotNull(session); checkNotNull(pos); session.describeCUI(player); BBC.SELECTOR_POS.send(player, region.getVertices().size(), pos, region.getArea()); }
Example #30
Source File: PatternCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Command( aliases = {"#buffer"}, desc = "Only place a block once while a pattern is in use", help = "Only place a block once while a pattern is in use\n" + "Use with a brush when you don't want to apply to the same spot twice", usage = "<pattern>", min = 1, max = 1 ) public Pattern buffer(Actor actor, Pattern pattern) { return new BufferedPattern(FawePlayer.wrap(actor), pattern); }