public class EditSessionEvent extends Event
EditSession
is being instantiated.
Block loggers, as well as block set interceptors, can use this event to wrap
the given Extent
with their own, which would allow them to intercept
all changes made to the world. For example, the code below would wrap the
existing extent with a custom one, and the custom extent would receive
all method calls before the extent fetched from
getExtent()
would.
event.setExtent(new MyExtent(event.getExtent())This event is fired several times during the creation of a single
EditSession
, but getStage()
will differ each time.
The stage determines at which point Extent
s added to this event
will be called. For example, if you inject an extent when the stage
is set to EditSession.Stage.BEFORE_HISTORY
, then you can drop (or log) changes
before the change has reached the history, reordering, and actual change
extents, but that means that any changes made with
EditSession.rawSetBlock(Vector, BaseBlock)
will skip your
custom Extent
because that method bypasses history (and reorder).
It is thus recommended that loggers intercept at EditSession.Stage.BEFORE_CHANGE
and block interceptors intercept at BOTH EditSession.Stage.BEFORE_CHANGE
and
EditSession.Stage.BEFORE_HISTORY
.Constructor and Description |
---|
EditSessionEvent(World world,
Actor actor,
int maxBlocks,
EditSession.Stage stage)
Create a new event.
|
Modifier and Type | Method and Description |
---|---|
EditSessionEvent |
clone(EditSession.Stage stage)
Create a clone of this event with the given stage.
|
Actor |
getActor()
Get the actor for this event.
|
Extent |
getExtent()
Get the
Extent that can be wrapped. |
int |
getMaxBlocks()
Get the maximum number of blocks that may be set.
|
EditSession.Stage |
getStage()
Get the stage that is being wrapped.
|
World |
getWorld()
Get the world.
|
void |
setExtent(Extent extent)
Set a new extent that should be used.
|
public EditSessionEvent(@Nullable World world, Actor actor, int maxBlocks, EditSession.Stage stage)
world
- the worldactor
- the actor, or null if there is no actor specifiedmaxBlocks
- the maximum number of block changesstage
- the stage@Nullable public Actor getActor()
@Nullable public World getWorld()
public int getMaxBlocks()
public EditSession.Stage getStage()
public void setExtent(Extent extent)
getExtent()
.extent
- the extentpublic EditSessionEvent clone(EditSession.Stage stage)
stage
- the stage