Package com.sk89q.worldedit
Class LocalSession
java.lang.Object
com.sk89q.worldedit.LocalSession
Stores session information.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstruct the object.LocalSession
(LocalConfiguration config) Construct the object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear history.boolean
Get whether this session is "dirty" and has changes that needs to be committed, and reset it tofalse
.createEditSession
(Actor actor) Construct a new edit session.void
describeCUI
(Actor actor) Describe the selection to the CUI actor.detectDate
(String input) Detect date from a user's input.void
Disable super pick axe.void
dispatchCUIEvent
(Actor actor, CUIEvent event) Dispatch a CUI event but only if the actor has CUI support.void
dispatchCUISelection
(Actor actor) Send the selection information.void
dispatchCUISetup
(Actor actor) Dispatch the initial setup CUI messages.void
Enable super pick axe.forceBrush
(ItemType item, Brush brush, String permission) Force the tool to become a brush tool with the specified brush and permission.getBlockBag
(Player player) Get a block bag for a player.int
Get the maximum number of blocks that can be changed in an edit session.Get the brush tool assigned to this item.getBrushTool
(ItemType item) Deprecated.Gets the clipboard.int
Gets the client's CUI protocol version.Get the default region selector.Get the last block distribution stored in this session.Get the last script used.getMask()
Get the mask.Get the preferred navigation wand item for this user, ornull
to use the default.Returns the current placement used for many operations, like//sphere
.getPlacementPosition
(Actor actor) Get the position use for commands that take a center point (i.e.getRegionSelector
(World world) Get the region selector for defining the selection.Deprecated.Get the selection region.getSelection
(World world) Get the selection region.Get the selection world.Gets the side effect applier of this session.Get the legacy snapshot that has been selected.Get the snapshot that has been selected.Get the assigned block tool.int
Get the maximum time allowed for certain executions to run before cancelling them, such as expressions.Get the session's timezone.Get the tool assigned to the item.Get the preferred wand item for this user, ornull
to use the default.void
handleCUIInitializationMessage
(String text, Actor actor) Handle a CUI initialization message.boolean
Gets the status of CUI support.boolean
Deprecated.boolean
Checks whether the super pick axe is enabled.boolean
boolean
isDirty()
Get whether this session is "dirty" and has changes that needs to be committed.boolean
Get if the navigation wand item should use the default, or null if unknown.boolean
Deprecated.UsegetPlacement()
boolean
isSelectionDefined
(World world) Returns true if the region is fully defined for the specified world.boolean
boolean
Deprecated.The wand is now a tool that can be bound/unbound.boolean
boolean
Returns whether inventory usage is enabled for this session.boolean
Get if the selection wand item should use the default, or null if unknown.void
onIdle()
Call when this session has become inactive.void
postLoad()
Called on post load of the session from persistent storage.Performs a redo.void
remember
(EditSession editSession) Remember an edit session for the undo history.void
setBlockChangeLimit
(int maxBlocksChanged) Set the maximum number of blocks that can be changed.void
setClipboard
(ClipboardHolder clipboard) Sets the clipboard.void
setConfiguration
(LocalConfiguration config) Set the configuration.void
setCUISupport
(boolean support) Sets the status of CUI support.void
setCUIVersion
(int cuiVersion) Sets the client's CUI protocol version.void
setDefaultRegionSelector
(RegionSelectorType defaultSelector) Set the default region selector.void
setFastMode
(boolean fastMode) Deprecated.void
setLastDistribution
(List<Countable<BlockState>> dist) Store a block distribution in this session.void
setLastScript
(String lastScript) Set the last script used.void
Set a mask.void
setPlaceAtPos1
(boolean placeAtPos1) Deprecated.void
setPlacement
(Placement placement) Sets the current placement used for many operations, like//sphere
.void
setRegionSelector
(World world, RegionSelector selector) Set the region selector.void
setReorderMode
(EditSession.ReorderMode reorderMode) Deprecated.void
setSideEffectSet
(SideEffectSet sideEffectSet) Sets the side effect applier for this session.void
setSnapshot
(Snapshot snapshot) Select a legacy snapshot.void
setSnapshotExperimental
(Snapshot snapshotExperimental) Select a snapshot.void
setSuperPickaxe
(BlockTool tool) Set the super pick axe tool.void
setTickingWatchdog
(boolean tickingWatchdog) void
setTimeout
(int timeout) Set the maximum number of blocks that can be changed.void
setTimezone
(ZoneId timezone) Set the session's timezone.void
Set the tool.void
setToolControl
(boolean toolControl) Deprecated.The wand is now a tool that can be bound/unbound.void
setTracingActions
(boolean tracingActions) void
setUseInventory
(boolean useInventory) Set the state of inventory usage.void
setUseServerCUI
(boolean useServerCUI) void
setWorldOverride
(World worldOverride) boolean
void
tellVersion
(Actor actor) Tell the player the WorldEdit version.boolean
Deprecated.boolean
Toggle the super pick axe.Performs an undo.void
updateServerCUI
(Actor actor) Update server-side WorldEdit CUI.
-
Field Details
-
MAX_HISTORY_SIZE
public static transient int MAX_HISTORY_SIZE
-
-
Constructor Details
-
LocalSession
public LocalSession()Construct the object.setConfiguration(LocalConfiguration)
should be called later with configuration. -
LocalSession
Construct the object.- Parameters:
config
- the configuration
-
-
Method Details
-
setConfiguration
Set the configuration.- Parameters:
config
- the configuration
-
postLoad
public void postLoad()Called on post load of the session from persistent storage. -
isDirty
public boolean isDirty()Get whether this session is "dirty" and has changes that needs to be committed.- Returns:
- true if dirty
-
compareAndResetDirty
public boolean compareAndResetDirty()Get whether this session is "dirty" and has changes that needs to be committed, and reset it tofalse
.- Returns:
- true if the dirty value was
true
-
getTimeZone
Get the session's timezone.- Returns:
- the timezone
-
setTimezone
Set the session's timezone.- Parameters:
timezone
- the user's timezone
-
clearHistory
public void clearHistory()Clear history. -
remember
Remember an edit session for the undo history. If the history maximum size is reached, old edit sessions will be discarded.- Parameters:
editSession
- the edit session
-
undo
Performs an undo.- Parameters:
newBlockBag
- a new block bagactor
- the actor- Returns:
- whether anything was undone
-
redo
Performs a redo.- Parameters:
newBlockBag
- a new block bagactor
- the actor- Returns:
- whether anything was redone
-
hasWorldOverride
public boolean hasWorldOverride() -
getWorldOverride
-
setWorldOverride
-
isTickingWatchdog
public boolean isTickingWatchdog() -
setTickingWatchdog
public void setTickingWatchdog(boolean tickingWatchdog) -
isTracingActions
public boolean isTracingActions() -
setTracingActions
public void setTracingActions(boolean tracingActions) -
getDefaultRegionSelector
Get the default region selector.- Returns:
- the default region selector
-
setDefaultRegionSelector
Set the default region selector.- Parameters:
defaultSelector
- the default region selector
-
getRegionSelector
Get the region selector for defining the selection. If the selection was defined for a different world, the old selection will be discarded.- Parameters:
world
- the world- Returns:
- position the position
-
setRegionSelector
Set the region selector.- Parameters:
world
- the worldselector
- the selector
-
isSelectionDefined
Returns true if the region is fully defined for the specified world.- Parameters:
world
- the world- Returns:
- true if a region selection is defined
-
getSelection
Get the selection region. If you change the region, you should call learnRegionChanges(). If the selection is not fully defined, theIncompleteRegionException
exception will be thrown.Note that this method will return a region in the current selection world, which is not guaranteed to be the player's world or even the current world override. If you require a specific world, use the
getSelection(World)
overload instead.- Returns:
- the selected region
- Throws:
IncompleteRegionException
- if the region is not fully defined
-
getSelection
Get the selection region. If you change the region, you should call learnRegionChanges(). If the selection is defined in a different world, or the selection isn't fully defined, theIncompleteRegionException
exception will be thrown.- Parameters:
world
- the world- Returns:
- a region
- Throws:
IncompleteRegionException
- if no region is selected, or the provided world is null
-
getSelectionWorld
Get the selection world.- Returns:
- the the world of the selection
-
getClipboard
Gets the clipboard.- Returns:
- clipboard
- Throws:
EmptyClipboardException
- thrown if no clipboard is set
-
setClipboard
Sets the clipboard.Pass
null
to clear the clipboard.- Parameters:
clipboard
- the clipboard, or null if the clipboard is to be cleared
-
isToolControlEnabled
Deprecated.The wand is now a tool that can be bound/unbound.Check if tool control is enabled.- Returns:
- true always - see deprecation notice
-
setToolControl
Deprecated.The wand is now a tool that can be bound/unbound.Set if tool control is enabled.- Parameters:
toolControl
- unused - see deprecation notice
-
getBlockChangeLimit
public int getBlockChangeLimit()Get the maximum number of blocks that can be changed in an edit session.- Returns:
- block change limit
-
setBlockChangeLimit
public void setBlockChangeLimit(int maxBlocksChanged) Set the maximum number of blocks that can be changed.- Parameters:
maxBlocksChanged
- the maximum number of blocks changed
-
getTimeout
public int getTimeout()Get the maximum time allowed for certain executions to run before cancelling them, such as expressions.- Returns:
- timeout time, in milliseconds
-
setTimeout
public void setTimeout(int timeout) Set the maximum number of blocks that can be changed.- Parameters:
timeout
- the time, in milliseconds, to limit certain executions to, or -1 to disable
-
hasSuperPickAxe
public boolean hasSuperPickAxe()Checks whether the super pick axe is enabled.- Returns:
- status
-
enableSuperPickAxe
public void enableSuperPickAxe()Enable super pick axe. -
disableSuperPickAxe
public void disableSuperPickAxe()Disable super pick axe. -
toggleSuperPickAxe
public boolean toggleSuperPickAxe()Toggle the super pick axe.- Returns:
- whether the super pick axe is now enabled
-
getPlacementPosition
Get the position use for commands that take a center point (i.e. //forestgen, etc.).- Parameters:
actor
- the actor- Returns:
- the position to use
- Throws:
IncompleteRegionException
- thrown if a region is not fully selected
-
getPlacement
Returns the current placement used for many operations, like//sphere
.- Returns:
- the placement.
-
setPlacement
Sets the current placement used for many operations, like//sphere
.Example usage:
session.setPlacement(new Placement(PlacementType.WORLD, BlockVector3.at(123, 456, 789)
- Parameters:
placement
- the placement.
-
setPlaceAtPos1
Deprecated.Sets whether placement is at POS1 or PLAYER.- Parameters:
placeAtPos1
- true=POS1, false=PLAYER
-
isPlaceAtPos1
Deprecated.UsegetPlacement()
Gets whether placement is at POS1 or PLAYER.- Returns:
- true=POS1, false=PLAYER
-
togglePlacementPosition
Deprecated.Toggle placement position between POS1 and PLAYER. If placement was POS1, it is set to PLAYER. If it was set to anything else, it is set to POS1.- Returns:
- whether placement is now at position 1
-
getBlockBag
Get a block bag for a player.- Parameters:
player
- the player to get the block bag for- Returns:
- a block bag
-
getSnapshot
Get the legacy snapshot that has been selected.- Returns:
- the legacy snapshot
-
setSnapshot
Select a legacy snapshot.- Parameters:
snapshot
- a legacy snapshot
-
getSnapshotExperimental
Get the snapshot that has been selected.- Returns:
- the snapshot
-
setSnapshotExperimental
Select a snapshot.- Parameters:
snapshotExperimental
- a snapshot
-
getSuperPickaxe
Get the assigned block tool.- Returns:
- the super pickaxe tool mode
-
setSuperPickaxe
Set the super pick axe tool.- Parameters:
tool
- the tool to set
-
getTool
Get the tool assigned to the item.- Parameters:
item
- the item type- Returns:
- the tool, which may be
null
-
getBrushTool
Deprecated.UsegetBrush(ItemType)
orforceBrush(ItemType, Brush, String)
if you need to bind a specific brushGet the brush tool assigned to the item. If there is no tool assigned or the tool is not a brush tool, the slot will be replaced with the brush tool.- Parameters:
item
- the item type- Returns:
- the tool, or
null
- Throws:
InvalidToolBindException
- if the item can't be bound to that item
-
getBrush
Get the brush tool assigned to this item.- Parameters:
item
- the item type- Returns:
- the brush tool assigned to the item type
-
forceBrush
public BrushTool forceBrush(ItemType item, Brush brush, String permission) throws InvalidToolBindException Force the tool to become a brush tool with the specified brush and permission.- Parameters:
item
- the item typebrush
- the brush to bindpermission
- the permission to check before use is allowed- Returns:
- the brush tool assigned to the item type
- Throws:
InvalidToolBindException
-
setTool
Set the tool.- Parameters:
item
- the item typetool
- the tool to set, which can benull
- Throws:
InvalidToolBindException
- if the item can't be bound to that item
-
isUsingInventory
public boolean isUsingInventory()Returns whether inventory usage is enabled for this session.- Returns:
- if inventory is being used
-
setUseInventory
public void setUseInventory(boolean useInventory) Set the state of inventory usage.- Parameters:
useInventory
- if inventory is to be used
-
getLastScript
Get the last script used.- Returns:
- the last script's name
-
setLastScript
Set the last script used.- Parameters:
lastScript
- the last script's name
-
tellVersion
Tell the player the WorldEdit version.- Parameters:
actor
- the actor
-
shouldUseServerCUI
public boolean shouldUseServerCUI() -
setUseServerCUI
public void setUseServerCUI(boolean useServerCUI) -
updateServerCUI
Update server-side WorldEdit CUI.- Parameters:
actor
- The player
-
dispatchCUIEvent
Dispatch a CUI event but only if the actor has CUI support.- Parameters:
actor
- the actorevent
- the event
-
dispatchCUISetup
Dispatch the initial setup CUI messages.- Parameters:
actor
- the actor
-
dispatchCUISelection
Send the selection information.- Parameters:
actor
- the actor
-
describeCUI
Describe the selection to the CUI actor.- Parameters:
actor
- the actor
-
handleCUIInitializationMessage
Handle a CUI initialization message.- Parameters:
text
- the message
-
hasCUISupport
public boolean hasCUISupport()Gets the status of CUI support.- Returns:
- true if CUI is enabled
-
setCUISupport
public void setCUISupport(boolean support) Sets the status of CUI support.- Parameters:
support
- true if CUI is enabled
-
getCUIVersion
public int getCUIVersion()Gets the client's CUI protocol version.- Returns:
- the CUI version
-
setCUIVersion
public void setCUIVersion(int cuiVersion) Sets the client's CUI protocol version.- Parameters:
cuiVersion
- the CUI version
-
detectDate
Detect date from a user's input.- Parameters:
input
- the input to parse- Returns:
- a date
-
createEditSession
Construct a new edit session.- Parameters:
actor
- the actor- Returns:
- an edit session
-
getSideEffectSet
Gets the side effect applier of this session.- Returns:
- the side effect applier
-
setSideEffectSet
Sets the side effect applier for this session.- Parameters:
sideEffectSet
- the side effect applier
-
hasFastMode
Deprecated.Checks if the session has fast mode enabled.- Returns:
- true if fast mode is enabled
-
setFastMode
Deprecated.Set fast mode.- Parameters:
fastMode
- true if fast mode is enabled
-
getReorderMode
Deprecated.Gets the reorder mode of the session.- Returns:
- The reorder mode
-
setReorderMode
Deprecated.Sets the reorder mode of the session.- Parameters:
reorderMode
- The reorder mode
-
getMask
Get the mask.- Returns:
- mask, may be null
-
setMask
Set a mask.- Parameters:
mask
- mask or null
-
getWandItem
Get the preferred wand item for this user, ornull
to use the default.- Returns:
- item id of wand item, or
null
-
isWandItemDefault
public boolean isWandItemDefault()Get if the selection wand item should use the default, or null if unknown.- Returns:
- if it should use the default
-
getLastDistribution
Get the last block distribution stored in this session.- Returns:
- block distribution or
null
-
setLastDistribution
Store a block distribution in this session. -
onIdle
public void onIdle()Call when this session has become inactive.This is for internal use only.
-
getBrush(ItemType)
orforceBrush(ItemType, Brush, String)
if you need to bind a specific brush