Class Polygonal2DRegionSelector
java.lang.Object
com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector
- All Implemented Interfaces:
CUIRegion
,RegionSelector
Creates a
Polygonal2DRegion
from a user's selections.-
Constructor Summary
ConstructorDescriptionCreate a new selector with anull
world.Polygonal2DRegionSelector
(RegionSelector oldSelector) Create a new selector from another one.Polygonal2DRegionSelector
(World world) Create a new selector with the given world.Polygonal2DRegionSelector
(World world, List<BlockVector2> points, int minY, int maxY) Create a new selector. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear the selection.void
describeCUI
(LocalSession session, Actor player) Sends CUI events describing the region for versions of CUI equal to or greater than the value supplied by getProtocolVersion().void
describeLegacyCUI
(LocalSession session, Actor player) Sends CUI events describing the region for versions of CUI smaller than the value supplied by getProtocolVersion().void
explainPrimarySelection
(Actor player, LocalSession session, BlockVector3 pos) Tell the player information about his/her primary selection.void
explainRegionAdjust
(Actor player, LocalSession session) Tell the player information about the region's changes.void
explainSecondarySelection
(Actor player, LocalSession session, BlockVector3 pos) Tell the player information about his/her secondary selection.Get the region even if it's not fully defined.Returns the type ID to send to CUI in the selection event if the CUI is in legacy mode.int
Get the number of points.Get the primary position.int
Returns the CUI version that is required to send up-to-date data.Get the selection.List<com.sk89q.worldedit.util.formatting.text.Component>
Get lines of information about the selection.Returns the type ID to send to CUI in the selection event.Get a lowercase name of this region selector type.long
Get the number of blocks inside the region.getWorld()
Get the world for the region selector.boolean
Returns whether the region has been fully defined.void
Update the selector with changes to the region.boolean
selectPrimary
(BlockVector3 position, SelectorLimits limits) Called when the first point is selected.boolean
selectSecondary
(BlockVector3 position, SelectorLimits limits) Called when the second point is selected.void
Set the world for the region selector.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.sk89q.worldedit.regions.RegionSelector
getArea, getInformationLines
-
Constructor Details
-
Polygonal2DRegionSelector
public Polygonal2DRegionSelector()Create a new selector with anull
world. -
Polygonal2DRegionSelector
Create a new selector with the given world.- Parameters:
world
- the world
-
Polygonal2DRegionSelector
Create a new selector from another one.- Parameters:
oldSelector
- the old selector
-
Polygonal2DRegionSelector
public Polygonal2DRegionSelector(@Nullable World world, List<BlockVector2> points, int minY, int maxY) Create a new selector.- Parameters:
world
- the worldpoints
- a list of pointsminY
- the minimum YmaxY
- the maximum Y
-
-
Method Details
-
getWorld
Description copied from interface:RegionSelector
Get the world for the region selector.- Specified by:
getWorld
in interfaceRegionSelector
- Returns:
- a world, which may be null
-
setWorld
Description copied from interface:RegionSelector
Set the world for the region selector.- Specified by:
setWorld
in interfaceRegionSelector
- Parameters:
world
- the world, which may be null
-
selectPrimary
Description copied from interface:RegionSelector
Called when the first point is selected.- Specified by:
selectPrimary
in interfaceRegionSelector
- Parameters:
position
- the position- Returns:
- true if something changed
-
selectSecondary
Description copied from interface:RegionSelector
Called when the second point is selected.- Specified by:
selectSecondary
in interfaceRegionSelector
- Parameters:
position
- the position- Returns:
- true if something changed
-
explainPrimarySelection
Description copied from interface:RegionSelector
Tell the player information about his/her primary selection.- Specified by:
explainPrimarySelection
in interfaceRegionSelector
- Parameters:
player
- the actorsession
- the sessionpos
- position
-
explainSecondarySelection
Description copied from interface:RegionSelector
Tell the player information about his/her secondary selection.- Specified by:
explainSecondarySelection
in interfaceRegionSelector
- Parameters:
player
- the actorsession
- the sessionpos
- position
-
explainRegionAdjust
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 interfaceRegionSelector
- Parameters:
player
- the actorsession
- the session
-
getPrimaryPosition
Description copied from interface:RegionSelector
Get the primary position.- Specified by:
getPrimaryPosition
in interfaceRegionSelector
- Returns:
- the primary position
- Throws:
IncompleteRegionException
- thrown if a region has not been fully defined
-
getRegion
Description copied from interface:RegionSelector
Get the selection.- Specified by:
getRegion
in interfaceRegionSelector
- Returns:
- the created region
- Throws:
IncompleteRegionException
- thrown if a region has not been fully defined
-
getIncompleteRegion
Description copied from interface:RegionSelector
Get the region even if it's not fully defined.- Specified by:
getIncompleteRegion
in interfaceRegionSelector
- Returns:
- an incomplete region object that is incomplete
-
isDefined
public boolean isDefined()Description copied from interface:RegionSelector
Returns whether the region has been fully defined.- Specified by:
isDefined
in interfaceRegionSelector
- Returns:
- true if a selection is available
-
learnChanges
public void learnChanges()Description copied from interface:RegionSelector
Update the selector with changes to the region.- Specified by:
learnChanges
in interfaceRegionSelector
-
clear
public void clear()Description copied from interface:RegionSelector
Clear the selection.- Specified by:
clear
in interfaceRegionSelector
-
getTypeName
Description copied from interface:RegionSelector
Get a lowercase name of this region selector type.- Specified by:
getTypeName
in interfaceRegionSelector
- Returns:
- a lower case name of the type
-
getSelectionInfoLines
Description copied from interface:RegionSelector
Get lines of information about the selection.- Specified by:
getSelectionInfoLines
in interfaceRegionSelector
- 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 interfaceRegionSelector
- Returns:
- number of blocks, or -1 if undefined
-
getPointCount
public int getPointCount()Get the number of points.- Returns:
- the number of points
-
describeCUI
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 interfaceCUIRegion
-
describeLegacyCUI
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 interfaceCUIRegion
-
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 interfaceCUIRegion
- Returns:
- the protocol version
-
getTypeID
Description copied from interface:CUIRegion
Returns the type ID to send to CUI in the selection event. -
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 interfaceCUIRegion
- Returns:
- the legacy type ID
-