Package com.sk89q.worldedit
Class LocalSession
java.lang.Object
com.sk89q.worldedit.LocalSession
- All Implemented Interfaces:
TextureHolder
Stores session information.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstruct the object.LocalSession(LocalConfiguration config) Construct the object. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddClipboard(MultiClipboardHolder toAppend) voidClear history.booleanGet 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) voidvoiddescribeCUI(Actor actor) Describe the selection to the CUI actor.detectDate(String input) Detect date from a user's input.voidDisable super pick axe.voiddispatchCUIEvent(Actor actor, CUIEvent event) Dispatch a CUI event but only if the actor has CUI support.voiddispatchCUISelection(Actor actor) Send the selection information.voiddispatchCUISetup(Actor actor) Dispatch the initial setup CUI messages.voidEnable super pick axe.voidEnsure the player's clipboard is flushed.getBlockBag(Player player) Get a block bag for a player.intGet 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.intGets the client's CUI protocol versionGet the default region selector.intintGet 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, ornullto 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.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 mask.Get the assigned block tool.Get the TextureUtil currently being usedintGet 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, ornullto use the defaultDeprecated.voidhandleCUIInitializationMessage(String text, Actor actor) Handle a CUI initialization message.booleanGets the status of CUI support.booleanDeprecated.booleanChecks whether the super pick axe is enabled.booleanbooleanisDirty()Get whether this session is "dirty" and has changes that needs to be committed.booleanbooleanisSelectionDefined(World world) Returns true if the region is fully defined for the specified world.booleanbooleanDeprecated.The wand is now a tool that can be bound/unbound.booleanbooleanReturns whether inventory usage is enabled for this session.voidloadClipboardFromDisk(File file) Load a clipboard from disk and into this localsession.voidloadDefaults(Actor actor, boolean force) booleanloadSessionHistoryFromDisk(UUID uuid, World world) voidonIdle()Call when this session has become inactive.voidpostLoad()Called on post load of the session from persistent storage.Performs a redovoidremember(EditSession editSession) Remember an edit session for the undo history.voidremember(EditSession editSession, boolean append, int limitMb) voidremember(Identifiable player, World world, ChangeSet changeSet, FaweLimit limit) booleansave()voidsetBlockChangeLimit(int maxBlocksChanged) Set the maximum number of blocks that can be changed.voidsetClipboard(ClipboardHolder clipboard) Sets the clipboard.voidsetConfiguration(LocalConfiguration config) Set the configuration.voidsetCUISupport(boolean support) Sets the status of CUI support.voidsetCUIVersion(int cuiVersion) Sets the client's CUI protocol versionvoidsetDefaultRegionSelector(RegionSelectorType defaultSelector) Set the default region selector.voidsetFastMode(boolean fastMode) Deprecated.voidsetLastDistribution(List<Countable<BlockState>> dist) Store a block distribution in this session.voidsetLastScript(String lastScript) Set the last script used.voidSet a mask.voidsetPlaceAtPos1(boolean placeAtPos1) voidsetRegionSelector(World world, RegionSelector selector) Set the region selector.voidsetReorderMode(EditSession.ReorderMode reorderMode) Deprecated.voidsetSideEffectSet(SideEffectSet sideEffectSet) Sets the side effect applier for this sessionvoidsetSnapshot(Snapshot snapshot) Select a legacy snapshot.voidsetSnapshotExperimental(Snapshot snapshotExperimental) Select a snapshot.voidsetSourceMask(Mask mask) Set a mask.voidsetSuperPickaxe(BlockTool tool) Set the super pick axe tool.voidsetTextureUtil(TextureUtil texture) voidsetTickingWatchdog(boolean tickingWatchdog) voidsetTimeout(int timeout) Set the maximum number of blocks that can be changed.voidsetTimezone(ZoneId timezone) Set the session's timezone.voidSet the tool.voidvoidvoidDeprecated.voidsetToolControl(boolean toolControl) Deprecated.The wand is now a tool that can be bound/unbound.voidsetTracingActions(boolean tracingActions) voidsetTransform(ResettableExtent transform) voidsetUseInventory(boolean useInventory) Set the state of inventory usage.voidsetUseServerCUI(boolean useServerCUI) voidsetWorldOverride(World worldOverride) booleanvoidtellVersion(Actor actor) Tell the player the WorldEdit version.booleanToggle placement position.booleanToggle the super pick axe.Performs an undo.voidupdateServerCUI(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, theIncompleteRegionExceptionexception 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, theIncompleteRegionExceptionexception 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
nullto 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
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
-
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:
getTextureUtilin interfaceTextureHolder
-
getWandItem
Deprecated.Get the preferred wand item for this user, ornullto use the default- Returns:
- item id of wand item, or
null
-
getWandBaseItem
Get the preferred wand item for this user, ornullto 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.
-