Updated to use simplified method signature for commands. Also improved SimpleInjector.

This commit is contained in:
zml2008 2011-12-17 23:45:12 -08:00
parent 6fb8085692
commit 4dc3c035c1
19 changed files with 366 additions and 371 deletions

View File

@ -3,22 +3,30 @@ package com.sk89q.minecraft.util.commands;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
public class SimpleInjector<T> implements Injector {
private final T injectionObject;
public class SimpleInjector implements Injector {
private Object[] args;
private Class<?>[] argClasses;
public SimpleInjector(T injectionObject) {
this.injectionObject = injectionObject;
public SimpleInjector(Object... args) {
this.args = args;
argClasses = new Class[args.length];
for (int i = 0; i < args.length; ++i) {
argClasses[i] = args[i].getClass();
}
}
public Object getInstance(Class<?> cls) throws InvocationTargetException,
IllegalAccessException, InstantiationException {
public Object getInstance(Class<?> clazz) {
try {
Constructor<?> construct = cls.getConstructor(injectionObject.getClass());
return construct.newInstance(injectionObject);
Constructor<?> ctr = clazz.getConstructor(argClasses);
return ctr.newInstance(args);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return null;
} catch (InvocationTargetException e) {
return null;
} catch (InstantiationException e) {
return null;
} catch (IllegalAccessException e) {
return null;
}
}
}

View File

@ -174,6 +174,8 @@ public class WorldEdit {
}
};
commands.setInjector(new SimpleInjector(this));
commands.register(ChunkCommands.class);
commands.register(ClipboardCommands.class);
commands.register(GeneralCommands.class);
@ -1256,7 +1258,7 @@ public class WorldEdit {
long start = System.currentTimeMillis();
try {
commands.execute(split, player, this, session, player, editSession);
commands.execute(split, player, session, player, editSession);
} catch (CommandPermissionsException e) {
player.printError("You don't have permission to do this.");
} catch (MissingNestedCommandException e) {

View File

@ -49,6 +49,12 @@ import com.sk89q.worldedit.tools.brushes.SphereBrush;
* @author sk89q
*/
public class BrushCommands {
private final WorldEdit we;
public BrushCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "sphere", "s" },
usage = "<block> [radius]",
@ -61,9 +67,8 @@ public class BrushCommands {
max = 2
)
@CommandPermissions("worldedit.brush.sphere")
public static void sphereBrush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void sphereBrush(CommandContext args, LocalSession session,
LocalPlayer player, EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -101,9 +106,8 @@ public class BrushCommands {
max = 3
)
@CommandPermissions("worldedit.brush.cylinder")
public static void cylinderBrush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void cylinderBrush(CommandContext args, LocalSession session,
LocalPlayer player, EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -148,9 +152,8 @@ public class BrushCommands {
max = 0
)
@CommandPermissions("worldedit.brush.clipboard")
public static void clipboardBrush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void clipboardBrush(CommandContext args, LocalSession session,
LocalPlayer player, EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -189,9 +192,8 @@ public class BrushCommands {
max = 2
)
@CommandPermissions("worldedit.brush.smooth")
public static void smoothBrush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void smoothBrush(CommandContext args, LocalSession session,
LocalPlayer player, EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -220,9 +222,8 @@ public class BrushCommands {
max = 1
)
@CommandPermissions("worldedit.brush.ex")
public static void extinguishBrush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void extinguishBrush(CommandContext args, LocalSession session,
LocalPlayer player, EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();

View File

@ -36,6 +36,12 @@ import com.sk89q.worldedit.data.McRegionChunkStore;
* @author sk89q
*/
public class ChunkCommands {
private final WorldEdit we;
public ChunkCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "chunkinfo" },
usage = "",
@ -44,9 +50,8 @@ public class ChunkCommands {
max = 0
)
@CommandPermissions("worldedit.chunkinfo")
public static void chunkInfo(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void chunkInfo(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Vector pos = player.getBlockIn();
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
@ -71,9 +76,8 @@ public class ChunkCommands {
max = 0
)
@CommandPermissions("worldedit.listchunks")
public static void listChunks(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void listChunks(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
@ -91,9 +95,8 @@ public class ChunkCommands {
)
@CommandPermissions("worldedit.delchunks")
@Logging(REGION)
public static void deleteChunks(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void deleteChunks(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
player.print("Note that this command does not yet support the mcregion format.");
LocalConfiguration config = we.getConfiguration();

View File

@ -38,6 +38,12 @@ import com.sk89q.worldedit.regions.Region;
* @author sk89q
*/
public class ClipboardCommands {
private final WorldEdit we;
public ClipboardCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "/copy" },
usage = "",
@ -46,9 +52,8 @@ public class ClipboardCommands {
max = 0
)
@CommandPermissions("worldedit.clipboard.copy")
public static void copy(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void copy(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Region region = session.getSelection(player.getWorld());
Vector min = region.getMinimumPoint();
@ -73,9 +78,8 @@ public class ClipboardCommands {
)
@CommandPermissions("worldedit.clipboard.cut")
@Logging(REGION)
public static void cut(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void cut(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
BaseBlock block = new BaseBlock(BlockID.AIR);
@ -113,9 +117,8 @@ public class ClipboardCommands {
)
@CommandPermissions("worldedit.clipboard.paste")
@Logging(PLACEMENT)
public static void paste(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void paste(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
boolean atOrigin = args.hasFlag('o');
boolean pasteNoAir = args.hasFlag('a');
@ -141,9 +144,8 @@ public class ClipboardCommands {
max = 1
)
@CommandPermissions("worldedit.clipboard.rotate")
public static void rotate(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void rotate(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int angle = args.getInteger(0);
@ -169,9 +171,8 @@ public class ClipboardCommands {
max = 1
)
@CommandPermissions("worldedit.clipboard.flip")
public static void flip(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void flip(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
CuboidClipboard.FlipDirection dir = we.getFlipDirection(player,
args.argsLength() > 0 ? args.getString(0).toLowerCase() : "me");
@ -189,9 +190,8 @@ public class ClipboardCommands {
max = 1
)
@CommandPermissions("worldedit.clipboard.load")
public static void load(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void load(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -225,9 +225,8 @@ public class ClipboardCommands {
max = 1
)
@CommandPermissions("worldedit.clipboard.save")
public static void save(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void save(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -268,9 +267,8 @@ public class ClipboardCommands {
max = 0
)
@CommandPermissions("worldedit.clipboard.clear")
public static void clearClipboard(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void clearClipboard(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
session.setClipboard(null);
player.print("Clipboard cleared.");

View File

@ -34,6 +34,12 @@ import com.sk89q.worldedit.masks.Mask;
* @author sk89q
*/
public class GeneralCommands {
private final WorldEdit we;
public GeneralCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "/limit" },
usage = "<limit>",
@ -42,9 +48,8 @@ public class GeneralCommands {
max = 1
)
@CommandPermissions("worldedit.limit")
public static void limit(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void limit(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -70,9 +75,8 @@ public class GeneralCommands {
max = 1
)
@CommandPermissions("worldedit.fast")
public static void fast(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void fast(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
String newState = args.getString(0, null);
if (session.hasFastMode()) {
@ -102,9 +106,8 @@ public class GeneralCommands {
max = -1
)
@CommandPermissions("worldedit.global-mask")
public static void mask(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void mask(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
if (args.argsLength() == 0) {
session.setMask(null);
player.print("Global mask disabled.");
@ -122,9 +125,8 @@ public class GeneralCommands {
min = 0,
max = 0
)
public static void togglePlace(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void togglePlace(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
if (session.togglePlacementPosition()) {
player.print("Now placing at pos #1.");
@ -147,9 +149,8 @@ public class GeneralCommands {
max = 1
)
@Console
public static void searchItem(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void searchItem(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
String query = args.getString(0).trim().toLowerCase();
boolean blocksOnly = args.hasFlag('b');
@ -222,8 +223,7 @@ public class GeneralCommands {
)
@NestedCommand(WorldEditCommands.class)
@Console
public static void we(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void we(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
}
}

View File

@ -36,6 +36,12 @@ import com.sk89q.worldedit.util.TreeGenerator;
* @author sk89q
*/
public class GenerationCommands {
private final WorldEdit we;
public GenerationCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "/hcyl" },
usage = "<block> <radius>[,<radius>] [height]",
@ -50,9 +56,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.cylinder")
@Logging(PLACEMENT)
public static void hcyl(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void hcyl(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Pattern block = we.getBlockPattern(player, args.getString(0));
String[] radiuses = args.getString(1).split(",");
@ -92,9 +97,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.cylinder")
@Logging(PLACEMENT)
public static void cyl(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void cyl(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Pattern block = we.getBlockPattern(player, args.getString(0));
String[] radiuses = args.getString(1).split(",");
@ -134,9 +138,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT)
public static void hsphere(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void hsphere(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
final Pattern block = we.getBlockPattern(player, args.getString(0));
String[] radiuses = args.getString(1).split(",");
@ -187,9 +190,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT)
public static void sphere(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void sphere(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Pattern block = we.getBlockPattern(player, args.getString(0));
String[] radiuses = args.getString(1).split(",");
@ -235,9 +237,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.forest")
@Logging(POSITION)
public static void forestGen(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void forestGen(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10;
TreeGenerator.TreeType type = args.argsLength() > 1 ?
@ -264,9 +265,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.pumpkins")
@Logging(POSITION)
public static void pumpkins(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void pumpkins(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10;
@ -283,9 +283,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT)
public static void pyramid(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void pyramid(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Pattern block = we.getBlockPattern(player, args.getString(0));
int size = Math.max(1, args.getInteger(1));
@ -306,9 +305,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT)
public static void hpyramid(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void hpyramid(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Pattern block = we.getBlockPattern(player, args.getString(0));
int size = Math.max(1, args.getInteger(1));
@ -340,9 +338,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.shape")
@Logging(ALL)
public static void generate(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void generate(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
final Pattern pattern = we.getBlockPattern(player, args.getString(0));
final Region region = session.getSelection(player.getWorld());

View File

@ -30,6 +30,12 @@ import com.sk89q.worldedit.*;
* @author sk89q
*/
public class HistoryCommands {
private final WorldEdit we;
public HistoryCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "/undo", "undo" },
usage = "[times] [player]",
@ -38,9 +44,8 @@ public class HistoryCommands {
max = 2
)
@CommandPermissions("worldedit.history.undo")
public static void undo(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void undo(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int times = Math.max(1, args.getInteger(0, 1));
for (int i = 0; i < times; ++i) {
@ -74,9 +79,8 @@ public class HistoryCommands {
max = 2
)
@CommandPermissions("worldedit.history.redo")
public static void redo(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void redo(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int times = Math.max(1, args.getInteger(0, 1));
@ -110,9 +114,8 @@ public class HistoryCommands {
max = 0
)
@CommandPermissions("worldedit.history.clear")
public static void clearHistory(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void clearHistory(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
session.clearHistory();
player.print("History cleared.");

View File

@ -32,6 +32,12 @@ import com.sk89q.worldedit.*;
* @author sk89q
*/
public class NavigationCommands {
private final WorldEdit we;
public NavigationCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "unstuck", "!" },
usage = "",
@ -40,9 +46,8 @@ public class NavigationCommands {
max = 0
)
@CommandPermissions("worldedit.navigation.unstuck")
public static void unstuck(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void unstuck(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
player.print("There you go!");
player.findFreePosition();
@ -56,9 +61,8 @@ public class NavigationCommands {
max = 1
)
@CommandPermissions("worldedit.navigation.ascend")
public static void ascend(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void ascend(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int levelsToAscend = 0;
if (args.argsLength() == 0) {
levelsToAscend = 1;
@ -84,9 +88,8 @@ public class NavigationCommands {
max = 1
)
@CommandPermissions("worldedit.navigation.descend")
public static void descend(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void descend(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int levelsToDescend = 0;
if (args.argsLength() == 0) {
levelsToDescend = 1;
@ -113,9 +116,8 @@ public class NavigationCommands {
)
@CommandPermissions("worldedit.navigation.ceiling")
@Logging(POSITION)
public static void ceiling(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void ceiling(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int clearence = args.argsLength() > 0 ?
Math.max(0, args.getInteger(0)) : 0;
@ -135,9 +137,8 @@ public class NavigationCommands {
max = 0
)
// @CommandPermissions("worldedit.navigation.thru.command") // TODO: Remove old permission
public static void thru(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void thru(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
if (!(player.hasPermission("worldedit.navigation.thru") ||
player.hasPermission("worldedit.navigation.thru.command"))) {
throw new WorldEditPermissionException();
@ -158,9 +159,8 @@ public class NavigationCommands {
max = 0
)
// @CommandPermissions("worldedit.navigation.jumpto.command") //TODO: Remove old permission
public static void jumpTo(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void jumpTo(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
if (!(player.hasPermission("worldedit.navigation.jumpto") ||
player.hasPermission("worldedit.navigation.jumpto.command"))) {
@ -185,9 +185,8 @@ public class NavigationCommands {
)
@CommandPermissions("worldedit.navigation.up")
@Logging(POSITION)
public static void up(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void up(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int distance = args.getInteger(0);

View File

@ -42,6 +42,12 @@ import com.sk89q.worldedit.regions.RegionOperationException;
* @author sk89q
*/
public class RegionCommands {
private final WorldEdit we;
public RegionCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "/set" },
usage = "<block>",
@ -51,9 +57,8 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.set")
@Logging(REGION)
public static void set(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void set(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Pattern pattern = we.getBlockPattern(player, args.getString(0));
@ -79,9 +84,8 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.replace")
@Logging(REGION)
public static void replace(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void replace(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Set<BaseBlock> from;
Pattern to;
@ -113,9 +117,8 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.overlay")
@Logging(REGION)
public static void overlay(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void overlay(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Pattern pat = we.getBlockPattern(player, args.getString(0));
@ -139,9 +142,8 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.naturalize")
@Logging(REGION)
public static void naturalize(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void naturalize(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Region region = session.getSelection(player.getWorld());
int affected = editSession.naturalizeCuboidBlocks(region);
@ -157,9 +159,8 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.walls")
@Logging(REGION)
public static void walls(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void walls(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Pattern pattern = we.getBlockPattern(player, args.getString(0));
int affected;
@ -181,9 +182,8 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.faces")
@Logging(REGION)
public static void faces(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void faces(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Pattern pattern = we.getBlockPattern(player, args.getString(0));
int affected;
@ -209,9 +209,8 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.smooth")
@Logging(REGION)
public static void smooth(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void smooth(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int iterations = 1;
if (args.argsLength() > 0) {
@ -239,9 +238,8 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.move")
@Logging(ORIENTATION_REGION)
public static void move(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void move(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
Vector dir = we.getDirection(player,
@ -289,9 +287,8 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.stack")
@Logging(ORIENTATION_REGION)
public static void stack(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void stack(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
Vector dir = we.getDiagonalDirection(player,
@ -332,9 +329,8 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.regen")
@Logging(REGION)
public static void regenerateChunk(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void regenerateChunk(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Region region = session.getSelection(player.getWorld());
Mask mask = session.getMask();
@ -359,9 +355,8 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.deform")
@Logging(ALL)
public static void deform(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void deform(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
final Region region = session.getSelection(player.getWorld());
@ -406,9 +401,8 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.hollow")
@Logging(REGION)
public static void hollow(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void hollow(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int affected = editSession.hollowOutRegion(session.getSelection(player.getWorld()));

View File

@ -33,6 +33,12 @@ import com.sk89q.worldedit.*;
* @author sk89q
*/
public class ScriptingCommands {
private final WorldEdit we;
public ScriptingCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "cs" },
usage = "<filename> [args...]",
@ -42,9 +48,8 @@ public class ScriptingCommands {
)
@CommandPermissions("worldedit.scripting.execute")
@Logging(ALL)
public static void execute(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void execute(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
String[] scriptArgs = args.getSlice(1);
String name = args.getString(0);
@ -71,9 +76,8 @@ public class ScriptingCommands {
)
@CommandPermissions("worldedit.scripting.execute")
@Logging(ALL)
public static void executeLast(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void executeLast(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
String lastScript = session.getLastScript();

View File

@ -41,6 +41,12 @@ import com.sk89q.worldedit.blocks.*;
* @author sk89q
*/
public class SelectionCommands {
private final WorldEdit we;
public SelectionCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "/pos1" },
usage = "[coordinates]",
@ -49,9 +55,8 @@ public class SelectionCommands {
max = 1
)
@CommandPermissions("worldedit.selection.pos")
public static void pos1(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void pos1(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Vector pos;
@ -84,9 +89,8 @@ public class SelectionCommands {
max = 1
)
@CommandPermissions("worldedit.selection.pos")
public static void pos2(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void pos2(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Vector pos;
if (args.argsLength() == 1) {
@ -120,9 +124,8 @@ public class SelectionCommands {
max = 0
)
@CommandPermissions("worldedit.selection.hpos")
public static void hpos1(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void hpos1(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Vector pos = player.getBlockTrace(300);
@ -148,9 +151,8 @@ public class SelectionCommands {
max = 0
)
@CommandPermissions("worldedit.selection.hpos")
public static void hpos2(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void hpos2(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Vector pos = player.getBlockTrace(300);
@ -181,9 +183,8 @@ public class SelectionCommands {
max = 0
)
@CommandPermissions("worldedit.selection.chunk")
public static void chunk(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void chunk(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
final Vector min;
final Vector max;
@ -226,9 +227,8 @@ public class SelectionCommands {
max = 0
)
@CommandPermissions("worldedit.wand")
public static void wand(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void wand(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
player.giveItem(we.getConfiguration().wandItem, 1);
player.print("Left click: select pos #1; Right click: select pos #2");
@ -242,9 +242,8 @@ public class SelectionCommands {
max = 0
)
@CommandPermissions("worldedit.wand.toggle")
public static void toggleWand(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void toggleWand(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
session.setToolControl(!session.isToolControlEnabled());
@ -263,9 +262,8 @@ public class SelectionCommands {
max = 3
)
@CommandPermissions("worldedit.selection.expand")
public static void expand(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void expand(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Vector dir;
@ -339,9 +337,8 @@ public class SelectionCommands {
max = 3
)
@CommandPermissions("worldedit.selection.contract")
public static void contract(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void contract(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Vector dir;
int change = args.getInteger(0);
@ -394,9 +391,8 @@ public class SelectionCommands {
max = 2
)
@CommandPermissions("worldedit.selection.shift")
public static void shift(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void shift(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Vector dir;
int change = args.getInteger(0);
@ -434,9 +430,8 @@ public class SelectionCommands {
max = 1
)
@CommandPermissions("worldedit.selection.outset")
public static void outset(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void outset(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int change = args.getInteger(0);
Region region = session.getSelection(player.getWorld());
@ -478,9 +473,8 @@ public class SelectionCommands {
max = 1
)
@CommandPermissions("worldedit.selection.inset")
public static void inset(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void inset(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int change = args.getInteger(0);
Region region = session.getSelection(player.getWorld());
@ -512,8 +506,7 @@ public class SelectionCommands {
max = 0
)
@CommandPermissions("worldedit.selection.size")
public static void size(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
public void size(CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
Region region = session.getSelection(player.getWorld());
@ -540,9 +533,8 @@ public class SelectionCommands {
max = 1
)
@CommandPermissions("worldedit.analysis.count")
public static void count(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void count(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Set<Integer> searchIDs = we.getBlockIDs(player,
args.getString(0), true);
@ -562,9 +554,8 @@ public class SelectionCommands {
max = 0
)
@CommandPermissions("worldedit.analysis.distr")
public static void distr(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void distr(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
List<Countable<Integer>> distribution =
editSession.getBlockDistribution(session.getSelection(player.getWorld()));
@ -605,9 +596,8 @@ public class SelectionCommands {
min = 0,
max = 1
)
public static void select(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void select(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
final LocalWorld world = player.getWorld();
if (args.argsLength() == 0) {

View File

@ -39,8 +39,14 @@ import com.sk89q.worldedit.snapshots.Snapshot;
* @author sk89q
*/
public class SnapshotCommands {
private static Logger logger = Logger.getLogger("Minecraft.WorldEdit");
private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
private final WorldEdit we;
public SnapshotCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "list" },
@ -50,9 +56,8 @@ public class SnapshotCommands {
max = 1
)
@CommandPermissions("worldedit.snapshots.list")
public static void list(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void list(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -102,9 +107,8 @@ public class SnapshotCommands {
max = 1
)
@CommandPermissions("worldedit.snapshots.restore")
public static void use(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void use(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -147,9 +151,8 @@ public class SnapshotCommands {
max = 1
)
@CommandPermissions("worldedit.snapshots.restore")
public static void sel(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void sel(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
@ -196,9 +199,8 @@ public class SnapshotCommands {
max = -1
)
@CommandPermissions("worldedit.snapshots.restore")
public static void before(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void before(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -237,9 +239,8 @@ public class SnapshotCommands {
max = -1
)
@CommandPermissions("worldedit.snapshots.restore")
public static void after(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void after(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();

View File

@ -42,16 +42,21 @@ import com.sk89q.worldedit.snapshots.SnapshotRestore;
public class SnapshotUtilCommands {
private static Logger logger = Logger.getLogger("Minecraft.WorldEdit");
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
private final WorldEdit we;
public SnapshotUtilCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "snapshot", "snap" },
desc = "Snapshot commands"
)
@NestedCommand(SnapshotCommands.class)
public static void snapshot(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void snapshot(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
}
@Command(
@ -62,9 +67,8 @@ public class SnapshotUtilCommands {
max = 1
)
@CommandPermissions("worldedit.snapshots.restore")
public static void restore(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void restore(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();

View File

@ -33,6 +33,12 @@ import com.sk89q.worldedit.tools.RecursivePickaxe;
import com.sk89q.worldedit.tools.SinglePickaxe;
public class SuperPickaxeCommands {
private final WorldEdit we;
public SuperPickaxeCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "single" },
usage = "",
@ -41,9 +47,8 @@ public class SuperPickaxeCommands {
max = 0
)
@CommandPermissions("worldedit.superpickaxe")
public static void single(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void single(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
session.setSuperPickaxe(new SinglePickaxe());
session.enableSuperPickAxe();
@ -58,9 +63,8 @@ public class SuperPickaxeCommands {
max = 1
)
@CommandPermissions("worldedit.superpickaxe.area")
public static void area(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void area(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
int range = args.getInteger(0);
@ -83,9 +87,8 @@ public class SuperPickaxeCommands {
max = 1
)
@CommandPermissions("worldedit.superpickaxe.recursive")
public static void recursive(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void recursive(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
double range = args.getDouble(0);

View File

@ -31,6 +31,12 @@ import com.sk89q.worldedit.tools.*;
import com.sk89q.worldedit.util.TreeGenerator;
public class ToolCommands {
private final WorldEdit we;
public ToolCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "none" },
usage = "",
@ -38,9 +44,8 @@ public class ToolCommands {
min = 0,
max = 0
)
public static void none(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void none(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
session.setTool(player.getItemInHand(), null);
player.print("Tool unbound from your current item.");
@ -54,9 +59,8 @@ public class ToolCommands {
max = 0
)
@CommandPermissions("worldedit.tool.info")
public static void info(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void info(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
session.setTool(player.getItemInHand(), new QueryTool());
player.print("Info tool bound to "
@ -71,9 +75,8 @@ public class ToolCommands {
max = 1
)
@CommandPermissions("worldedit.tool.tree")
public static void tree(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void tree(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
TreeGenerator.TreeType type = args.argsLength() > 0 ?
type = TreeGenerator.lookup(args.getString(0))
@ -97,9 +100,8 @@ public class ToolCommands {
max = 1
)
@CommandPermissions("worldedit.tool.replacer")
public static void repl(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void repl(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
BaseBlock targetBlock = we.getBlock(player, args.getString(0));
session.setTool(player.getItemInHand(), new BlockReplacer(targetBlock));
@ -115,9 +117,8 @@ public class ToolCommands {
max = 0
)
@CommandPermissions("worldedit.tool.data-cycler")
public static void cycler(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void cycler(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
session.setTool(player.getItemInHand(), new BlockDataCyler());
player.print("Block data cycler tool bound to "
@ -132,9 +133,8 @@ public class ToolCommands {
max = 2
)
@CommandPermissions("worldedit.tool.flood-fill")
public static void floodFill(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void floodFill(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
int range = args.getInteger(1);
@ -155,9 +155,8 @@ public class ToolCommands {
desc = "Brush tool"
)
@NestedCommand(BrushCommands.class)
public static void brush(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void brush(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
}
@Command(
@ -168,9 +167,8 @@ public class ToolCommands {
max = 0
)
@CommandPermissions("worldedit.tool.deltree")
public static void deltree(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void deltree(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
session.setTool(player.getItemInHand(), new FloatingTreeRemover());
player.print("Floating tree remover tool bound to "
@ -185,9 +183,8 @@ public class ToolCommands {
max = 0
)
@CommandPermissions("worldedit.tool.farwand")
public static void farwand(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void farwand(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
session.setTool(player.getItemInHand(), new DistanceWand());
player.print("Far wand tool bound to " + ItemType.toHeldName(player.getItemInHand()) + ".");
@ -201,9 +198,8 @@ public class ToolCommands {
max = 2
)
@CommandPermissions("worldedit.tool.lrbuild")
public static void longrangebuildtool(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void longrangebuildtool(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
BaseBlock secondary = we.getBlock(player, args.getString(0));
BaseBlock primary = we.getBlock(player, args.getString(1));

View File

@ -33,6 +33,12 @@ import com.sk89q.worldedit.patterns.Pattern;
* @author sk89q
*/
public class ToolUtilCommands {
private final WorldEdit we;
public ToolUtilCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "/", "," },
usage = "[on|off]",
@ -41,9 +47,8 @@ public class ToolUtilCommands {
max = 1
)
@CommandPermissions("worldedit.superpickaxe")
public static void togglePickaxe(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void togglePickaxe(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
String newState = args.getString(0, null);
if (session.hasSuperPickAxe()) {
@ -70,9 +75,8 @@ public class ToolUtilCommands {
desc = "Select super pickaxe mode"
)
@NestedCommand(SuperPickaxeCommands.class)
public static void pickaxe(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void pickaxe(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
}
@Command(
@ -80,9 +84,8 @@ public class ToolUtilCommands {
desc = "Select a tool to bind"
)
@NestedCommand(ToolCommands.class)
public static void tool(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void tool(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
}
@Command(
@ -93,9 +96,8 @@ public class ToolUtilCommands {
max = -1
)
@CommandPermissions("worldedit.brush.options.mask")
public static void mask(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void mask(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
if (args.argsLength() == 0) {
session.getBrushTool(player.getItemInHand()).setMask(null);
player.print("Brush mask disabled.");
@ -114,9 +116,8 @@ public class ToolUtilCommands {
max = 1
)
@CommandPermissions("worldedit.brush.options.material")
public static void material(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void material(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Pattern pattern = we.getBlockPattern(player, args.getString(0));
session.getBrushTool(player.getItemInHand()).setFill(pattern);
player.print("Brush material set.");
@ -130,9 +131,8 @@ public class ToolUtilCommands {
max = 1
)
@CommandPermissions("worldedit.brush.options.range")
public static void range(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void range(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int range = args.getInteger(0);
session.getBrushTool(player.getItemInHand()).setRange(range);
player.print("Brush range set.");
@ -146,9 +146,8 @@ public class ToolUtilCommands {
max = 1
)
@CommandPermissions("worldedit.brush.options.size")
public static void size(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void size(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();

View File

@ -44,6 +44,12 @@ import com.sk89q.worldedit.regions.Region;
* @author sk89q
*/
public class UtilityCommands {
private final WorldEdit we;
public UtilityCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "/fill" },
usage = "<block> <radius> [depth]",
@ -53,9 +59,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.fill")
@Logging(PLACEMENT)
public static void fill(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void fill(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Pattern pattern = we.getBlockPattern(player, args.getString(0));
double radius = Math.max(1, args.getDouble(1));
@ -83,9 +88,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.fill.recursive")
@Logging(PLACEMENT)
public static void fillr(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void fillr(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Pattern pattern = we.getBlockPattern(player, args.getString(0));
double radius = Math.max(1, args.getDouble(1));
@ -113,9 +117,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.drain")
@Logging(PLACEMENT)
public static void drain(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void drain(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
double radius = Math.max(0, args.getDouble(0));
we.checkMaxRadius(radius);
@ -133,9 +136,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.fixlava")
@Logging(PLACEMENT)
public static void fixLava(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void fixLava(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
double radius = Math.max(0, args.getDouble(0));
we.checkMaxRadius(radius);
@ -153,9 +155,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.fixwater")
@Logging(PLACEMENT)
public static void fixWater(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void fixWater(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
double radius = Math.max(0, args.getDouble(0));
we.checkMaxRadius(radius);
@ -173,9 +174,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.removeabove")
@Logging(PLACEMENT)
public static void removeAbove(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void removeAbove(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
we.checkMaxRadius(size);
@ -196,9 +196,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.removebelow")
@Logging(PLACEMENT)
public static void removeBelow(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void removeBelow(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
we.checkMaxRadius(size);
@ -218,9 +217,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.removenear")
@Logging(PLACEMENT)
public static void removeNear(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void removeNear(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
BaseBlock block = we.getBlock(player, args.getString(0), true);
int size = Math.max(1, args.getInteger(1, 50));
@ -240,9 +238,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.replacenear")
@Logging(PLACEMENT)
public static void replaceNear(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void replaceNear(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int size = Math.max(1, args.getInteger(0));
int affected;
@ -278,9 +275,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.snow")
@Logging(PLACEMENT)
public static void snow(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void snow(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
@ -297,9 +293,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.thaw")
@Logging(PLACEMENT)
public static void thaw(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void thaw(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
@ -316,9 +311,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.green")
@Logging(PLACEMENT)
public static void green(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void green(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
@ -335,9 +329,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.extinguish")
@Logging(PLACEMENT)
public static void extinguish(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void extinguish(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -367,9 +360,8 @@ public class UtilityCommands {
@CommandPermissions("worldedit.butcher")
@Logging(PLACEMENT)
@Console
public static void butcher(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void butcher(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
int radius = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : -1;
@ -400,9 +392,8 @@ public class UtilityCommands {
)
@CommandPermissions("worldedit.remove")
@Logging(PLACEMENT)
public static void remove(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void remove(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
String typeStr = args.getString(0);
int radius = args.getInteger(1);

View File

@ -34,7 +34,13 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
public class WorldEditCommands {
private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
private final WorldEdit we;
public WorldEditCommands(WorldEdit we) {
this.we = we;
}
@Command(
aliases = { "version", "ver" },
@ -44,9 +50,8 @@ public class WorldEditCommands {
max = 0
)
@Console
public static void version(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void version(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
player.print("WorldEdit version " + WorldEdit.getVersion());
player.print("http://www.sk89q.com/projects/worldedit/");
@ -61,9 +66,8 @@ public class WorldEditCommands {
)
@CommandPermissions("worldedit.reload")
@Console
public static void reload(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void reload(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
we.getServer().reload();
player.print("Configuration reloaded!");
@ -76,9 +80,8 @@ public class WorldEditCommands {
min = 0,
max = 0
)
public static void cui(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void cui(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
session.setCUISupport(true);
session.dispatchCUISetup(player);
}
@ -91,9 +94,8 @@ public class WorldEditCommands {
max = 1
)
@Console
public static void tz(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
public void tz(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
TimeZone tz = TimeZone.getTimeZone(args.getString(0));
session.setTimezone(tz);
player.print("Timezone set for this session to: " + tz.getDisplayName());