Better enforce the Request lifetime.

Previously, the current request would just get a new EditSession when
one was created. Now, a Request is reset before and after:
 - a command is used and
 - an interact is fired with the platform
This means each action taken will get a single, non-reusable Request.

Note that this only applies to actions taken through the platform.
API users will not be using requests anyway, since things like Masks,
etc. will be constructed directly instead of being passed through the
platform's parsers and so on. (e.g. if a plugin loads a schematic into
the world with a mask, they should create the EditSession and mask it
directly, and not use that Mask again for another EditSession in another
World).

Also, get rid of a bunch of (some now-)unnecessary EditSession creation
during command dispatching.

Note that this also fixed the dynamic selection mask, which apparently
has been broken for some unknown amount of time.
This commit is contained in:
wizjany
2019-03-16 19:04:24 -04:00
parent 25631af31c
commit 1934006d14
22 changed files with 207 additions and 177 deletions

View File

@ -24,7 +24,6 @@ package com.sk89q.worldedit.command;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
@ -62,7 +61,7 @@ public class SnapshotCommands {
max = 1
)
@CommandPermissions("worldedit.snapshots.list")
public void list(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
public void list(Player player, CommandContext args) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -112,7 +111,7 @@ public class SnapshotCommands {
max = 1
)
@CommandPermissions("worldedit.snapshots.restore")
public void use(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
public void use(Player player, LocalSession session, CommandContext args) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -155,7 +154,7 @@ public class SnapshotCommands {
max = 1
)
@CommandPermissions("worldedit.snapshots.restore")
public void sel(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
public void sel(Player player, LocalSession session, CommandContext args) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
@ -202,7 +201,7 @@ public class SnapshotCommands {
max = -1
)
@CommandPermissions("worldedit.snapshots.restore")
public void before(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
public void before(Player player, LocalSession session, CommandContext args) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -241,7 +240,7 @@ public class SnapshotCommands {
max = -1
)
@CommandPermissions("worldedit.snapshots.restore")
public void after(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
public void after(Player player, LocalSession session, CommandContext args) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();