Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 11:00:05 +01:00
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.
Dieser Commit ist enthalten in:
Ursprung
25631af31c
Commit
1934006d14
@ -875,9 +875,10 @@ public class LocalSession {
|
|||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
|
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
|
||||||
.getEditSession(player.isPlayer() ? player.getWorld() : null,
|
.getEditSession(player.isPlayer() ? player.getWorld() : null,
|
||||||
getBlockChangeLimit(), blockBag, player);
|
getBlockChangeLimit(), blockBag, player);
|
||||||
|
Request.request().setEditSession(editSession);
|
||||||
|
|
||||||
editSession.setFastMode(fastMode);
|
editSession.setFastMode(fastMode);
|
||||||
editSession.setReorderMode(reorderMode);
|
editSession.setReorderMode(reorderMode);
|
||||||
Request.request().setEditSession(editSession);
|
|
||||||
editSession.setMask(mask);
|
editSession.setMask(mask);
|
||||||
|
|
||||||
return editSession;
|
return editSession;
|
||||||
|
@ -42,7 +42,6 @@ import com.sk89q.worldedit.scripting.CraftScriptContext;
|
|||||||
import com.sk89q.worldedit.scripting.CraftScriptEngine;
|
import com.sk89q.worldedit.scripting.CraftScriptEngine;
|
||||||
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
|
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
|
||||||
import com.sk89q.worldedit.session.SessionManager;
|
import com.sk89q.worldedit.session.SessionManager;
|
||||||
import com.sk89q.worldedit.session.request.Request;
|
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||||
@ -595,8 +594,6 @@ public final class WorldEdit {
|
|||||||
* @throws WorldEditException
|
* @throws WorldEditException
|
||||||
*/
|
*/
|
||||||
public void runScript(Player player, File f, String[] args) throws WorldEditException {
|
public void runScript(Player player, File f, String[] args) throws WorldEditException {
|
||||||
Request.reset();
|
|
||||||
|
|
||||||
String filename = f.getPath();
|
String filename = f.getPath();
|
||||||
int index = filename.lastIndexOf('.');
|
int index = filename.lastIndexOf('.');
|
||||||
String ext = filename.substring(index + 1);
|
String ext = filename.substring(index + 1);
|
||||||
|
@ -24,7 +24,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.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.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
@ -63,7 +62,7 @@ public class ChunkCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.chunkinfo")
|
@CommandPermissions("worldedit.chunkinfo")
|
||||||
public void chunkInfo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void chunkInfo(Player player) throws WorldEditException {
|
||||||
Location pos = player.getBlockIn();
|
Location pos = player.getBlockIn();
|
||||||
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
|
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
|
||||||
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
|
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
|
||||||
@ -87,7 +86,7 @@ public class ChunkCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.listchunks")
|
@CommandPermissions("worldedit.listchunks")
|
||||||
public void listChunks(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void listChunks(Player player, LocalSession session) throws WorldEditException {
|
||||||
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
|
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||||
|
|
||||||
for (BlockVector2 chunk : chunks) {
|
for (BlockVector2 chunk : chunks) {
|
||||||
@ -104,7 +103,7 @@ public class ChunkCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.delchunks")
|
@CommandPermissions("worldedit.delchunks")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void deleteChunks(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void deleteChunks(Player player, LocalSession session) throws WorldEditException {
|
||||||
player.print("Note that this command does not yet support the mcregion format.");
|
player.print("Note that this command does not yet support the mcregion format.");
|
||||||
LocalConfiguration config = worldEdit.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ public class ClipboardCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.flip")
|
@CommandPermissions("worldedit.clipboard.flip")
|
||||||
public void flip(Player player, LocalSession session, EditSession editSession,
|
public void flip(Player player, LocalSession session,
|
||||||
@Optional(Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException {
|
@Optional(Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException {
|
||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
AffineTransform transform = new AffineTransform();
|
AffineTransform transform = new AffineTransform();
|
||||||
@ -228,7 +228,7 @@ public class ClipboardCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.clear")
|
@CommandPermissions("worldedit.clipboard.clear")
|
||||||
public void clearClipboard(Player player, LocalSession session, EditSession editSession) throws WorldEditException {
|
public void clearClipboard(Player player, LocalSession session) throws WorldEditException {
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
player.print("Clipboard cleared.");
|
player.print("Clipboard cleared.");
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class GeneralCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.limit")
|
@CommandPermissions("worldedit.limit")
|
||||||
public void limit(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void limit(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = worldEdit.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
boolean mayDisable = player.hasPermission("worldedit.limit.unrestricted");
|
boolean mayDisable = player.hasPermission("worldedit.limit.unrestricted");
|
||||||
@ -93,7 +93,7 @@ public class GeneralCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.timeout")
|
@CommandPermissions("worldedit.timeout")
|
||||||
public void timeout(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void timeout(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = worldEdit.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
boolean mayDisable = player.hasPermission("worldedit.timeout.unrestricted");
|
boolean mayDisable = player.hasPermission("worldedit.timeout.unrestricted");
|
||||||
@ -123,7 +123,7 @@ public class GeneralCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.fast")
|
@CommandPermissions("worldedit.fast")
|
||||||
public void fast(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void fast(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
String newState = args.getString(0, null);
|
String newState = args.getString(0, null);
|
||||||
if (session.hasFastMode()) {
|
if (session.hasFastMode()) {
|
||||||
@ -153,7 +153,7 @@ public class GeneralCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.reorder")
|
@CommandPermissions("worldedit.reorder")
|
||||||
public void reorderMode(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void reorderMode(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
String newState = args.getString(0, null);
|
String newState = args.getString(0, null);
|
||||||
if (newState == null) {
|
if (newState == null) {
|
||||||
player.print("The reorder mode is " + session.getReorderMode().getDisplayName());
|
player.print("The reorder mode is " + session.getReorderMode().getDisplayName());
|
||||||
@ -213,7 +213,7 @@ public class GeneralCommands {
|
|||||||
max = -1
|
max = -1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.global-mask")
|
@CommandPermissions("worldedit.global-mask")
|
||||||
public void gmask(Player player, LocalSession session, EditSession editSession, @Optional Mask mask) throws WorldEditException {
|
public void gmask(Player player, LocalSession session, @Optional Mask mask) throws WorldEditException {
|
||||||
if (mask == null) {
|
if (mask == null) {
|
||||||
session.setMask((Mask) null);
|
session.setMask((Mask) null);
|
||||||
player.print("Global mask disabled.");
|
player.print("Global mask disabled.");
|
||||||
@ -230,7 +230,7 @@ public class GeneralCommands {
|
|||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
public void togglePlace(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void togglePlace(Player player, LocalSession session) throws WorldEditException {
|
||||||
|
|
||||||
if (session.togglePlacementPosition()) {
|
if (session.togglePlacementPosition()) {
|
||||||
player.print("Now placing at pos #1.");
|
player.print("Now placing at pos #1.");
|
||||||
|
@ -55,7 +55,7 @@ public class HistoryCommands {
|
|||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.history.undo")
|
@CommandPermissions("worldedit.history.undo")
|
||||||
public void undo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void undo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
int times = Math.max(1, args.getInteger(0, 1));
|
int times = Math.max(1, args.getInteger(0, 1));
|
||||||
for (int i = 0; i < times; ++i) {
|
for (int i = 0; i < times; ++i) {
|
||||||
EditSession undone;
|
EditSession undone;
|
||||||
@ -88,7 +88,7 @@ public class HistoryCommands {
|
|||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.history.redo")
|
@CommandPermissions("worldedit.history.redo")
|
||||||
public void redo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void redo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
int times = Math.max(1, args.getInteger(0, 1));
|
int times = Math.max(1, args.getInteger(0, 1));
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ public class HistoryCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.history.clear")
|
@CommandPermissions("worldedit.history.clear")
|
||||||
public void clearHistory(Player player, LocalSession session, EditSession editSession) throws WorldEditException {
|
public void clearHistory(Player player, LocalSession session) throws WorldEditException {
|
||||||
session.clearHistory();
|
session.clearHistory();
|
||||||
player.print("History cleared.");
|
player.print("History cleared.");
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,7 @@ import com.sk89q.minecraft.util.commands.Command;
|
|||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
@ -121,7 +119,7 @@ public class NavigationCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.navigation.ceiling")
|
@CommandPermissions("worldedit.navigation.ceiling")
|
||||||
@Logging(POSITION)
|
@Logging(POSITION)
|
||||||
public void ceiling(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void ceiling(Player player, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
final int clearance = args.argsLength() > 0 ?
|
final int clearance = args.argsLength() > 0 ?
|
||||||
Math.max(0, args.getInteger(0)) : 0;
|
Math.max(0, args.getInteger(0)) : 0;
|
||||||
@ -142,7 +140,7 @@ public class NavigationCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.navigation.thru.command")
|
@CommandPermissions("worldedit.navigation.thru.command")
|
||||||
public void thru(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void thru(Player player) throws WorldEditException {
|
||||||
if (player.passThroughForwardWall(6)) {
|
if (player.passThroughForwardWall(6)) {
|
||||||
player.print("Whoosh!");
|
player.print("Whoosh!");
|
||||||
} else {
|
} else {
|
||||||
@ -158,7 +156,7 @@ public class NavigationCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.navigation.jumpto.command")
|
@CommandPermissions("worldedit.navigation.jumpto.command")
|
||||||
public void jumpTo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void jumpTo(Player player) throws WorldEditException {
|
||||||
|
|
||||||
Location pos = player.getSolidBlockTrace(300);
|
Location pos = player.getSolidBlockTrace(300);
|
||||||
if (pos != null) {
|
if (pos != null) {
|
||||||
@ -179,7 +177,7 @@ public class NavigationCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.navigation.up")
|
@CommandPermissions("worldedit.navigation.up")
|
||||||
@Logging(POSITION)
|
@Logging(POSITION)
|
||||||
public void up(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void up(Player player, CommandContext args) throws WorldEditException {
|
||||||
final int distance = args.getInteger(0);
|
final int distance = args.getInteger(0);
|
||||||
|
|
||||||
final boolean alwaysGlass = getAlwaysGlass(args);
|
final boolean alwaysGlass = getAlwaysGlass(args);
|
||||||
|
@ -26,7 +26,6 @@ import com.sk89q.minecraft.util.commands.Command;
|
|||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -60,7 +59,7 @@ public class ScriptingCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.scripting.execute")
|
@CommandPermissions("worldedit.scripting.execute")
|
||||||
@Logging(ALL)
|
@Logging(ALL)
|
||||||
public void execute(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void execute(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
String[] scriptArgs = args.getSlice(1);
|
String[] scriptArgs = args.getSlice(1);
|
||||||
String name = args.getString(0);
|
String name = args.getString(0);
|
||||||
@ -87,7 +86,7 @@ public class ScriptingCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.scripting.execute")
|
@CommandPermissions("worldedit.scripting.execute")
|
||||||
@Logging(ALL)
|
@Logging(ALL)
|
||||||
public void executeLast(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void executeLast(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
String lastScript = session.getLastScript();
|
String lastScript = session.getLastScript();
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class SelectionCommands {
|
|||||||
)
|
)
|
||||||
@Logging(POSITION)
|
@Logging(POSITION)
|
||||||
@CommandPermissions("worldedit.selection.pos")
|
@CommandPermissions("worldedit.selection.pos")
|
||||||
public void pos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void pos1(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
Location pos;
|
Location pos;
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ public class SelectionCommands {
|
|||||||
)
|
)
|
||||||
@Logging(POSITION)
|
@Logging(POSITION)
|
||||||
@CommandPermissions("worldedit.selection.pos")
|
@CommandPermissions("worldedit.selection.pos")
|
||||||
public void pos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void pos2(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
Location pos;
|
Location pos;
|
||||||
if (args.argsLength() == 1) {
|
if (args.argsLength() == 1) {
|
||||||
@ -155,7 +155,7 @@ public class SelectionCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.selection.hpos")
|
@CommandPermissions("worldedit.selection.hpos")
|
||||||
public void hpos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void hpos1(Player player, LocalSession session) throws WorldEditException {
|
||||||
|
|
||||||
Location pos = player.getBlockTrace(300);
|
Location pos = player.getBlockTrace(300);
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ public class SelectionCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.selection.hpos")
|
@CommandPermissions("worldedit.selection.hpos")
|
||||||
public void hpos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void hpos2(Player player, LocalSession session) throws WorldEditException {
|
||||||
|
|
||||||
Location pos = player.getBlockTrace(300);
|
Location pos = player.getBlockTrace(300);
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ public class SelectionCommands {
|
|||||||
)
|
)
|
||||||
@Logging(POSITION)
|
@Logging(POSITION)
|
||||||
@CommandPermissions("worldedit.selection.chunk")
|
@CommandPermissions("worldedit.selection.chunk")
|
||||||
public void chunk(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void chunk(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
final BlockVector3 min;
|
final BlockVector3 min;
|
||||||
final BlockVector3 max;
|
final BlockVector3 max;
|
||||||
final World world = player.getWorld();
|
final World world = player.getWorld();
|
||||||
@ -277,7 +277,7 @@ public class SelectionCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.wand")
|
@CommandPermissions("worldedit.wand")
|
||||||
public void wand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void wand(Player player) throws WorldEditException {
|
||||||
|
|
||||||
player.giveItem(new BaseItemStack(ItemTypes.get(we.getConfiguration().wandItem), 1));
|
player.giveItem(new BaseItemStack(ItemTypes.get(we.getConfiguration().wandItem), 1));
|
||||||
player.print("Left click: select pos #1; Right click: select pos #2");
|
player.print("Left click: select pos #1; Right click: select pos #2");
|
||||||
@ -291,7 +291,7 @@ public class SelectionCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.wand.toggle")
|
@CommandPermissions("worldedit.wand.toggle")
|
||||||
public void toggleWand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void toggleWand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
session.setToolControl(!session.isToolControlEnabled());
|
session.setToolControl(!session.isToolControlEnabled());
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ public class SelectionCommands {
|
|||||||
)
|
)
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@CommandPermissions("worldedit.selection.expand")
|
@CommandPermissions("worldedit.selection.expand")
|
||||||
public void expand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void expand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
// Special syntax (//expand vert) to expand the selection between
|
// Special syntax (//expand vert) to expand the selection between
|
||||||
// sky and bedrock.
|
// sky and bedrock.
|
||||||
@ -406,7 +406,7 @@ public class SelectionCommands {
|
|||||||
)
|
)
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@CommandPermissions("worldedit.selection.contract")
|
@CommandPermissions("worldedit.selection.contract")
|
||||||
public void contract(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void contract(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
List<BlockVector3> dirs = new ArrayList<>();
|
List<BlockVector3> dirs = new ArrayList<>();
|
||||||
int change = args.getInteger(0);
|
int change = args.getInteger(0);
|
||||||
@ -481,7 +481,7 @@ public class SelectionCommands {
|
|||||||
)
|
)
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@CommandPermissions("worldedit.selection.shift")
|
@CommandPermissions("worldedit.selection.shift")
|
||||||
public void shift(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void shift(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
List<BlockVector3> dirs = new ArrayList<>();
|
List<BlockVector3> dirs = new ArrayList<>();
|
||||||
int change = args.getInteger(0);
|
int change = args.getInteger(0);
|
||||||
@ -529,7 +529,7 @@ public class SelectionCommands {
|
|||||||
)
|
)
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@CommandPermissions("worldedit.selection.outset")
|
@CommandPermissions("worldedit.selection.outset")
|
||||||
public void outset(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void outset(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
Region region = session.getSelection(player.getWorld());
|
Region region = session.getSelection(player.getWorld());
|
||||||
region.expand(getChangesForEachDir(args));
|
region.expand(getChangesForEachDir(args));
|
||||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||||
@ -552,7 +552,7 @@ public class SelectionCommands {
|
|||||||
)
|
)
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@CommandPermissions("worldedit.selection.inset")
|
@CommandPermissions("worldedit.selection.inset")
|
||||||
public void inset(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void inset(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
Region region = session.getSelection(player.getWorld());
|
Region region = session.getSelection(player.getWorld());
|
||||||
region.contract(getChangesForEachDir(args));
|
region.contract(getChangesForEachDir(args));
|
||||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||||
@ -588,7 +588,7 @@ public class SelectionCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.selection.size")
|
@CommandPermissions("worldedit.selection.size")
|
||||||
public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void size(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
if (args.hasFlag('c')) {
|
if (args.hasFlag('c')) {
|
||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
Clipboard clipboard = holder.getClipboard();
|
Clipboard clipboard = holder.getClipboard();
|
||||||
@ -706,7 +706,7 @@ public class SelectionCommands {
|
|||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
public void select(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void select(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
final World world = player.getWorld();
|
final World world = player.getWorld();
|
||||||
if (args.argsLength() == 0) {
|
if (args.argsLength() == 0) {
|
||||||
session.getRegionSelector(world).clear();
|
session.getRegionSelector(world).clear();
|
||||||
|
@ -24,7 +24,6 @@ package com.sk89q.worldedit.command;
|
|||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -62,7 +61,7 @@ public class SnapshotCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.snapshots.list")
|
@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();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
@ -112,7 +111,7 @@ public class SnapshotCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.snapshots.restore")
|
@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();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
@ -155,7 +154,7 @@ public class SnapshotCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.snapshots.restore")
|
@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();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
if (config.snapshotRepo == null) {
|
if (config.snapshotRepo == null) {
|
||||||
@ -202,7 +201,7 @@ public class SnapshotCommands {
|
|||||||
max = -1
|
max = -1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.snapshots.restore")
|
@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();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
@ -241,7 +240,7 @@ public class SnapshotCommands {
|
|||||||
max = -1
|
max = -1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.snapshots.restore")
|
@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();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ package com.sk89q.worldedit.command;
|
|||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -47,7 +46,7 @@ public class SuperPickaxeCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.superpickaxe")
|
@CommandPermissions("worldedit.superpickaxe")
|
||||||
public void single(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void single(Player player, LocalSession session) throws WorldEditException {
|
||||||
|
|
||||||
session.setSuperPickaxe(new SinglePickaxe());
|
session.setSuperPickaxe(new SinglePickaxe());
|
||||||
session.enableSuperPickAxe();
|
session.enableSuperPickAxe();
|
||||||
@ -62,7 +61,7 @@ public class SuperPickaxeCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.superpickaxe.area")
|
@CommandPermissions("worldedit.superpickaxe.area")
|
||||||
public void area(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void area(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
int range = args.getInteger(0);
|
int range = args.getInteger(0);
|
||||||
@ -85,7 +84,7 @@ public class SuperPickaxeCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.superpickaxe.recursive")
|
@CommandPermissions("worldedit.superpickaxe.recursive")
|
||||||
public void recursive(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void recursive(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
double range = args.getDouble(0);
|
double range = args.getDouble(0);
|
||||||
|
@ -22,7 +22,6 @@ package com.sk89q.worldedit.command;
|
|||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -56,7 +55,7 @@ public class ToolCommands {
|
|||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
public void none(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void none(Player player, LocalSession session) throws WorldEditException {
|
||||||
|
|
||||||
session.setTool(player.getItemInHand(HandSide.MAIN_HAND).getType(), null);
|
session.setTool(player.getItemInHand(HandSide.MAIN_HAND).getType(), null);
|
||||||
player.print("Tool unbound from your current item.");
|
player.print("Tool unbound from your current item.");
|
||||||
@ -70,7 +69,7 @@ public class ToolCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.tool.info")
|
@CommandPermissions("worldedit.tool.info")
|
||||||
public void info(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void info(Player player, LocalSession session) throws WorldEditException {
|
||||||
|
|
||||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||||
session.setTool(itemStack.getType(), new QueryTool());
|
session.setTool(itemStack.getType(), new QueryTool());
|
||||||
@ -86,7 +85,7 @@ public class ToolCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.tool.tree")
|
@CommandPermissions("worldedit.tool.tree")
|
||||||
public void tree(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void tree(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
TreeGenerator.TreeType type = args.argsLength() > 0
|
TreeGenerator.TreeType type = args.argsLength() > 0
|
||||||
? TreeGenerator.lookup(args.getString(0))
|
? TreeGenerator.lookup(args.getString(0))
|
||||||
@ -124,7 +123,7 @@ public class ToolCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.tool.data-cycler")
|
@CommandPermissions("worldedit.tool.data-cycler")
|
||||||
public void cycler(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void cycler(Player player, LocalSession session) throws WorldEditException {
|
||||||
|
|
||||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||||
session.setTool(itemStack.getType(), new BlockDataCyler());
|
session.setTool(itemStack.getType(), new BlockDataCyler());
|
||||||
@ -161,7 +160,7 @@ public class ToolCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.tool.deltree")
|
@CommandPermissions("worldedit.tool.deltree")
|
||||||
public void deltree(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void deltree(Player player, LocalSession session) throws WorldEditException {
|
||||||
|
|
||||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||||
session.setTool(itemStack.getType(), new FloatingTreeRemover());
|
session.setTool(itemStack.getType(), new FloatingTreeRemover());
|
||||||
@ -177,7 +176,7 @@ public class ToolCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.tool.farwand")
|
@CommandPermissions("worldedit.tool.farwand")
|
||||||
public void farwand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void farwand(Player player, LocalSession session) throws WorldEditException {
|
||||||
|
|
||||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||||
session.setTool(itemStack.getType(), new DistanceWand());
|
session.setTool(itemStack.getType(), new DistanceWand());
|
||||||
|
@ -22,7 +22,6 @@ package com.sk89q.worldedit.command;
|
|||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -50,7 +49,7 @@ public class ToolUtilCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.superpickaxe")
|
@CommandPermissions("worldedit.superpickaxe")
|
||||||
public void togglePickaxe(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void togglePickaxe(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
String newState = args.getString(0, null);
|
String newState = args.getString(0, null);
|
||||||
if (session.hasSuperPickAxe()) {
|
if (session.hasSuperPickAxe()) {
|
||||||
@ -80,7 +79,7 @@ public class ToolUtilCommands {
|
|||||||
max = -1
|
max = -1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.options.mask")
|
@CommandPermissions("worldedit.brush.options.mask")
|
||||||
public void mask(Player player, LocalSession session, EditSession editSession, @Optional Mask mask) throws WorldEditException {
|
public void mask(Player player, LocalSession session, @Optional Mask mask) throws WorldEditException {
|
||||||
if (mask == null) {
|
if (mask == null) {
|
||||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setMask(null);
|
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setMask(null);
|
||||||
player.print("Brush mask disabled.");
|
player.print("Brush mask disabled.");
|
||||||
@ -98,7 +97,7 @@ public class ToolUtilCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.options.material")
|
@CommandPermissions("worldedit.brush.options.material")
|
||||||
public void material(Player player, LocalSession session, EditSession editSession, Pattern pattern) throws WorldEditException {
|
public void material(Player player, LocalSession session, Pattern pattern) throws WorldEditException {
|
||||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setFill(pattern);
|
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setFill(pattern);
|
||||||
player.print("Brush material set.");
|
player.print("Brush material set.");
|
||||||
}
|
}
|
||||||
@ -111,7 +110,7 @@ public class ToolUtilCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.options.range")
|
@CommandPermissions("worldedit.brush.options.range")
|
||||||
public void range(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void range(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
int range = args.getInteger(0);
|
int range = args.getInteger(0);
|
||||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setRange(range);
|
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setRange(range);
|
||||||
player.print("Brush range set.");
|
player.print("Brush range set.");
|
||||||
@ -125,7 +124,7 @@ public class ToolUtilCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.options.size")
|
@CommandPermissions("worldedit.brush.options.size")
|
||||||
public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void size(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
int radius = args.getInteger(0);
|
int radius = args.getInteger(0);
|
||||||
we.checkMaxBrushRadius(radius);
|
we.checkMaxBrushRadius(radius);
|
||||||
|
@ -23,7 +23,6 @@ import com.google.common.io.Files;
|
|||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -126,7 +125,7 @@ public class WorldEditCommands {
|
|||||||
min = 0,
|
min = 0,
|
||||||
max = 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.setCUISupport(true);
|
||||||
session.dispatchCUISetup(player);
|
session.dispatchCUISetup(player);
|
||||||
}
|
}
|
||||||
@ -138,7 +137,7 @@ public class WorldEditCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 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));
|
TimeZone tz = TimeZone.getTimeZone(args.getString(0));
|
||||||
session.setTimezone(tz);
|
session.setTimezone(tz);
|
||||||
player.print("Timezone set for this session to: " + tz.getDisplayName());
|
player.print("Timezone set for this session to: " + tz.getDisplayName());
|
||||||
|
@ -173,7 +173,6 @@ public class BrushTool implements TraceTool {
|
|||||||
BlockBag bag = session.getBlockBag(player);
|
BlockBag bag = session.getBlockBag(player);
|
||||||
|
|
||||||
try (EditSession editSession = session.createEditSession(player)) {
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
Request.request().setEditSession(editSession);
|
|
||||||
if (mask != null) {
|
if (mask != null) {
|
||||||
Mask existingMask = editSession.getMask();
|
Mask existingMask = editSession.getMask();
|
||||||
|
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extension.platform;
|
package com.sk89q.worldedit.extension.platform;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.sk89q.worldedit.util.command.composition.LegacyCommandAdapter.adapt;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||||
@ -54,8 +57,10 @@ import com.sk89q.worldedit.command.composition.DeformCommand;
|
|||||||
import com.sk89q.worldedit.command.composition.PaintCommand;
|
import com.sk89q.worldedit.command.composition.PaintCommand;
|
||||||
import com.sk89q.worldedit.command.composition.SelectionCommand;
|
import com.sk89q.worldedit.command.composition.SelectionCommand;
|
||||||
import com.sk89q.worldedit.command.composition.ShapedBrushCommand;
|
import com.sk89q.worldedit.command.composition.ShapedBrushCommand;
|
||||||
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||||
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
|
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.factory.Deform;
|
import com.sk89q.worldedit.function.factory.Deform;
|
||||||
import com.sk89q.worldedit.function.factory.Deform.Mode;
|
import com.sk89q.worldedit.function.factory.Deform.Mode;
|
||||||
import com.sk89q.worldedit.internal.command.ActorAuthorizer;
|
import com.sk89q.worldedit.internal.command.ActorAuthorizer;
|
||||||
@ -76,6 +81,7 @@ import com.sk89q.worldedit.util.formatting.ColorCodeBuilder;
|
|||||||
import com.sk89q.worldedit.util.formatting.component.CommandUsageBox;
|
import com.sk89q.worldedit.util.formatting.component.CommandUsageBox;
|
||||||
import com.sk89q.worldedit.util.logging.DynamicStreamHandler;
|
import com.sk89q.worldedit.util.logging.DynamicStreamHandler;
|
||||||
import com.sk89q.worldedit.util.logging.LogFormat;
|
import com.sk89q.worldedit.util.logging.LogFormat;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -85,9 +91,6 @@ import java.util.logging.FileHandler;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.sk89q.worldedit.util.command.composition.LegacyCommandAdapter.adapt;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the registration and invocation of commands.
|
* Handles the registration and invocation of commands.
|
||||||
*
|
*
|
||||||
@ -260,6 +263,13 @@ public final class CommandManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LocalSession session = worldEdit.getSessionManager().get(actor);
|
LocalSession session = worldEdit.getSessionManager().get(actor);
|
||||||
|
Request.request().setSession(session);
|
||||||
|
if (actor instanceof Entity) {
|
||||||
|
Extent extent = ((Entity) actor).getExtent();
|
||||||
|
if (extent instanceof World) {
|
||||||
|
Request.request().setWorld(((World) extent));
|
||||||
|
}
|
||||||
|
}
|
||||||
LocalConfiguration config = worldEdit.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
|
|
||||||
CommandLocals locals = new CommandLocals();
|
CommandLocals locals = new CommandLocals();
|
||||||
@ -335,6 +345,7 @@ public final class CommandManager {
|
|||||||
|
|
||||||
worldEdit.flushBlockBag(actor, editSession);
|
worldEdit.flushBlockBag(actor, editSession);
|
||||||
}
|
}
|
||||||
|
Request.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -38,6 +38,7 @@ import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
|
import com.sk89q.worldedit.session.request.Request;
|
||||||
import com.sk89q.worldedit.util.HandSide;
|
import com.sk89q.worldedit.util.HandSide;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||||
@ -314,70 +315,78 @@ public class PlatformManager {
|
|||||||
Player player = (Player) actor;
|
Player player = (Player) actor;
|
||||||
LocalSession session = worldEdit.getSessionManager().get(actor);
|
LocalSession session = worldEdit.getSessionManager().get(actor);
|
||||||
|
|
||||||
if (event.getType() == Interaction.HIT) {
|
Request.reset();
|
||||||
if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) {
|
Request.request().setSession(session);
|
||||||
if (!session.isToolControlEnabled()) {
|
Request.request().setWorld(player.getWorld());
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!actor.hasPermission("worldedit.selection.pos")) {
|
try {
|
||||||
return;
|
if (event.getType() == Interaction.HIT) {
|
||||||
}
|
if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) {
|
||||||
|
if (!session.isToolControlEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
if (!actor.hasPermission("worldedit.selection.pos")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BlockVector3 blockPoint = vector.toBlockPoint();
|
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
|
||||||
selector.explainPrimarySelection(actor, session, blockPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
BlockVector3 blockPoint = vector.toBlockPoint();
|
||||||
return;
|
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||||
}
|
selector.explainPrimarySelection(actor, session, blockPoint);
|
||||||
|
}
|
||||||
|
|
||||||
if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) {
|
|
||||||
final BlockTool superPickaxe = session.getSuperPickaxe();
|
|
||||||
if (superPickaxe != null && superPickaxe.canUse(player)) {
|
|
||||||
event.setCancelled(superPickaxe.actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
|
||||||
if (tool instanceof DoubleActionBlockTool) {
|
|
||||||
if (tool.canUse(player)) {
|
|
||||||
((DoubleActionBlockTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (event.getType() == Interaction.OPEN) {
|
|
||||||
if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) {
|
|
||||||
if (!session.isToolControlEnabled()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!actor.hasPermission("worldedit.selection.pos")) {
|
if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) {
|
||||||
return;
|
final BlockTool superPickaxe = session.getSuperPickaxe();
|
||||||
|
if (superPickaxe != null && superPickaxe.canUse(player)) {
|
||||||
|
event.setCancelled(superPickaxe.actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||||
BlockVector3 blockPoint = vector.toBlockPoint();
|
if (tool instanceof DoubleActionBlockTool) {
|
||||||
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
if (tool.canUse(player)) {
|
||||||
selector.explainSecondarySelection(actor, session, blockPoint);
|
((DoubleActionBlockTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
} else if (event.getType() == Interaction.OPEN) {
|
||||||
return;
|
if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) {
|
||||||
}
|
if (!session.isToolControlEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!actor.hasPermission("worldedit.selection.pos")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
|
BlockVector3 blockPoint = vector.toBlockPoint();
|
||||||
|
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||||
|
selector.explainSecondarySelection(actor, session, blockPoint);
|
||||||
|
}
|
||||||
|
|
||||||
Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
|
||||||
if (tool instanceof BlockTool) {
|
|
||||||
if (tool.canUse(player)) {
|
|
||||||
((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||||
|
if (tool instanceof BlockTool) {
|
||||||
|
if (tool.canUse(player)) {
|
||||||
|
((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
Request.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -387,74 +396,78 @@ public class PlatformManager {
|
|||||||
// Create a proxy actor with a potentially different world for
|
// Create a proxy actor with a potentially different world for
|
||||||
// making changes to the world
|
// making changes to the world
|
||||||
Player player = createProxyActor(event.getPlayer());
|
Player player = createProxyActor(event.getPlayer());
|
||||||
|
LocalSession session = worldEdit.getSessionManager().get(player);
|
||||||
|
Request.reset();
|
||||||
|
Request.request().setSession(session);
|
||||||
|
Request.request().setWorld(player.getWorld());
|
||||||
|
|
||||||
switch (event.getInputType()) {
|
try {
|
||||||
case PRIMARY: {
|
switch (event.getInputType()) {
|
||||||
if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().navigationWand)) {
|
case PRIMARY: {
|
||||||
if (getConfiguration().navigationWandMaxDistance <= 0) {
|
if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().navigationWand)) {
|
||||||
return;
|
if (getConfiguration().navigationWandMaxDistance <= 0) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!player.hasPermission("worldedit.navigation.jumpto.tool")) {
|
if (!player.hasPermission("worldedit.navigation.jumpto.tool")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location pos = player.getSolidBlockTrace(getConfiguration().navigationWandMaxDistance);
|
Location pos = player.getSolidBlockTrace(getConfiguration().navigationWandMaxDistance);
|
||||||
if (pos != null) {
|
if (pos != null) {
|
||||||
player.findFreePosition(pos);
|
player.findFreePosition(pos);
|
||||||
} else {
|
} else {
|
||||||
player.printError("No block in sight (or too far)!");
|
player.printError("No block in sight (or too far)!");
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalSession session = worldEdit.getSessionManager().get(player);
|
|
||||||
|
|
||||||
Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
|
||||||
if (tool instanceof DoubleActionTraceTool) {
|
|
||||||
if (tool.canUse(player)) {
|
|
||||||
((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||||
|
if (tool instanceof DoubleActionTraceTool) {
|
||||||
|
if (tool.canUse(player)) {
|
||||||
|
((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
case SECONDARY: {
|
||||||
}
|
if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().navigationWand)) {
|
||||||
|
if (getConfiguration().navigationWandMaxDistance <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
case SECONDARY: {
|
if (!player.hasPermission("worldedit.navigation.thru.tool")) {
|
||||||
if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().navigationWand)) {
|
return;
|
||||||
if (getConfiguration().navigationWandMaxDistance <= 0) {
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!player.hasPermission("worldedit.navigation.thru.tool")) {
|
if (!player.passThroughForwardWall(40)) {
|
||||||
return;
|
player.printError("Nothing to pass through!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.passThroughForwardWall(40)) {
|
|
||||||
player.printError("Nothing to pass through!");
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalSession session = worldEdit.getSessionManager().get(player);
|
|
||||||
|
|
||||||
Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
|
||||||
if (tool instanceof TraceTool) {
|
|
||||||
if (tool.canUse(player)) {
|
|
||||||
((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||||
|
if (tool instanceof TraceTool) {
|
||||||
|
if (tool.canUse(player)) {
|
||||||
|
((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
Request.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ import com.sk89q.worldedit.entity.Player;
|
|||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.session.request.Request;
|
||||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
@ -65,6 +66,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
|||||||
EditSession editSession = controller.getEditSessionFactory()
|
EditSession editSession = controller.getEditSessionFactory()
|
||||||
.getEditSession(player.getWorld(),
|
.getEditSession(player.getWorld(),
|
||||||
session.getBlockChangeLimit(), session.getBlockBag(player), player);
|
session.getBlockChangeLimit(), session.getBlockBag(player), player);
|
||||||
|
Request.request().setEditSession(editSession);
|
||||||
editSession.enableStandardMode();
|
editSession.enableStandardMode();
|
||||||
editSessions.add(editSession);
|
editSessions.add(editSession);
|
||||||
return editSession;
|
return editSession;
|
||||||
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.LocalSession;
|
|||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
|
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
|
||||||
|
import com.sk89q.worldedit.session.request.Request;
|
||||||
import com.sk89q.worldedit.session.storage.JsonFileSessionStore;
|
import com.sk89q.worldedit.session.storage.JsonFileSessionStore;
|
||||||
import com.sk89q.worldedit.session.storage.SessionStore;
|
import com.sk89q.worldedit.session.storage.SessionStore;
|
||||||
import com.sk89q.worldedit.session.storage.VoidStore;
|
import com.sk89q.worldedit.session.storage.VoidStore;
|
||||||
@ -151,6 +152,7 @@ public class SessionManager {
|
|||||||
log.warn("Failed to load saved session", e);
|
log.warn("Failed to load saved session", e);
|
||||||
session = new LocalSession();
|
session = new LocalSession();
|
||||||
}
|
}
|
||||||
|
Request.request().setSession(session);
|
||||||
|
|
||||||
session.setConfiguration(config);
|
session.setConfiguration(config);
|
||||||
session.setBlockChangeLimit(config.defaultChangeLimit);
|
session.setBlockChangeLimit(config.defaultChangeLimit);
|
||||||
@ -313,7 +315,7 @@ public class SessionManager {
|
|||||||
/**
|
/**
|
||||||
* Stores the owner of a session, the session, and the last active time.
|
* Stores the owner of a session, the session, and the last active time.
|
||||||
*/
|
*/
|
||||||
private static class SessionHolder {
|
private static final class SessionHolder {
|
||||||
private final SessionKey key;
|
private final SessionKey key;
|
||||||
private final LocalSession session;
|
private final LocalSession session;
|
||||||
private long lastActive = System.currentTimeMillis();
|
private long lastActive = System.currentTimeMillis();
|
||||||
|
@ -35,6 +35,7 @@ public final class Request {
|
|||||||
private @Nullable World world;
|
private @Nullable World world;
|
||||||
private @Nullable LocalSession session;
|
private @Nullable LocalSession session;
|
||||||
private @Nullable EditSession editSession;
|
private @Nullable EditSession editSession;
|
||||||
|
private boolean valid;
|
||||||
|
|
||||||
private Request() {
|
private Request() {
|
||||||
}
|
}
|
||||||
@ -106,6 +107,20 @@ public final class Request {
|
|||||||
* Reset the current request and clear all fields.
|
* Reset the current request and clear all fields.
|
||||||
*/
|
*/
|
||||||
public static void reset() {
|
public static void reset() {
|
||||||
|
request().invalidate();
|
||||||
threadLocal.remove();
|
threadLocal.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the current request object is still valid. Invalid requests may contain outdated values.
|
||||||
|
*
|
||||||
|
* @return true if the request is valid
|
||||||
|
*/
|
||||||
|
public boolean isValid() {
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void invalidate() {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,13 +39,13 @@ import java.util.List;
|
|||||||
|
|
||||||
public class RequestExtent implements Extent {
|
public class RequestExtent implements Extent {
|
||||||
|
|
||||||
private EditSession extent;
|
private Request request;
|
||||||
|
|
||||||
protected Extent getExtent() {
|
protected Extent getExtent() {
|
||||||
if (extent == null) {
|
if (request == null || !request.isValid()) {
|
||||||
extent = Request.request().getEditSession();
|
request = Request.request();
|
||||||
}
|
}
|
||||||
return extent;
|
return request.getEditSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -103,7 +103,7 @@ public class RequestExtent implements Extent {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public Operation commit() {
|
public Operation commit() {
|
||||||
Operation commit = getExtent().commit();
|
Operation commit = getExtent().commit();
|
||||||
extent = null;
|
request = null;
|
||||||
return commit;
|
return commit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren