Interface Player

All Superinterfaces:
Actor, Entity, Faceted, Identifiable, Locatable, MapMetadatable, Metadatable, SessionOwner, Subject
All Known Implementing Classes:
AbstractPlayerActor, AsyncPlayer, LocationMaskedPlayerWrapper, PlayerProxy, SilentPlayerWrapper

public interface Player extends Entity, Actor
Represents a player.
  • Method Details

    • getWorld

      World getWorld()
      Return the world that the player is on.
      Returns:
      the world
    • isHoldingPickAxe

      boolean isHoldingPickAxe()
      Returns true if the entity is holding a pick axe.
      Returns:
      whether a pick axe is held
    • getCardinalDirection

      Direction getCardinalDirection(int yawOffset)
      Get the player's cardinal direction (N, W, NW, etc.) with an offset. May return null.
      Parameters:
      yawOffset - offset that is added to the player's yaw before determining the cardinal direction
      Returns:
      the direction
    • getItemInHand

      BaseItemStack getItemInHand(HandSide handSide)
      Get the item that the player is holding.
      Returns:
      the item the player is holding
    • getBlockInHand

      BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException
      Get the Block that the player is holding.
      Returns:
      the item id of the item the player is holding
      Throws:
      WorldEditException
    • giveItem

      void giveItem(BaseItemStack itemStack)
      Gives the player an item.
      Parameters:
      itemStack - The item to give
    • getInventoryBlockBag

      BlockBag getInventoryBlockBag()
      Get this actor's block bag.
      Returns:
      the actor's block bag
    • getGameMode

      GameMode getGameMode()
      Return this actor's game mode.
      Returns:
      the game mode
    • setGameMode

      void setGameMode(GameMode gameMode)
      Sets the player to the given game mode.
      Parameters:
      gameMode - The game mode
    • findFreePosition

      void findFreePosition(Location searchPos)
      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.
      Parameters:
      searchPos - search position
    • setOnGround

      void setOnGround(Location searchPos)
      Set the actor on the ground.
      Parameters:
      searchPos - The location to start searching from
    • findFreePosition

      void findFreePosition()
      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.
    • ascendLevel

      boolean ascendLevel()
      Go up one level to the next free space above.
      Returns:
      true if a spot was found
    • descendLevel

      boolean descendLevel()
      Go up one level to the next free space above.
      Returns:
      true if a spot was found
    • ascendToCeiling

      boolean ascendToCeiling(int clearance)
      Ascend to the ceiling above.
      Parameters:
      clearance - How many blocks to leave above the player's head
      Returns:
      whether the player was moved
    • ascendToCeiling

      boolean ascendToCeiling(int clearance, boolean alwaysGlass)
      Ascend to the ceiling above.
      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

      boolean ascendUpwards(int distance)
      Just go up.
      Parameters:
      distance - How far up to teleport
      Returns:
      whether the player was moved
    • ascendUpwards

      boolean ascendUpwards(int distance, boolean alwaysGlass)
      Just go up.
      Parameters:
      distance - How far up to teleport
      alwaysGlass - Always put glass under the player
      Returns:
      whether the player was moved
    • floatAt

      void floatAt(int x, int y, int z, boolean alwaysGlass)
      Make the player float in the given blocks.
      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
    • getBlockIn

      @Deprecated default Location getBlockIn()
      Deprecated.
      Use Locatable#getBlockLocation
      Get the point of the block that is being stood in.
      Returns:
      point
    • getBlockOn

      Location getBlockOn()
      Get the point of the block that is being stood upon.
      Returns:
      point
    • getBlockTrace

      Location getBlockTrace(int range, boolean useLastBlock)
      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.
      Parameters:
      range - how far to checks for blocks
      useLastBlock - try to return the last valid air block found
      Returns:
      point
    • getBlockTrace

      Location getBlockTrace(int range, boolean useLastBlock, @Nullable Mask stopMask)
      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.
      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

      Location getBlockTraceFace(int range, boolean useLastBlock)
      Get the face that the player is looking at.
      Parameters:
      range - the range
      useLastBlock - try to return the last valid air block found
      Returns:
      a face
    • getBlockTraceFace

      Location getBlockTraceFace(int range, boolean useLastBlock, @Nullable Mask stopMask)
      Get the face that the player is looking at.
      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

      Location getBlockTrace(int range)
      Get the point of the block being looked at. May return null.
      Parameters:
      range - How far to checks for blocks
      Returns:
      point
    • getSolidBlockTrace

      Location getSolidBlockTrace(int range)
      Get the point of the block being looked at. May return null.
      Parameters:
      range - How far to checks for blocks
      Returns:
      point
    • getCardinalDirection

      Direction getCardinalDirection()
      Get the player's cardinal direction (N, W, NW, etc.). May return null.
      Returns:
      the direction
    • passThroughForwardWall

      boolean passThroughForwardWall(int range)
      Pass through the wall that you are looking at.
      Parameters:
      range - How far to checks for blocks
      Returns:
      whether the player was pass through
    • setPosition

      @Deprecated default void setPosition(Vector3 pos, float pitch, float yaw)
      Deprecated.
      This method may fail without indication. Use trySetPosition(Vector3, float, float) instead
      Move the player.
      Parameters:
      pos - where to move them
      pitch - the pitch (up/down) of the player's view in degrees
      yaw - the yaw (left/right) of the player's view in degrees
    • trySetPosition

      @NonAbstractForCompatibility(delegateName="setPosition", delegateParams={Vector3.class,float.class,float.class}) default boolean trySetPosition(Vector3 pos, float pitch, float yaw)
      Attempt to move the player.

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

      Parameters:
      pos - where to move them
      pitch - the pitch (up/down) of the player's view in degrees
      yaw - the yaw (left/right) of the player's view in degrees
      Returns:
      if the move was able to occur
    • sendFakeBlock

      <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, @Nullable B block)
      Sends a fake block to the client.

      This block isn't real.

      Parameters:
      pos - The position of the block
      block - The block to send, null to reset
    • getAllowedRegions

      Region[] getAllowedRegions()
      Get the player's current allowed WorldEdit regions.
      Returns:
      an array of allowed regions
    • getAllowedRegions

      Region[] getAllowedRegions(FaweMaskManager.MaskType type)
      Get the player's current allowed WorldEdit regions.
      Parameters:
      type - Mask type; whether to check if the player is an owner of a member of the regions
      Returns:
      an array of allowed regions
    • getDisallowedRegions

      Region[] getDisallowedRegions()
      Get the player's current disallowed WorldEdit regions. Effectively a blacklist.
      Returns:
      an array of disallowed regions
    • getDisallowedRegions

      Region[] getDisallowedRegions(FaweMaskManager.MaskType type)
      Get the player's current disallowed WorldEdit regions. Effectively a blacklist.
      Parameters:
      type - Mask type; whether to check if the player is an owner of a member of the regions
      Returns:
      an array of disallowed regions
    • getLargestRegion

      Region getLargestRegion()
      Get the largest region in the player's allowed WorldEdit region.
    • setSelection

      void setSelection(Region region)
      Set a players selection and selector type to the given region
    • getSelection

      default Region getSelection() throws IncompleteRegionException
      Get the player's selection region. If the selection is defined in a different world, the IncompleteRegionException exception will be thrown.
      Returns:
      a region
      Throws:
      IncompleteRegionException - if no region is selected
    • setSelection

      default void setSelection(RegionSelector selector)
      Set the player's WorldEdit selection.
      Parameters:
      selector - the selector
    • getWorldForEditing

      default World getWorldForEditing()
      Get the world the player is editing in. The world may or may not match the world they are in. For example, if they are editing a CFI world.
      Returns:
      Editing world
    • unregister

      default void unregister()
      Unregister this player, deleting all data stored during the login session.
    • sendTitle

      void sendTitle(com.sk89q.worldedit.util.formatting.text.Component title, com.sk89q.worldedit.util.formatting.text.Component sub)
    • loadClipboardFromDisk

      default void loadClipboardFromDisk()
      Loads any history items from disk: - Should already be called if history on disk is enabled.