Class CuboidRegionSelector

java.lang.Object
com.sk89q.worldedit.regions.selector.CuboidRegionSelector
All Implemented Interfaces:
CUIRegion, RegionSelector
Direct Known Subclasses:
ExtendingCuboidRegionSelector

public class CuboidRegionSelector extends Object implements RegionSelector, CUIRegion
Creates a CuboidRegion from a user's selections.
  • Field Details

  • Constructor Details

    • CuboidRegionSelector

      public CuboidRegionSelector()
      Create a new region selector with a null world.
    • CuboidRegionSelector

      public CuboidRegionSelector(@Nullable World world)
      Create a new region selector.
      Parameters:
      world - the world, which may be null
    • CuboidRegionSelector

      public CuboidRegionSelector(RegionSelector oldSelector)
      Create a copy of another selector.
      Parameters:
      oldSelector - another selector
    • CuboidRegionSelector

      public CuboidRegionSelector(@Nullable World world, BlockVector3 position1, BlockVector3 position2)
      Create a new region selector with the given two positions.
      Parameters:
      world - the world
      position1 - position 1
      position2 - position 2
  • Method Details

    • getWorld

      @Nullable public World getWorld()
      Description copied from interface: RegionSelector
      Get the world for the region selector.
      Specified by:
      getWorld in interface RegionSelector
      Returns:
      a world, which may be null
    • setWorld

      public void setWorld(@Nullable World world)
      Description copied from interface: RegionSelector
      Set the world for the region selector.
      Specified by:
      setWorld in interface RegionSelector
      Parameters:
      world - the world, which may be null
    • selectPrimary

      public boolean selectPrimary(BlockVector3 position, SelectorLimits limits)
      Description copied from interface: RegionSelector
      Called when the first point is selected.
      Specified by:
      selectPrimary in interface RegionSelector
      Parameters:
      position - the position
      Returns:
      true if something changed
    • selectSecondary

      public boolean selectSecondary(BlockVector3 position, SelectorLimits limits)
      Description copied from interface: RegionSelector
      Called when the second point is selected.
      Specified by:
      selectSecondary in interface RegionSelector
      Parameters:
      position - the position
      Returns:
      true if something changed
    • explainPrimarySelection

      public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos)
      Description copied from interface: RegionSelector
      Tell the player information about his/her primary selection.
      Specified by:
      explainPrimarySelection in interface RegionSelector
      Parameters:
      player - the actor
      session - the session
      pos - position
    • explainSecondarySelection

      public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos)
      Description copied from interface: RegionSelector
      Tell the player information about his/her secondary selection.
      Specified by:
      explainSecondarySelection in interface RegionSelector
      Parameters:
      player - the actor
      session - the session
      pos - position
    • explainRegionAdjust

      public void explainRegionAdjust(Actor player, LocalSession session)
      Description copied from interface: RegionSelector
      Tell the player information about the region's changes. This may resend all the defining region information if needed.
      Specified by:
      explainRegionAdjust in interface RegionSelector
      Parameters:
      player - the actor
      session - the session
    • getPrimaryPosition

      public BlockVector3 getPrimaryPosition() throws IncompleteRegionException
      Description copied from interface: RegionSelector
      Get the primary position.
      Specified by:
      getPrimaryPosition in interface RegionSelector
      Returns:
      the primary position
      Throws:
      IncompleteRegionException - thrown if a region has not been fully defined
    • isDefined

      public boolean isDefined()
      Description copied from interface: RegionSelector
      Returns whether the region has been fully defined.
      Specified by:
      isDefined in interface RegionSelector
      Returns:
      true if a selection is available
    • getRegion

      public CuboidRegion getRegion() throws IncompleteRegionException
      Description copied from interface: RegionSelector
      Get the selection.
      Specified by:
      getRegion in interface RegionSelector
      Returns:
      the created region
      Throws:
      IncompleteRegionException - thrown if a region has not been fully defined
    • getIncompleteRegion

      public CuboidRegion getIncompleteRegion()
      Description copied from interface: RegionSelector
      Get the region even if it's not fully defined.
      Specified by:
      getIncompleteRegion in interface RegionSelector
      Returns:
      an incomplete region object that is incomplete
    • learnChanges

      public void learnChanges()
      Description copied from interface: RegionSelector
      Update the selector with changes to the region.
      Specified by:
      learnChanges in interface RegionSelector
    • clear

      public void clear()
      Description copied from interface: RegionSelector
      Clear the selection.
      Specified by:
      clear in interface RegionSelector
    • getTypeName

      public String getTypeName()
      Description copied from interface: RegionSelector
      Get a lowercase name of this region selector type.
      Specified by:
      getTypeName in interface RegionSelector
      Returns:
      a lower case name of the type
    • getSelectionInfoLines

      public List<com.sk89q.worldedit.util.formatting.text.Component> getSelectionInfoLines()
      Description copied from interface: RegionSelector
      Get lines of information about the selection.
      Specified by:
      getSelectionInfoLines in interface RegionSelector
      Returns:
      a list of lines describing the region.
    • getVolume

      public long getVolume()
      Description copied from interface: RegionSelector
      Get the number of blocks inside the region.
      Specified by:
      getVolume in interface RegionSelector
      Returns:
      number of blocks, or -1 if undefined
    • describeCUI

      public void describeCUI(LocalSession session, Actor player)
      Description copied from interface: CUIRegion
      Sends CUI events describing the region for versions of CUI equal to or greater than the value supplied by getProtocolVersion().
      Specified by:
      describeCUI in interface CUIRegion
    • describeLegacyCUI

      public void describeLegacyCUI(LocalSession session, Actor player)
      Description copied from interface: CUIRegion
      Sends CUI events describing the region for versions of CUI smaller than the value supplied by getProtocolVersion().
      Specified by:
      describeLegacyCUI in interface CUIRegion
    • getProtocolVersion

      public int getProtocolVersion()
      Description copied from interface: CUIRegion
      Returns the CUI version that is required to send up-to-date data. If the CUI version is smaller than this value, the legacy methods will be called.
      Specified by:
      getProtocolVersion in interface CUIRegion
      Returns:
      the protocol version
    • getTypeID

      public String getTypeID()
      Description copied from interface: CUIRegion
      Returns the type ID to send to CUI in the selection event.
      Specified by:
      getTypeID in interface CUIRegion
      Returns:
      the type ID
    • getLegacyTypeID

      public String getLegacyTypeID()
      Description copied from interface: CUIRegion
      Returns the type ID to send to CUI in the selection event if the CUI is in legacy mode.
      Specified by:
      getLegacyTypeID in interface CUIRegion
      Returns:
      the legacy type ID