Package com.sk89q.worldedit
Class LocalSession
java.lang.Object
com.sk89q.worldedit.LocalSession
- All Implemented Interfaces:
TextureHolder
Stores session information.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstruct the object.LocalSession
(LocalConfiguration config) Construct the object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addClipboard
(MultiClipboardHolder toAppend) void
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.createEditSession
(Actor actor, String command) void
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.void
Ensure the player's clipboard is flushed.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
(BaseItem item, Player player, boolean create) getBrushTool
(Player player) getBrushTool
(Player player, boolean create) getBrushTool
(ItemType item) Deprecated.FAWE binds to the item, not the type - this allows brushes to persist, also deprecated in upstreamGets the clipboard.int
Gets the client's CUI protocol versionGet the default region selector.int
int
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 defaultDeprecated.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.Gets the reorder mode of the session.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 mask.Get the assigned block tool.Get the TextureUtil currently being usedint
Get the maximum time allowed for certain executions to run before cancelling them, such as expressions.Get the session's timezone.Deprecated.This method is deprecated and only for compatibility with WorldEdit.Deprecated.Get the preferred wand item for this user, ornull
to use the defaultDeprecated.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
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.void
loadClipboardFromDisk
(File file) Load a clipboard from disk and into this localsession.void
loadDefaults
(Actor actor, boolean force) boolean
loadSessionHistoryFromDisk
(UUID uuid, World world) void
onIdle()
Call when this session has become inactive.void
postLoad()
Called on post load of the session from persistent storage.Performs a redovoid
remember
(EditSession editSession) Remember an edit session for the undo history.void
remember
(EditSession editSession, boolean append, int limitMb) void
remember
(Identifiable player, World world, ChangeSet changeSet, FaweLimit limit) boolean
save()
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 versionvoid
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) void
setRegionSelector
(World world, RegionSelector selector) Set the region selector.void
setReorderMode
(EditSession.ReorderMode reorderMode) Sets the reorder mode of the session.void
setSideEffectSet
(SideEffectSet sideEffectSet) Sets the side effect applier for this sessionvoid
setSnapshot
(Snapshot snapshot) Select a legacy snapshot.void
setSnapshotExperimental
(Snapshot snapshotExperimental) Select a snapshot.void
setSourceMask
(Mask mask) Set a mask.void
setSuperPickaxe
(BlockTool tool) Set the super pick axe tool.void
setTextureUtil
(TextureUtil texture) 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
void
void
Deprecated.void
setToolControl
(boolean toolControl) Deprecated.The wand is now a tool that can be bound/unbound.void
setTracingActions
(boolean tracingActions) void
setTransform
(ResettableExtent transform) 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
Toggle placement position.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 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. -
loadSessionHistoryFromDisk
-
isDirty
public boolean isDirty()Get whether this session is "dirty" and has changes that needs to be committed.- Returns:
- true if dirty
-
getHistoryIndex
public int getHistoryIndex() -
getHistoryNegativeIndex
public int getHistoryNegativeIndex() -
getHistory
-
save
public boolean save() -
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
-
remember
-
remember
-
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
-
getExistingClipboard
-
addClipboard
-
flushClipboard
public void flushClipboard()Ensure the player's clipboard is flushed. (will only do something with clipboard-on-disk) -
loadClipboardFromDisk
public void loadClipboardFromDisk(File file) throws FaweClipboardVersionMismatchException, ExecutionException, InterruptedException Load a clipboard from disk and into this localsession. Synchronises with other clipboard setting/getting to and from this session- Parameters:
file
- Clipboard file to load- Throws:
FaweClipboardVersionMismatchException
- in clipboard version mismatch (between saved and internal, expected, version)ExecutionException
- if the computation threw an exceptionInterruptedException
- if the current thread was interrupted while waiting
-
deleteClipboardOnDisk
public void deleteClipboardOnDisk() -
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.- Returns:
- true always - see deprecation notice
-
setToolControl
Deprecated.The wand is now a tool that can be bound/unbound.- 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
-
setPlaceAtPos1
public void setPlaceAtPos1(boolean placeAtPos1) -
isPlaceAtPos1
public boolean isPlaceAtPos1() -
togglePlacementPosition
public boolean togglePlacementPosition()Toggle placement position.- Returns:
- whether "place at position 1" is now enabled
-
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
Deprecated.Get the tool assigned to the item.- Parameters:
item
- the item type- Returns:
- the tool, which may be
null
-
getTool
Deprecated.This method is deprecated and only for compatibility with WorldEdit. UsegetTool(BaseItem, Player)
instead.Get the tool assigned to the item.- Parameters:
item
- the item type- Returns:
- the tool, which may be
null
-
getTool
-
getTool
-
loadDefaults
-
getBrushTool
Deprecated.FAWE binds to the item, not the type - this allows brushes to persist, also deprecated in upstreamGet 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
-
getBrushTool
- Throws:
InvalidToolBindException
-
getBrushTool
- Throws:
InvalidToolBindException
-
getBrushTool
public BrushTool getBrushTool(BaseItem item, Player player, boolean create) throws InvalidToolBindException - Throws:
InvalidToolBindException
-
getBrush
Get the brush tool assigned to this item.- Parameters:
item
- the item type- Returns:
- the brush tool assigned to the item type
-
setTool
Deprecated.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
-
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- Since:
- 2.11.0
-
setTool
- Throws:
InvalidToolBindException
-
setTool
public void setTool(BaseItem item, @Nullable Tool tool, Player player) throws InvalidToolBindException - Throws:
InvalidToolBindException
-
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
-
createEditSession
-
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
Gets the reorder mode of the session.- Returns:
- The reorder mode
-
setReorderMode
Sets the reorder mode of the session.- Parameters:
reorderMode
- The reorder mode
-
getMask
Get the mask.- Returns:
- mask, may be null
-
getSourceMask
Get the mask.- Returns:
- mask, may be null
-
setMask
Set a mask.- Parameters:
mask
- mask or null
-
setSourceMask
Set a mask.- Parameters:
mask
- mask or null
-
setTextureUtil
-
getTextureUtil
Get the TextureUtil currently being used- Specified by:
getTextureUtil
in interfaceTextureHolder
-
getWandItem
Deprecated.Get the preferred wand item for this user, ornull
to use the default- Returns:
- item id of wand item, or
null
-
getWandBaseItem
Get the preferred wand item for this user, ornull
to use the default- Returns:
- item id of wand item, or
null
- Since:
- 2.11.0
-
getLastDistribution
Get the last block distribution stored in this session.- Returns:
- block distribution or
null
-
setLastDistribution
Store a block distribution in this session. -
getTransform
-
setTransform
-
onIdle
public void onIdle()Call when this session has become inactive.This is for internal use only.
-