public class LocalSession
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
MAX_HISTORY_SIZE |
Constructor and Description |
---|
LocalSession()
Construct the object.
|
LocalSession(LocalConfiguration config)
Construct the object.
|
Modifier and Type | Method and Description |
---|---|
void |
clearHistory()
Clear history.
|
boolean |
compareAndResetDirty()
Get whether this session is "dirty" and has changes that needs to
be committed, and reset it to
false . |
EditSession |
createEditSession(Actor actor)
Construct a new edit session.
|
void |
describeCUI(Actor actor)
Describe the selection to the CUI actor.
|
java.util.Calendar |
detectDate(java.lang.String input)
Detect date from a user's input.
|
void |
disableSuperPickAxe()
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 |
enableSuperPickAxe()
Enable super pick axe.
|
BlockBag |
getBlockBag(Player player)
Get a block bag for a player.
|
int |
getBlockChangeLimit()
Get the maximum number of blocks that can be changed in an edit session.
|
BrushTool |
getBrushTool(ItemType item)
Get the brush tool assigned to the item.
|
ClipboardHolder |
getClipboard()
Gets the clipboard.
|
int |
getCUIVersion()
Gets the client's CUI protocol version.
|
RegionSelectorType |
getDefaultRegionSelector()
Get the default region selector.
|
java.util.List<Countable<BlockState>> |
getLastDistribution()
Get the last block distribution stored in this session.
|
java.lang.String |
getLastScript()
Get the last script used.
|
Mask |
getMask()
Get the mask.
|
java.lang.String |
getNavWandItem()
Get the preferred navigation wand item for this user, or
null to use the default. |
BlockVector3 |
getPlacementPosition(Actor actor)
Get the position use for commands that take a center point
(i.e.
|
RegionSelector |
getRegionSelector(World world)
Get the region selector for defining the selection.
|
EditSession.ReorderMode |
getReorderMode()
Gets the reorder mode of the session.
|
Region |
getSelection()
Get the selection region.
|
Region |
getSelection(World world)
Get the selection region.
|
World |
getSelectionWorld()
Get the selection world.
|
SideEffectSet |
getSideEffectSet()
Gets the side effect applier of this session.
|
Snapshot |
getSnapshot()
Get the legacy snapshot that has been selected.
|
Snapshot |
getSnapshotExperimental()
Get the snapshot that has been selected.
|
BlockTool |
getSuperPickaxe()
Get the assigned block tool.
|
int |
getTimeout()
Get the maximum time allowed for certain executions to run before cancelling them, such as expressions.
|
java.time.ZoneId |
getTimeZone()
Get the session's timezone.
|
Tool |
getTool(ItemType item)
Get the tool assigned to the item.
|
java.lang.String |
getWandItem()
Get the preferred wand item for this user, or
null to use the default. |
World |
getWorldOverride() |
void |
handleCUIInitializationMessage(java.lang.String text,
Actor actor)
Handle a CUI initialization message.
|
boolean |
hasCUISupport()
Gets the status of CUI support.
|
boolean |
hasFastMode()
Deprecated.
|
boolean |
hasSuperPickAxe()
Checks whether the super pick axe is enabled.
|
boolean |
hasWorldOverride() |
boolean |
isDirty()
Get whether this session is "dirty" and has changes that needs to
be committed.
|
boolean |
isNavWandItemDefault()
Get if the navigation wand item should use the default, or null if unknown.
|
boolean |
isPlaceAtPos1() |
boolean |
isSelectionDefined(World world)
Returns true if the region is fully defined for the specified world.
|
boolean |
isTickingWatchdog() |
boolean |
isToolControlEnabled()
Deprecated.
The wand is now a tool that can be bound/unbound.
|
boolean |
isTracingActions() |
boolean |
isUsingInventory()
Returns whether inventory usage is enabled for this session.
|
boolean |
isWandItemDefault()
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.
|
EditSession |
redo(BlockBag newBlockBag,
Actor actor)
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(java.util.List<Countable<BlockState>> dist)
Store a block distribution in this session.
|
void |
setLastScript(java.lang.String lastScript)
Set the last script used.
|
void |
setMask(Mask mask)
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 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(java.time.ZoneId timezone)
Set the session's timezone.
|
void |
setTool(ItemType item,
Tool tool)
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 |
shouldUseServerCUI() |
void |
tellVersion(Actor actor)
Tell the player the WorldEdit version.
|
boolean |
togglePlacementPosition()
Toggle placement position.
|
boolean |
toggleSuperPickAxe()
Toggle the super pick axe.
|
EditSession |
undo(BlockBag newBlockBag,
Actor actor)
Performs an undo.
|
void |
updateServerCUI(Actor actor)
Update server-side WorldEdit CUI.
|
public LocalSession()
setConfiguration(LocalConfiguration)
should be called
later with configuration.
public LocalSession(@Nullable LocalConfiguration config)
config
- the configurationpublic void setConfiguration(LocalConfiguration config)
config
- the configurationpublic void postLoad()
public boolean isDirty()
public boolean compareAndResetDirty()
false
.true
public java.time.ZoneId getTimeZone()
public void setTimezone(java.time.ZoneId timezone)
timezone
- the user's timezonepublic void clearHistory()
public void remember(EditSession editSession)
editSession
- the edit sessionpublic EditSession undo(@Nullable BlockBag newBlockBag, Actor actor)
newBlockBag
- a new block bagactor
- the actorpublic EditSession redo(@Nullable BlockBag newBlockBag, Actor actor)
newBlockBag
- a new block bagactor
- the actorpublic boolean hasWorldOverride()
@Nullable public World getWorldOverride()
public void setWorldOverride(@Nullable World worldOverride)
public boolean isTickingWatchdog()
public void setTickingWatchdog(boolean tickingWatchdog)
public boolean isTracingActions()
public void setTracingActions(boolean tracingActions)
public RegionSelectorType getDefaultRegionSelector()
public void setDefaultRegionSelector(RegionSelectorType defaultSelector)
defaultSelector
- the default region selectorpublic RegionSelector getRegionSelector(World world)
world
- the worldpublic void setRegionSelector(World world, RegionSelector selector)
world
- the worldselector
- the selectorpublic boolean isSelectionDefined(World world)
world
- the worldpublic Region getSelection() throws IncompleteRegionException
IncompleteRegionException
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.
IncompleteRegionException
- if the region is not fully definedpublic Region getSelection(@Nullable World world) throws IncompleteRegionException
IncompleteRegionException
exception will be thrown.world
- the worldIncompleteRegionException
- if no region is selected, or the provided world is null@Nullable public World getSelectionWorld()
public ClipboardHolder getClipboard() throws EmptyClipboardException
EmptyClipboardException
- thrown if no clipboard is setpublic void setClipboard(@Nullable ClipboardHolder clipboard)
Pass null
to clear the clipboard.
clipboard
- the clipboard, or null if the clipboard is to be cleared@Deprecated public boolean isToolControlEnabled()
@Deprecated public void setToolControl(boolean toolControl)
toolControl
- unused - see deprecation noticepublic int getBlockChangeLimit()
public void setBlockChangeLimit(int maxBlocksChanged)
maxBlocksChanged
- the maximum number of blocks changedpublic int getTimeout()
public void setTimeout(int timeout)
timeout
- the time, in milliseconds, to limit certain executions to, or -1 to disablepublic boolean hasSuperPickAxe()
public void enableSuperPickAxe()
public void disableSuperPickAxe()
public boolean toggleSuperPickAxe()
public BlockVector3 getPlacementPosition(Actor actor) throws IncompleteRegionException
actor
- the actorIncompleteRegionException
- thrown if a region is not fully selectedpublic void setPlaceAtPos1(boolean placeAtPos1)
public boolean isPlaceAtPos1()
public boolean togglePlacementPosition()
@Nullable public BlockBag getBlockBag(Player player)
player
- the player to get the block bag for@Nullable public Snapshot getSnapshot()
public void setSnapshot(@Nullable Snapshot snapshot)
snapshot
- a legacy snapshot@Nullable public Snapshot getSnapshotExperimental()
public void setSnapshotExperimental(@Nullable Snapshot snapshotExperimental)
snapshotExperimental
- a snapshotpublic BlockTool getSuperPickaxe()
public void setSuperPickaxe(BlockTool tool)
tool
- the tool to set@Nullable public Tool getTool(ItemType item)
item
- the item typenull
public BrushTool getBrushTool(ItemType item) throws InvalidToolBindException
item
- the item typenull
InvalidToolBindException
- if the item can't be bound to that itempublic void setTool(ItemType item, @Nullable Tool tool) throws InvalidToolBindException
item
- the item typetool
- the tool to set, which can be null
InvalidToolBindException
- if the item can't be bound to that itempublic boolean isUsingInventory()
public void setUseInventory(boolean useInventory)
useInventory
- if inventory is to be used@Nullable public java.lang.String getLastScript()
public void setLastScript(@Nullable java.lang.String lastScript)
lastScript
- the last script's namepublic void tellVersion(Actor actor)
actor
- the actorpublic boolean shouldUseServerCUI()
public void setUseServerCUI(boolean useServerCUI)
public void updateServerCUI(Actor actor)
actor
- The playerpublic void dispatchCUIEvent(Actor actor, CUIEvent event)
actor
- the actorevent
- the eventpublic void dispatchCUISetup(Actor actor)
actor
- the actorpublic void dispatchCUISelection(Actor actor)
actor
- the actorpublic void describeCUI(Actor actor)
actor
- the actorpublic void handleCUIInitializationMessage(java.lang.String text, Actor actor)
text
- the messagepublic boolean hasCUISupport()
public void setCUISupport(boolean support)
support
- true if CUI is enabledpublic int getCUIVersion()
public void setCUIVersion(int cuiVersion)
cuiVersion
- the CUI version@Nullable public java.util.Calendar detectDate(java.lang.String input)
input
- the input to parsepublic EditSession createEditSession(Actor actor)
actor
- the actorpublic SideEffectSet getSideEffectSet()
public void setSideEffectSet(SideEffectSet sideEffectSet)
sideEffectSet
- the side effect applier@Deprecated public boolean hasFastMode()
@Deprecated public void setFastMode(boolean fastMode)
fastMode
- true if fast mode is enabledpublic EditSession.ReorderMode getReorderMode()
public void setReorderMode(EditSession.ReorderMode reorderMode)
reorderMode
- The reorder modepublic Mask getMask()
public void setMask(Mask mask)
mask
- mask or nullpublic java.lang.String getWandItem()
null
to use the default.null
public boolean isWandItemDefault()
public java.lang.String getNavWandItem()
null
to use the default.null
public boolean isNavWandItemDefault()
public java.util.List<Countable<BlockState>> getLastDistribution()
null
public void setLastDistribution(java.util.List<Countable<BlockState>> dist)
public void onIdle()
This is for internal use only.