Class AbstractPlayerActor

java.lang.Object
com.sk89q.worldedit.extension.platform.AbstractPlayerActor
All Implemented Interfaces:
Entity, Player, Actor, Locatable, SessionOwner, Subject, Faceted, Identifiable, Cloneable

public abstract class AbstractPlayerActor extends Object implements Actor, Player, Cloneable
An abstract implementation of both a Actor and a Player that is intended for implementations of WorldEdit to use to wrap players that make use of WorldEdit.
  • Constructor Details

    • AbstractPlayerActor

      public AbstractPlayerActor()
  • Method Details

    • getExtent

      public final Extent getExtent()
      Description copied from interface: Locatable
      Get the extent that this actor is in.
      Specified by:
      getExtent in interface Locatable
      Returns:
      the extent
    • isHoldingPickAxe

      public boolean isHoldingPickAxe()
      Description copied from interface: Player
      Returns true if the entity is holding a pick axe.
      Specified by:
      isHoldingPickAxe in interface Player
      Returns:
      whether a pick axe is held
    • findFreePosition

      public void findFreePosition(Location searchPos)
      Description copied from interface: Player
      Find a position for the actor to stand that is not inside a block. Blocks above the player will be iteratively tested until there is a series of two free blocks. The actor will be teleported to that free position.
      Specified by:
      findFreePosition in interface Player
      Parameters:
      searchPos - search position
    • setOnGround

      public void setOnGround(Location searchPos)
      Description copied from interface: Player
      Set the actor on the ground.
      Specified by:
      setOnGround in interface Player
      Parameters:
      searchPos - The location to start searching from
    • findFreePosition

      public void findFreePosition()
      Description copied from interface: Player
      Find a position for the player to stand that is not inside a block. Blocks above the player will be iteratively tested until there is a series of two free blocks. The player will be teleported to that free position.
      Specified by:
      findFreePosition in interface Player
    • ascendLevel

      public boolean ascendLevel()
      Description copied from interface: Player
      Go up one level to the next free space above.
      Specified by:
      ascendLevel in interface Player
      Returns:
      true if a spot was found
    • descendLevel

      public boolean descendLevel()
      Description copied from interface: Player
      Go up one level to the next free space above.
      Specified by:
      descendLevel in interface Player
      Returns:
      true if a spot was found
    • ascendToCeiling

      public boolean ascendToCeiling(int clearance)
      Description copied from interface: Player
      Ascend to the ceiling above.
      Specified by:
      ascendToCeiling in interface Player
      Parameters:
      clearance - How many blocks to leave above the player's head
      Returns:
      whether the player was moved
    • ascendToCeiling

      public boolean ascendToCeiling(int clearance, boolean alwaysGlass)
      Description copied from interface: Player
      Ascend to the ceiling above.
      Specified by:
      ascendToCeiling in interface Player
      Parameters:
      clearance - How many blocks to leave above the player's head
      alwaysGlass - Always put glass under the player
      Returns:
      whether the player was moved
    • ascendUpwards

      public boolean ascendUpwards(int distance)
      Description copied from interface: Player
      Just go up.
      Specified by:
      ascendUpwards in interface Player
      Parameters:
      distance - How far up to teleport
      Returns:
      whether the player was moved
    • ascendUpwards

      public boolean ascendUpwards(int distance, boolean alwaysGlass)
      Description copied from interface: Player
      Just go up.
      Specified by:
      ascendUpwards in interface Player
      Parameters:
      distance - How far up to teleport
      alwaysGlass - Always put glass under the player
      Returns:
      whether the player was moved
    • floatAt

      public void floatAt(int x, int y, int z, boolean alwaysGlass)
      Description copied from interface: Player
      Make the player float in the given blocks.
      Specified by:
      floatAt in interface Player
      Parameters:
      x - The X coordinate of the block to float in
      y - The Y coordinate of the block to float in
      z - The Z coordinate of the block to float in
    • isAllowedToFly

      protected boolean isAllowedToFly()
      Check whether the player is allowed to fly.
      Returns:
      true if allowed flight
    • setFlying

      protected void setFlying(boolean flying)
      Set whether the player is currently flying.
      Parameters:
      flying - true to fly
    • getBlockOn

      public Location getBlockOn()
      Description copied from interface: Player
      Get the point of the block that is being stood upon.
      Specified by:
      getBlockOn in interface Player
      Returns:
      point
    • getBlockTrace

      public Location getBlockTrace(int range, boolean useLastBlock)
      Description copied from interface: Player
      Get the point of the block being looked at. May return null. Will return the farthest away air block if useLastBlock is true and no other block is found.
      Specified by:
      getBlockTrace in interface Player
      Parameters:
      range - how far to checks for blocks
      useLastBlock - try to return the last valid air block found
      Returns:
      point
    • getBlockTraceFace

      public Location getBlockTraceFace(int range, boolean useLastBlock)
      Description copied from interface: Player
      Get the face that the player is looking at.
      Specified by:
      getBlockTraceFace in interface Player
      Parameters:
      range - the range
      useLastBlock - try to return the last valid air block found
      Returns:
      a face
    • getBlockTrace

      public Location getBlockTrace(int range, boolean useLastBlock, @Nullable Mask stopMask)
      Description copied from interface: Player
      Get the point of the block being looked at. May return null. Will return the farthest away block before matching the stop mask if useLastBlock is true and no other block is found.
      Specified by:
      getBlockTrace in interface Player
      Parameters:
      range - how far to checks for blocks
      useLastBlock - try to return the last valid block not matching the stop mask found
      stopMask - the mask used to determine when to stop tracing
      Returns:
      point
    • getBlockTraceFace

      public Location getBlockTraceFace(int range, boolean useLastBlock, @Nullable Mask stopMask)
      Description copied from interface: Player
      Get the face that the player is looking at.
      Specified by:
      getBlockTraceFace in interface Player
      Parameters:
      range - the range
      useLastBlock - try to return the last valid block not matching the stop mask found
      stopMask - the mask used to determine when to stop tracing
      Returns:
      a face
    • getBlockTrace

      public Location getBlockTrace(int range)
      Description copied from interface: Player
      Get the point of the block being looked at. May return null.
      Specified by:
      getBlockTrace in interface Player
      Parameters:
      range - How far to checks for blocks
      Returns:
      point
    • getSolidBlockTrace

      public Location getSolidBlockTrace(int range)
      Description copied from interface: Player
      Get the point of the block being looked at. May return null.
      Specified by:
      getSolidBlockTrace in interface Player
      Parameters:
      range - How far to checks for blocks
      Returns:
      point
    • getCardinalDirection

      public Direction getCardinalDirection()
      Description copied from interface: Player
      Get the player's cardinal direction (N, W, NW, etc.). May return null.
      Specified by:
      getCardinalDirection in interface Player
      Returns:
      the direction
    • getCardinalDirection

      public Direction getCardinalDirection(int yawOffset)
      Description copied from interface: Player
      Get the player's cardinal direction (N, W, NW, etc.) with an offset. May return null.
      Specified by:
      getCardinalDirection in interface Player
      Parameters:
      yawOffset - offset that is added to the player's yaw before determining the cardinal direction
      Returns:
      the direction
    • getBlockInHand

      public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException
      Description copied from interface: Player
      Get the Block that the player is holding.
      Specified by:
      getBlockInHand in interface Player
      Returns:
      the item id of the item the player is holding
      Throws:
      WorldEditException
    • passThroughForwardWall

      public boolean passThroughForwardWall(int range)
      Description copied from interface: Player
      Pass through the wall that you are looking at.
      Specified by:
      passThroughForwardWall in interface Player
      Parameters:
      range - How far to checks for blocks
      Returns:
      whether the player was pass through
    • trySetPosition

      public boolean trySetPosition(Vector3 pos)
      Description copied from interface: Locatable
      Attempts to set the position of this actor.

      This action may fail, due to other mods cancelling the move. If so, this method will return false.

      Specified by:
      trySetPosition in interface Locatable
      Parameters:
      pos - the position to set
      Returns:
      if the position was able to be set
    • openFileOpenDialog

      public File openFileOpenDialog(String[] extensions)
      Description copied from interface: Actor
      Open a file open dialog.
      Specified by:
      openFileOpenDialog in interface Actor
      Parameters:
      extensions - null to allow all
      Returns:
      the selected file or null if something went wrong
    • openFileSaveDialog

      public File openFileSaveDialog(String[] extensions)
      Description copied from interface: Actor
      Open a file save dialog.
      Specified by:
      openFileSaveDialog in interface Actor
      Parameters:
      extensions - null to allow all
      Returns:
      the selected file or null if something went wrong
    • canDestroyBedrock

      public boolean canDestroyBedrock()
      Description copied from interface: Actor
      Returns true if the actor can destroy bedrock.
      Specified by:
      canDestroyBedrock in interface Actor
      Returns:
      true if bedrock can be broken by the actor
    • dispatchCUIEvent

      public void dispatchCUIEvent(CUIEvent event)
      Description copied from interface: Actor
      Send a CUI event.
      Specified by:
      dispatchCUIEvent in interface Actor
      Parameters:
      event - the event
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • checkPermission

      public void checkPermission(String permission) throws AuthorizationException
      Description copied from interface: Subject
      Check whether this subject has been granted the given permission and throw an exception on error.
      Specified by:
      checkPermission in interface Subject
      Parameters:
      permission - the permission
      Throws:
      AuthorizationException - thrown if not permitted
    • isPlayer

      public boolean isPlayer()
      Description copied from interface: Actor
      Return whether this actor is a player.
      Specified by:
      isPlayer in interface Actor
      Returns:
      true if a player
    • getGameMode

      public GameMode getGameMode()
      Description copied from interface: Player
      Return this actor's game mode.
      Specified by:
      getGameMode in interface Player
      Returns:
      the game mode
    • setGameMode

      public void setGameMode(GameMode gameMode)
      Description copied from interface: Player
      Sets the player to the given game mode.
      Specified by:
      setGameMode in interface Player
      Parameters:
      gameMode - The game mode
    • clone

      public Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • remove

      public boolean remove()
      Description copied from interface: Entity
      Remove this entity from it container.
      Specified by:
      remove in interface Entity
      Returns:
      true if removal was successful
    • sendFakeBlock

      public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block)
      Description copied from interface: Player
      Sends a fake block to the client.

      This block isn't real.

      Specified by:
      sendFakeBlock in interface Player
      Parameters:
      pos - The position of the block
      block - The block to send, null to reset