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

@ -23,7 +23,6 @@ import com.google.common.io.Files;
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.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
@ -126,7 +125,7 @@ public class WorldEditCommands {
min = 0,
max = 0
)
public void cui(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
public void cui(Player player, LocalSession session) throws WorldEditException {
session.setCUISupport(true);
session.dispatchCUISetup(player);
}
@ -138,7 +137,7 @@ public class WorldEditCommands {
min = 1,
max = 1
)
public void tz(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
public void tz(Player player, LocalSession session, CommandContext args) throws WorldEditException {
TimeZone tz = TimeZone.getTimeZone(args.getString(0));
session.setTimezone(tz);
player.print("Timezone set for this session to: " + tz.getDisplayName());