Some command fixes

Fix EditSession being created for commands that don't need it
Fix error from schematic list (when there are files in sub directories)
Fix dispatcher redundantly checking a huge number of permissions
This commit is contained in:
Jesse Boyd 2016-12-24 15:56:53 +11:00 committed by wizjany
parent b2fb73582f
commit 4a8bba7a54
15 changed files with 79 additions and 93 deletions

View File

@ -80,7 +80,7 @@ public BrushCommands(WorldEdit worldEdit) {
max = 2 max = 2
) )
@CommandPermissions("worldedit.brush.sphere") @CommandPermissions("worldedit.brush.sphere")
public void sphereBrush(Player player, LocalSession session, EditSession editSession, Pattern fill, public void sphereBrush(Player player, LocalSession session, Pattern fill,
@Optional("2") double radius, @Switch('h') boolean hollow) throws WorldEditException { @Optional("2") double radius, @Switch('h') boolean hollow) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
@ -109,7 +109,7 @@ public void sphereBrush(Player player, LocalSession session, EditSession editSes
max = 3 max = 3
) )
@CommandPermissions("worldedit.brush.cylinder") @CommandPermissions("worldedit.brush.cylinder")
public void cylinderBrush(Player player, LocalSession session, EditSession editSession, Pattern fill, public void cylinderBrush(Player player, LocalSession session, Pattern fill,
@Optional("2") double radius, @Optional("1") int height, @Switch('h') boolean hollow) throws WorldEditException { @Optional("2") double radius, @Optional("1") int height, @Switch('h') boolean hollow) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(height); worldEdit.checkMaxBrushRadius(height);
@ -139,7 +139,7 @@ public void cylinderBrush(Player player, LocalSession session, EditSession editS
"stood relative to the copied area when you copied it." "stood relative to the copied area when you copied it."
) )
@CommandPermissions("worldedit.brush.clipboard") @CommandPermissions("worldedit.brush.clipboard")
public void clipboardBrush(Player player, LocalSession session, EditSession editSession, @Switch('a') boolean ignoreAir, @Switch('p') boolean usingOrigin) throws WorldEditException { public void clipboardBrush(Player player, LocalSession session, @Switch('a') boolean ignoreAir, @Switch('p') boolean usingOrigin) throws WorldEditException {
ClipboardHolder holder = session.getClipboard(); ClipboardHolder holder = session.getClipboard();
Clipboard clipboard = holder.getClipboard(); Clipboard clipboard = holder.getClipboard();
@ -167,7 +167,7 @@ public void clipboardBrush(Player player, LocalSession session, EditSession edit
max = 2 max = 2
) )
@CommandPermissions("worldedit.brush.smooth") @CommandPermissions("worldedit.brush.smooth")
public void smoothBrush(Player player, LocalSession session, EditSession editSession, public void smoothBrush(Player player, LocalSession session,
@Optional("2") double radius, @Optional("4") int iterations, @Switch('n') @Optional("2") double radius, @Optional("4") int iterations, @Switch('n')
boolean naturalBlocksOnly) throws WorldEditException { boolean naturalBlocksOnly) throws WorldEditException {
@ -215,7 +215,7 @@ public void extinguishBrush(Player player, LocalSession session, EditSession edi
max = 1 max = 1
) )
@CommandPermissions("worldedit.brush.gravity") @CommandPermissions("worldedit.brush.gravity")
public void gravityBrush(Player player, LocalSession session, EditSession editSession, @Optional("5") double radius, @Switch('h') boolean fromMaxY) throws WorldEditException { public void gravityBrush(Player player, LocalSession session, @Optional("5") double radius, @Switch('h') boolean fromMaxY) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand()); BrushTool tool = session.getBrushTool(player.getItemInHand());
@ -246,7 +246,7 @@ public void gravityBrush(Player player, LocalSession session, EditSession editSe
max = 1 max = 1
) )
@CommandPermissions("worldedit.brush.butcher") @CommandPermissions("worldedit.brush.butcher")
public void butcherBrush(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { public void butcherBrush(Player player, LocalSession session, CommandContext args) throws WorldEditException {
LocalConfiguration config = worldEdit.getConfiguration(); LocalConfiguration config = worldEdit.getConfiguration();
double radius = args.argsLength() > 0 ? args.getDouble(0) : 5; double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;

View File

@ -57,7 +57,7 @@ public ChunkCommands(WorldEdit worldEdit) {
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, LocalSession session, CommandContext args) throws WorldEditException {
Vector pos = player.getBlockIn(); Vector 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);
@ -81,7 +81,7 @@ public void chunkInfo(Player player, LocalSession session, EditSession editSessi
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, CommandContext args) throws WorldEditException {
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks(); Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
for (Vector2D chunk : chunks) { for (Vector2D chunk : chunks) {
@ -98,7 +98,7 @@ public void listChunks(Player player, LocalSession session, EditSession editSess
) )
@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, CommandContext args) 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();

View File

@ -207,7 +207,7 @@ public void rotate(Player player, LocalSession session, Double yRotate, @Optiona
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 Vector direction) throws WorldEditException { @Optional(Direction.AIM) @Direction Vector direction) throws WorldEditException {
ClipboardHolder holder = session.getClipboard(); ClipboardHolder holder = session.getClipboard();
Clipboard clipboard = holder.getClipboard(); Clipboard clipboard = holder.getClipboard();
@ -251,7 +251,7 @@ public void save(Actor actor) {
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.");
} }

View File

@ -56,7 +56,7 @@ public GeneralCommands(WorldEdit worldEdit) {
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");
@ -86,7 +86,7 @@ public void limit(Player player, LocalSession session, EditSession editSession,
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()) {
@ -116,7 +116,7 @@ public void fast(Player player, LocalSession session, EditSession editSession, C
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.");
@ -133,7 +133,7 @@ public void gmask(Player player, LocalSession session, EditSession editSession,
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, CommandContext args) throws WorldEditException {
if (session.togglePlacementPosition()) { if (session.togglePlacementPosition()) {
player.print("Now placing at pos #1."); player.print("Now placing at pos #1.");

View File

@ -52,7 +52,7 @@ public HistoryCommands(WorldEdit worldEdit) {
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;
@ -85,7 +85,7 @@ public void undo(Player player, LocalSession session, EditSession editSession, C
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));
@ -119,7 +119,7 @@ public void redo(Player player, LocalSession session, EditSession editSession, C
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.");
} }

View File

@ -23,7 +23,6 @@
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.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -116,7 +115,7 @@ public void descend(Player player, @Optional("1") int levelsToDescend) throws Wo
) )
@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, LocalSession session, 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;
@ -137,7 +136,7 @@ public void ceiling(Player player, LocalSession session, EditSession editSession
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, LocalSession session, CommandContext args) throws WorldEditException {
if (player.passThroughForwardWall(6)) { if (player.passThroughForwardWall(6)) {
player.print("Whoosh!"); player.print("Whoosh!");
} else { } else {
@ -153,7 +152,7 @@ public void thru(Player player, LocalSession session, EditSession editSession, C
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, LocalSession session, CommandContext args) throws WorldEditException {
WorldVector pos = player.getSolidBlockTrace(300); WorldVector pos = player.getSolidBlockTrace(300);
if (pos != null) { if (pos != null) {
@ -174,7 +173,7 @@ public void jumpTo(Player player, LocalSession session, EditSession editSession,
) )
@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, LocalSession session, 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);

View File

@ -23,7 +23,6 @@
import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.minecraft.util.commands.CommandException;
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;
@ -201,7 +200,7 @@ public void save(Player player, LocalSession session, @Optional("schematic") Str
max = 1 max = 1
) )
@CommandPermissions("worldedit.schematic.delete") @CommandPermissions("worldedit.schematic.delete")
public void delete(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { public void delete(Player player, LocalSession session, CommandContext args) throws WorldEditException {
LocalConfiguration config = worldEdit.getConfiguration(); LocalConfiguration config = worldEdit.getConfiguration();
String filename = args.getString(0); String filename = args.getString(0);
@ -336,6 +335,7 @@ private List<File> allFiles(File root) {
} }
private List<String> listFiles(String prefix, File[] files) { private List<String> listFiles(String prefix, File[] files) {
File dir = worldEdit.getWorkingDirectoryFile(prefix);
if (prefix == null) prefix = ""; if (prefix == null) prefix = "";
List<String> result = new ArrayList<String>(); List<String> result = new ArrayList<String>();
for (File file : files) { for (File file : files) {
@ -344,8 +344,13 @@ private List<String> listFiles(String prefix, File[] files) {
build.append("\u00a72"); build.append("\u00a72");
ClipboardFormat format = ClipboardFormat.findByFile(file); ClipboardFormat format = ClipboardFormat.findByFile(file);
boolean inRoot = file.getParentFile().getName().equals(prefix); boolean inRoot = file.getParentFile().getName().equals(prefix);
build.append(inRoot ? file.getName() : file.getPath().split(Pattern.quote(prefix + File.separator))[1]) if (inRoot) {
.append(": ").append(format == null ? "Unknown" : format.name()); build.append(file.getName());
} else {
String relative = dir.toURI().relativize(file.toURI()).getPath();
build.append(relative);
}
build.append(": ").append(format == null ? "Unknown" : format.name());
result.add(build.toString()); result.add(build.toString());
} }
return result; return result;

View File

@ -23,7 +23,6 @@
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 ScriptingCommands(WorldEdit worldEdit) {
) )
@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 void execute(Player player, LocalSession session, EditSession editSession
) )
@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();

View File

@ -83,8 +83,7 @@ public SelectionCommands(WorldEdit we) {
) )
@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 {
Vector pos; Vector pos;
if (args.argsLength() == 1) { if (args.argsLength() == 1) {
@ -117,8 +116,7 @@ public void pos1(Player player, LocalSession session, EditSession editSession, C
) )
@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 {
Vector pos; Vector pos;
if (args.argsLength() == 1) { if (args.argsLength() == 1) {
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) { if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
@ -151,8 +149,7 @@ public void pos2(Player player, LocalSession session, EditSession editSession, C
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, CommandContext args) throws WorldEditException {
Vector pos = player.getBlockTrace(300); Vector pos = player.getBlockTrace(300);
if (pos != null) { if (pos != null) {
@ -176,8 +173,7 @@ public void hpos1(Player player, LocalSession session, EditSession editSession,
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, CommandContext args) throws WorldEditException {
Vector pos = player.getBlockTrace(300); Vector pos = player.getBlockTrace(300);
if (pos != null) { if (pos != null) {
@ -211,7 +207,7 @@ public void hpos2(Player player, LocalSession session, EditSession editSession,
) )
@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 Vector min; final Vector min;
final Vector max; final Vector max;
final World world = player.getWorld(); final World world = player.getWorld();
@ -273,8 +269,7 @@ public void chunk(Player player, LocalSession session, EditSession editSession,
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, LocalSession session, CommandContext args) throws WorldEditException {
player.giveItem(we.getConfiguration().wandItem, 1); player.giveItem(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");
} }
@ -287,8 +282,7 @@ public void wand(Player player, LocalSession session, EditSession editSession, C
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());
if (session.isToolControlEnabled()) { if (session.isToolControlEnabled()) {
@ -307,8 +301,7 @@ public void toggleWand(Player player, LocalSession session, EditSession editSess
) )
@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.
if (args.getString(0).equalsIgnoreCase("vert") if (args.getString(0).equalsIgnoreCase("vert")
@ -387,7 +380,7 @@ public void expand(Player player, LocalSession session, EditSession editSession,
session.getRegionSelector(player.getWorld()).learnChanges(); session.getRegionSelector(player.getWorld()).learnChanges();
int newSize = region.getArea(); int newSize = region.getArea();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
player.print("Region expanded " + (newSize - oldSize) + " blocks."); player.print("Region expanded " + (newSize - oldSize) + " blocks.");
@ -402,8 +395,7 @@ public void expand(Player player, LocalSession session, EditSession editSession,
) )
@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<Vector> dirs = new ArrayList<Vector>(); List<Vector> dirs = new ArrayList<Vector>();
int change = args.getInteger(0); int change = args.getInteger(0);
int reverseChange = 0; int reverseChange = 0;
@ -458,7 +450,7 @@ public void contract(Player player, LocalSession session, EditSession editSessio
} }
session.getRegionSelector(player.getWorld()).learnChanges(); session.getRegionSelector(player.getWorld()).learnChanges();
int newSize = region.getArea(); int newSize = region.getArea();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
@ -477,8 +469,7 @@ public void contract(Player player, LocalSession session, EditSession editSessio
) )
@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<Vector> dirs = new ArrayList<Vector>(); List<Vector> dirs = new ArrayList<Vector>();
int change = args.getInteger(0); int change = args.getInteger(0);
if (args.argsLength() == 2) { if (args.argsLength() == 2) {
@ -525,7 +516,7 @@ public void shift(Player player, LocalSession session, EditSession editSession,
) )
@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();
@ -548,7 +539,7 @@ public void outset(Player player, LocalSession session, EditSession editSession,
) )
@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();
@ -584,8 +575,7 @@ private Vector[] getChangesForEachDir(CommandContext args) {
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();
@ -599,20 +589,20 @@ public void size(Player player, LocalSession session, EditSession editSession, C
player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ())); player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ()));
return; return;
} }
Region region = session.getSelection(player.getWorld()); Region region = session.getSelection(player.getWorld());
Vector size = region.getMaximumPoint() Vector size = region.getMaximumPoint()
.subtract(region.getMinimumPoint()) .subtract(region.getMinimumPoint())
.add(1, 1, 1); .add(1, 1, 1);
player.print("Type: " + session.getRegionSelector(player.getWorld()) player.print("Type: " + session.getRegionSelector(player.getWorld())
.getTypeName()); .getTypeName());
for (String line : session.getRegionSelector(player.getWorld()) for (String line : session.getRegionSelector(player.getWorld())
.getInformationLines()) { .getInformationLines()) {
player.print(line); player.print(line);
} }
player.print("Size: " + size); player.print("Size: " + size);
player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint())); player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
player.print("# of blocks: " + region.getArea()); player.print("# of blocks: " + region.getArea());
@ -629,7 +619,6 @@ public void size(Player player, LocalSession session, EditSession editSession, C
) )
@CommandPermissions("worldedit.analysis.count") @CommandPermissions("worldedit.analysis.count")
public void count(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { public void count(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
boolean useData = args.hasFlag('d'); boolean useData = args.hasFlag('d');
if (args.getString(0).contains(":")) { if (args.getString(0).contains(":")) {
useData = true; //override d flag, if they specified data they want it useData = true; //override d flag, if they specified data they want it
@ -659,7 +648,6 @@ public void count(Player player, LocalSession session, EditSession editSession,
) )
@CommandPermissions("worldedit.analysis.distr") @CommandPermissions("worldedit.analysis.distr")
public void distr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException, CommandException { public void distr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException, CommandException {
int size; int size;
boolean useData = args.hasFlag('d'); boolean useData = args.hasFlag('d');
List<Countable<Integer>> distribution = null; List<Countable<Integer>> distribution = null;
@ -715,7 +703,7 @@ public void distr(Player player, LocalSession session, EditSession editSession,
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();

View File

@ -60,7 +60,7 @@ public SnapshotCommands(WorldEdit we) {
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, LocalSession session, CommandContext args) throws WorldEditException {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
@ -110,7 +110,7 @@ public void list(Player player, LocalSession session, EditSession editSession, C
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();
@ -153,7 +153,7 @@ public void use(Player player, LocalSession session, EditSession editSession, Co
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) {
@ -200,7 +200,7 @@ public void sel(Player player, LocalSession session, EditSession editSession, Co
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();
@ -239,7 +239,7 @@ public void before(Player player, LocalSession session, EditSession editSession,
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();

View File

@ -43,7 +43,7 @@ public SuperPickaxeCommands(WorldEdit we) {
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, CommandContext args) throws WorldEditException {
session.setSuperPickaxe(new SinglePickaxe()); session.setSuperPickaxe(new SinglePickaxe());
session.enableSuperPickAxe(); session.enableSuperPickAxe();
@ -58,7 +58,7 @@ public void single(Player player, LocalSession session, EditSession editSession,
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);
@ -81,7 +81,7 @@ public void area(Player player, LocalSession session, EditSession editSession, C
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);

View File

@ -44,7 +44,7 @@ public ToolCommands(WorldEdit we) {
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, CommandContext args) throws WorldEditException {
session.setTool(player.getItemInHand(), null); session.setTool(player.getItemInHand(), null);
player.print("Tool unbound from your current item."); player.print("Tool unbound from your current item.");
@ -58,7 +58,7 @@ public void none(Player player, LocalSession session, EditSession editSession, C
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, CommandContext args) throws WorldEditException {
session.setTool(player.getItemInHand(), new QueryTool()); session.setTool(player.getItemInHand(), new QueryTool());
player.print("Info tool bound to " player.print("Info tool bound to "
@ -74,7 +74,7 @@ public void info(Player player, LocalSession session, EditSession editSession, C
) )
@CommandPermissions("worldedit.tool.tree") @CommandPermissions("worldedit.tool.tree")
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
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 ?
type = TreeGenerator.lookup(args.getString(0)) type = TreeGenerator.lookup(args.getString(0))
@ -98,7 +98,7 @@ public void tree(Player player, LocalSession session, EditSession editSession, C
max = 1 max = 1
) )
@CommandPermissions("worldedit.tool.replacer") @CommandPermissions("worldedit.tool.replacer")
public void repl(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { public void repl(Player player, LocalSession session, CommandContext args) throws WorldEditException {
BaseBlock targetBlock = we.getBlock(player, args.getString(0)); BaseBlock targetBlock = we.getBlock(player, args.getString(0));
session.setTool(player.getItemInHand(), new BlockReplacer(targetBlock)); session.setTool(player.getItemInHand(), new BlockReplacer(targetBlock));
@ -114,7 +114,7 @@ public void repl(Player player, LocalSession session, EditSession editSession, C
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, CommandContext args) throws WorldEditException {
session.setTool(player.getItemInHand(), new BlockDataCyler()); session.setTool(player.getItemInHand(), new BlockDataCyler());
player.print("Block data cycler tool bound to " player.print("Block data cycler tool bound to "
@ -129,7 +129,7 @@ public void cycler(Player player, LocalSession session, EditSession editSession,
max = 2 max = 2
) )
@CommandPermissions("worldedit.tool.flood-fill") @CommandPermissions("worldedit.tool.flood-fill")
public void floodFill(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { public void floodFill(Player player, LocalSession session, CommandContext args) throws WorldEditException {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
int range = args.getInteger(1); int range = args.getInteger(1);
@ -153,7 +153,7 @@ public void floodFill(Player player, LocalSession session, EditSession editSessi
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, CommandContext args) throws WorldEditException {
session.setTool(player.getItemInHand(), new FloatingTreeRemover()); session.setTool(player.getItemInHand(), new FloatingTreeRemover());
player.print("Floating tree remover tool bound to " player.print("Floating tree remover tool bound to "
@ -168,7 +168,7 @@ public void deltree(Player player, LocalSession session, EditSession editSession
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, CommandContext args) throws WorldEditException {
session.setTool(player.getItemInHand(), new DistanceWand()); session.setTool(player.getItemInHand(), new DistanceWand());
player.print("Far wand tool bound to " + ItemType.toHeldName(player.getItemInHand()) + "."); player.print("Far wand tool bound to " + ItemType.toHeldName(player.getItemInHand()) + ".");
@ -182,7 +182,7 @@ public void farwand(Player player, LocalSession session, EditSession editSession
max = 2 max = 2
) )
@CommandPermissions("worldedit.tool.lrbuild") @CommandPermissions("worldedit.tool.lrbuild")
public void longrangebuildtool(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { public void longrangebuildtool(Player player, LocalSession session, CommandContext args) throws WorldEditException {
BaseBlock secondary = we.getBlock(player, args.getString(0)); BaseBlock secondary = we.getBlock(player, args.getString(0));
BaseBlock primary = we.getBlock(player, args.getString(1)); BaseBlock primary = we.getBlock(player, args.getString(1));

View File

@ -46,7 +46,7 @@ public ToolUtilCommands(WorldEdit we) {
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()) {
@ -76,7 +76,7 @@ public void togglePickaxe(Player player, LocalSession session, EditSession editS
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()).setMask(null); session.getBrushTool(player.getItemInHand()).setMask(null);
player.print("Brush mask disabled."); player.print("Brush mask disabled.");
@ -94,7 +94,7 @@ public void mask(Player player, LocalSession session, EditSession editSession, @
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()).setFill(pattern); session.getBrushTool(player.getItemInHand()).setFill(pattern);
player.print("Brush material set."); player.print("Brush material set.");
} }
@ -107,7 +107,7 @@ public void material(Player player, LocalSession session, EditSession editSessio
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()).setRange(range); session.getBrushTool(player.getItemInHand()).setRange(range);
player.print("Brush range set."); player.print("Brush range set.");
@ -121,7 +121,7 @@ public void range(Player player, LocalSession session, EditSession editSession,
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);

View File

@ -90,7 +90,7 @@ public void reload(Actor actor) throws WorldEditException {
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, CommandContext args) throws WorldEditException {
session.setCUISupport(true); session.setCUISupport(true);
session.dispatchCUISetup(player); session.dispatchCUISetup(player);
} }
@ -102,7 +102,7 @@ public void cui(Player player, LocalSession session, EditSession editSession, Co
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());

View File

@ -177,13 +177,8 @@ public SimpleDescription getDescription() {
@Override @Override
public boolean testPermission(CommandLocals locals) { public boolean testPermission(CommandLocals locals) {
for (CommandMapping mapping : getCommands()) { // checking EVERY perm here doesn't do anything but waste cpu
if (mapping.getCallable().testPermission(locals)) { return true;
return true;
}
}
return false;
} }
} }