From 92fb90de0907fbb66e98f1a7d149a2aeff01480d Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 7 Aug 2019 06:18:44 +1000 Subject: [PATCH] Fix some arguments --- .../boydti/fawe/command/AnvilCommands.java | 17 +- .../com/boydti/fawe/command/CFICommands.java | 96 ++++----- .../java/com/sk89q/worldedit/EditSession.java | 9 +- .../worldedit/command/BrushCommands.java | 193 +++++++++--------- .../command/BrushOptionsCommands.java | 26 +-- .../worldedit/command/ClipboardCommands.java | 16 +- .../worldedit/command/GeneralCommands.java | 14 +- .../worldedit/command/GenerationCommands.java | 26 +-- .../sk89q/worldedit/command/MaskCommands.java | 32 +-- .../worldedit/command/PatternCommands.java | 18 +- .../worldedit/command/RegionCommands.java | 16 +- .../worldedit/command/SelectionCommands.java | 8 +- .../sk89q/worldedit/command/ToolCommands.java | 6 +- .../worldedit/command/ToolUtilCommands.java | 12 +- .../worldedit/command/TransformCommands.java | 2 +- .../worldedit/command/UtilityCommands.java | 52 ++--- .../worldedit/command/WorldEditCommands.java | 4 +- .../worldedit/command/tool/BrushTool.java | 2 +- .../util/CommandQueuedConditionGenerator.java | 4 +- 19 files changed, 275 insertions(+), 278 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java index 861ed7c41..4b9fb7110 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java @@ -116,7 +116,7 @@ public class AnvilCommands { public void replaceAll(Player player, String folder, @Arg(name = "from", desc = "String", def = "") String fromPattern, - String toPattern, + String toPatternStr, @Switch(name = 'd', desc = "Disable wildcard data matching") boolean useData) throws WorldEditException { // final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED @@ -299,7 +299,7 @@ public class AnvilCommands { desc = "Replace all blocks in the selection with another" ) @CommandPermissions("worldedit.anvil.replaceall") - public void replaceAllPattern(Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, Pattern to, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap) throws WorldEditException { + public void replaceAllPattern(Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, Pattern toPattern, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap) throws WorldEditException { // MCAFilterCounter filter; TODO NOT IMPLEMENTED // if (useMap) { // if (to instanceof RandomPattern) { @@ -328,7 +328,7 @@ public class AnvilCommands { desc = "Count all blocks in a world" ) @CommandPermissions("worldedit.anvil.countall") - public void countAll(Player player, EditSession editSession, String folder, String arg, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException { + public void countAll(Player player, EditSession editSession, String folder, String argStr, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException { // Set searchBlocks = worldEdit.getBlocks(player, arg, true); // MCAFilterCounter filter; // if (useData || arg.contains(":")) { // Optimize for both cases @@ -402,7 +402,7 @@ public class AnvilCommands { desc = "Count blocks in a selection" ) @CommandPermissions("worldedit.anvil.count") - public void count(Player player, EditSession editSession, @Selection Region selection, String arg, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException { + public void count(Player player, EditSession editSession, @Selection Region selection, String argStr, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException { // Set searchBlocks = worldEdit.getBlocks(player, arg, true); TODO NOT IMPLEMENTED // MCAFilterCounter filter; // if (useData || arg.contains(":")) { // Optimize for both cases @@ -503,7 +503,7 @@ public class AnvilCommands { desc = "Replace all blocks in the selection with another" ) @CommandPermissions("worldedit.anvil.replace") - public void replace(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, String to, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException { + public void replace(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, String toStr, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException { // final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED // if (from == null) { // matchFrom = FaweBlockMatcher.NOT_AIR; @@ -525,8 +525,7 @@ public class AnvilCommands { desc = "Replace all blocks in the selection with a pattern" ) @CommandPermissions("worldedit.anvil.replace") - // Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap - public void replacePattern(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap) throws WorldEditException { + public void replacePattern(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, final Pattern toPattern, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap) throws WorldEditException { // MCAFilterCounter filter; TODO NOT IMPLEMENTED // if (useMap) { // if (to instanceof RandomPattern) { @@ -556,8 +555,8 @@ public class AnvilCommands { desc = "Set all blocks in the selection with a pattern" ) @CommandPermissions("worldedit.anvil.set") - // Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap - public void set(Player player, EditSession editSession, @Selection Region selection, final Pattern to) throws WorldEditException { + // Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern toPattern, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap + public void set(Player player, EditSession editSession, @Selection Region selection, final Pattern toPattern) throws WorldEditException { // MCAFilterCounter filter = new SetPatternFilter(to); TODO NOT IMPLEMENTED // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // if (result != null) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java index 9879f6f6d..8a65ec7b5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java @@ -240,12 +240,12 @@ public class CFICommands { desc = "Set the floor and main block" ) @CommandPermissions("worldedit.anvil.cfi") - public void column(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + public void column(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setColumn(load(image), patternArg, !disableWhiteOnly); - } else if (mask != null) { - gen.setColumn(mask, patternArg); + } else if (maskOpt != null) { + gen.setColumn(maskOpt, patternArg); } else { gen.setColumn(patternArg); } @@ -259,19 +259,19 @@ public class CFICommands { desc = "Set the floor (default: grass)" ) @CommandPermissions("worldedit.anvil.cfi") - public void floorCmd(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ - floor(fp, patternArg, image, mask, disableWhiteOnly); + public void floorCmd(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + floor(fp, patternArg, image, maskOpt, disableWhiteOnly); fp.sendMessage("Set floor!"); assertSettings(fp).resetComponent(); component(fp); } - private void floor(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) { + private void floor(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setFloor(load(image), patternArg, !disableWhiteOnly); - } else if (mask != null) { - gen.setFloor(mask, patternArg); + } else if (maskOpt != null) { + gen.setFloor(maskOpt, patternArg); } else { gen.setFloor(patternArg); } @@ -282,19 +282,19 @@ public class CFICommands { desc = "Set the main block (default: stone)" ) @CommandPermissions("worldedit.anvil.cfi") - public void mainCmd(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ - main(fp, patternArg, image, mask, disableWhiteOnly); + public void mainCmd(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + main(fp, patternArg, image, maskOpt, disableWhiteOnly); fp.sendMessage("Set main!"); assertSettings(fp).resetComponent(); component(fp); } - public void main(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + public void main(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setMain(load(image), patternArg, !disableWhiteOnly); - } else if (mask != null) { - gen.setMain(mask, patternArg); + } else if (maskOpt != null) { + gen.setMain(maskOpt, patternArg); } else { gen.setMain(patternArg); } @@ -308,12 +308,12 @@ public class CFICommands { "e.g. Tallgrass" ) @CommandPermissions("worldedit.anvil.cfi") - public void overlay(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + public void overlay(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setOverlay(load(image), patternArg, !disableWhiteOnly); - } else if (mask != null) { - gen.setOverlay(mask, patternArg); + } else if (maskOpt != null) { + gen.setOverlay(maskOpt, patternArg); } else { gen.setOverlay(patternArg); } @@ -330,18 +330,18 @@ public class CFICommands { " - A good value for radius and iterations would be 1 8." ) @CommandPermissions("worldedit.anvil.cfi") - public void smoothCmd(FawePlayer fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ - smooth(fp, radius, iterations, image, mask, disableWhiteOnly); + public void smoothCmd(FawePlayer fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + smooth(fp, radius, iterations, image, maskOpt, disableWhiteOnly); assertSettings(fp).resetComponent(); component(fp); } - private void smooth(FawePlayer fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + private void smooth(FawePlayer fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.smooth(load(image), !disableWhiteOnly, radius, iterations); } else { - gen.smooth(mask, radius, iterations); + gen.smooth(maskOpt, radius, iterations); } } @@ -350,11 +350,11 @@ public class CFICommands { desc = "Create some snow" ) @CommandPermissions("worldedit.anvil.cfi") - public void snow(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + public void snow(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); - floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, mask, disableWhiteOnly); - main(fp, BlockTypes.SNOW_BLOCK, image, mask, disableWhiteOnly); - smooth(fp, 1, 8, image, mask, disableWhiteOnly); + floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, maskOpt, disableWhiteOnly); + main(fp, BlockTypes.SNOW_BLOCK, image, maskOpt, disableWhiteOnly); + smooth(fp, 1, 8, image, maskOpt, disableWhiteOnly); fp.toWorldEditPlayer().print(TextComponent.of("Added snow!")); assertSettings(fp).resetComponent(); component(fp); @@ -382,8 +382,8 @@ public class CFICommands { "`#clipboard` will only use the blocks present in your clipboard." ) @CommandPermissions("worldedit.anvil.cfi") - public void paletteblocks(FawePlayer fp, Player player, LocalSession session, @Arg(name = "arg", desc = "String", def = "") String arg) throws EmptyClipboardException, InputParseException, FileNotFoundException { - if (arg == null) { + public void paletteblocks(FawePlayer fp, Player player, LocalSession session, @Arg(name = "arg", desc = "String", def = "") String argOpt) throws EmptyClipboardException, InputParseException, FileNotFoundException { + if (argOpt == null) { TextComponent build = TextComponent.builder("What blocks do you want to color with?") .append(newline()) .append(TextComponent.of("[All]") @@ -417,7 +417,7 @@ public class CFICommands { Request.request().setExtent(generator); Set blocks; - switch (arg.toLowerCase()) { + switch (argOpt.toLowerCase()) { case "true": case "*": { generator.setTextureUtil(Fawe.get().getTextureUtil()); @@ -447,7 +447,7 @@ public class CFICommands { parserContext.setSession(session); parserContext.setExtent(extent); Request.request().setExtent(extent); - Mask mask = worldEdit.getMaskFactory().parseFromInput(arg, parserContext); + Mask mask = worldEdit.getMaskFactory().parseFromInput(argOpt, parserContext); TextureUtil tu = Fawe.get().getTextureUtil(); for (int typeId : tu.getValidBlockIds()) { BlockType type = BlockTypes.get(typeId); @@ -504,7 +504,7 @@ public class CFICommands { " - The distance is the spacing between each schematic" ) @CommandPermissions("worldedit.anvil.cfi") - public void schem(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, Mask mask, String schematic, int rarity, int distance, boolean rotate)throws IOException, WorldEditException { + public void schem(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask") Mask mask, String schematic, int rarity, int distance, boolean rotate)throws IOException, WorldEditException { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); World world = fp.getWorld(); @@ -530,12 +530,12 @@ public class CFICommands { " - If a mask is used, the biome will be set anywhere the mask applies" ) @CommandPermissions("worldedit.anvil.cfi") - public void biome(FawePlayer fp, @Arg(name = "biome", desc = "Biome type") BiomeType biomeType, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + public void biome(FawePlayer fp, @Arg(name = "biome", desc = "Biome type") BiomeType biomeType, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setBiome(load(image), biomeType, !disableWhiteOnly); - } else if (mask != null) { - gen.setBiome(mask, biomeType); + } else if (maskOpt != null) { + gen.setBiome(maskOpt, biomeType); } else { gen.setBiome(biomeType); } @@ -561,7 +561,7 @@ public class CFICommands { descFooter = "Use a specific pattern and settings to generate ore" ) @CommandPermissions("worldedit.anvil.cfi") - public void ore(FawePlayer fp, Mask mask, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, int size, int frequency, int rariry, int minY, int maxY) throws WorldEditException { + public void ore(FawePlayer fp, @Arg(name = "mask", desc = "Mask") Mask mask, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, int size, int frequency, int rariry, int minY, int maxY) throws WorldEditException { assertSettings(fp).getGenerator().addOre(mask, patternArg, size, frequency, rariry, minY, maxY); fp.toWorldEditPlayer().print(TextComponent.of("Added ore!")); populate(fp); @@ -572,7 +572,7 @@ public class CFICommands { desc = "Generate the vanilla ores" ) @CommandPermissions("worldedit.anvil.cfi") - public void ores(FawePlayer fp, Mask mask) throws WorldEditException { + public void ores(FawePlayer fp, @Arg(name = "mask", desc = "Mask") Mask mask) throws WorldEditException { assertSettings(fp).getGenerator().addDefaultOres(mask); fp.toWorldEditPlayer().print(TextComponent.of("Added ores!")); populate(fp); @@ -584,12 +584,12 @@ public class CFICommands { descFooter = "Set the terrain height either based on an image heightmap, or a numeric value." ) @CommandPermissions("worldedit.anvil.cfi") - public void height(FawePlayer fp, String arg) throws WorldEditException { + public void height(FawePlayer fp, String imageStr) throws WorldEditException { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); - if (!MathMan.isInteger(arg)) { - gen.setHeight(ImageUtil.getImage(arg)); + if (!MathMan.isInteger(imageStr)) { + gen.setHeight(ImageUtil.getImage(imageStr)); } else { - gen.setHeights(Integer.parseInt(arg)); + gen.setHeights(Integer.parseInt(imageStr)); } fp.toWorldEditPlayer().print("Set Height!"); component(fp); @@ -698,7 +698,7 @@ public class CFICommands { ) // ![79,174,212,5:3,5:4,18,161,20] @CommandPermissions("worldedit.anvil.cfi") - public void glass(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { + public void glass(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { CFISettings settings = assertSettings(fp); settings.getGenerator().setColorWithGlass(load(image)); fp.toWorldEditPlayer().print(TextComponent.of("Set color with glass!")); @@ -715,13 +715,13 @@ public class CFICommands { "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance" ) @CommandPermissions("worldedit.anvil.cfi") - public void color(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { + public void color(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { CFISettings settings = assertSettings(fp); HeightMapMCAGenerator gen = settings.getGenerator(); if (imageMask != null) { gen.setColor(load(image), load(imageMask), !disableWhiteOnly); - } else if (mask != null) { - gen.setColor(load(image), mask); + } else if (maskOpt != null) { + gen.setColor(load(image), maskOpt); } else { gen.setColor(load(image)); } @@ -739,9 +739,9 @@ public class CFICommands { "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance" ) @CommandPermissions("worldedit.anvil.cfi") - public void blockbiome(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { + public void blockbiome(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { CFISettings settings = assertSettings(fp); - settings.getGenerator().setBlockAndBiomeColor(load(image), mask, load(imageMask), !disableWhiteOnly); + settings.getGenerator().setBlockAndBiomeColor(load(image), maskOpt, load(imageMask), !disableWhiteOnly); fp.toWorldEditPlayer().print(TextComponent.of("Set color with blocks and biomes!")); settings.resetColoring(); mainMenu(fp); @@ -755,7 +755,7 @@ public class CFICommands { " - If you changed the block to something other than grass you will not see anything." ) @CommandPermissions("worldedit.anvil.cfi") - public void biomecolor(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { + public void biomecolor(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { CFISettings settings = assertSettings(fp); settings.getGenerator().setBiomeColor(load(image)); fp.toWorldEditPlayer().print(TextComponent.of("Set color with biomes!")); @@ -855,14 +855,14 @@ public class CFICommands { desc = "Select a mask" ) @CommandPermissions("worldedit.anvil.cfi") - public void mask(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly, InjectedValueAccess context){ + public void mask(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly, InjectedValueAccess context){ CFISettings settings = assertSettings(fp); String[] split = getArguments(context).split(" "); int index = 2; settings.imageMask = imageMask; settings.imageMaskArg = imageMask != null ? split[index++] : null; - settings.mask = mask; - settings.maskArg = mask != null ? split[index++] : null; + settings.mask = maskOpt; + settings.maskArg = maskOpt != null ? split[index++] : null; settings.whiteOnly = !disableWhiteOnly; String s = "/cfi mask http://"; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 3d3b97767..c6b654357 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -167,12 +167,6 @@ public class EditSession extends AbstractDelegateExtent implements SimpleWorld, private static final Logger log = LoggerFactory.getLogger(EditSession.class); - //TODO - @Override - public String getId() { - return null; - } - /** * Used by {@link EditSession#setBlock(BlockVector3, BlockStateHolder, Stage)} to * determine which {@link Extent}s should be bypassed. @@ -240,7 +234,7 @@ public class EditSession extends AbstractDelegateExtent implements SimpleWorld, this.world = builder.getWorld(); this.worldName = builder.getWorldName(); this.wrapped = builder.isWrapped(); - this.fastMode = builder.hasFastMode(); +// this.fastMode = builder.hasFastMode(); Not used this.history = builder.getHistory(); this.bypassHistory = builder.getBypassHistory(); this.bypassAll = builder.getBypassAll(); @@ -610,7 +604,6 @@ public class EditSession extends AbstractDelegateExtent implements SimpleWorld, * @param enabled true to enable */ public void setFastMode(boolean enabled) { - this.fastMode = enabled; disableHistory(enabled); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 03b7d4330..72ec1431b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -97,6 +97,7 @@ import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.internal.annotation.Range; import com.sk89q.worldedit.internal.expression.Expression; +import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.factory.RegionFactory; @@ -152,9 +153,9 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.blendball") public BrushSettings blendBallBrush(Player player, LocalSession session, @Arg(desc = "The radius to sample for blending", def = "5") - Expression radius, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new BlendBall()).setSize(radius); + Expression radiusOpt, InjectedValueAccess context) throws WorldEditException { + worldEdit.checkMaxBrushRadius(radiusOpt); + return set(session, context, new BlendBall()).setSize(radiusOpt); } @Command( @@ -164,9 +165,9 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.erode") public BrushSettings erodeBrush(Player player, LocalSession session, @Arg(desc = "The radius for eroding", def = "5") - Expression radius, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new ErodeBrush()).setSize(radius); + Expression radiusOpt, InjectedValueAccess context) throws WorldEditException { + worldEdit.checkMaxBrushRadius(radiusOpt); + return set(session, context, new ErodeBrush()).setSize(radiusOpt); } @Command( @@ -176,9 +177,9 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.pull") public BrushSettings pullBrush(Player player, LocalSession session, @Arg(desc = "The radius to sample for blending", def = "5") - Expression radius, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new RaiseBrush()).setSize(radius); + Expression radiusOpt, InjectedValueAccess context) throws WorldEditException { + worldEdit.checkMaxBrushRadius(radiusOpt); + return set(session, context, new RaiseBrush()).setSize(radiusOpt); } @Command( @@ -188,9 +189,9 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.sphere") public BrushSettings circleBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, @Arg(desc = "The radius to sample for blending", def = "5") - Expression radius, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new CircleBrush(player)).setSize(radius).setFill(fill); + Expression radiusOpt, InjectedValueAccess context) throws WorldEditException { + worldEdit.checkMaxBrushRadius(radiusOpt); + return set(session, context, new CircleBrush(player)).setSize(radiusOpt).setFill(fill); } @Command( @@ -203,14 +204,14 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.recursive") public BrushSettings recursiveBrush(Player player, LocalSession session, EditSession editSession, Pattern fill, @Arg(desc = "The radius to sample for blending", def = "5") - Expression radius, + Expression radiusOpt, @Switch(name = 'd', desc = "Apply in depth first order") boolean depthFirst, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius(radiusOpt); return set(session, context, new RecurseBrush(depthFirst)) - .setSize(radius) + .setSize(radiusOpt) .setFill(fill) .setMask(new IdMask(editSession)); } @@ -223,17 +224,17 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.line") public BrushSettings lineBrush(Player player, LocalSession session, Pattern fill, @Arg(desc = "The radius to sample for blending", def = "0") - Expression radius, + Expression radiusOpt, @Switch(name = 'h', desc = "Create only a shell") boolean shell, @Switch(name = 's', desc = "Selects the clicked point after drawing") boolean select, @Switch(name = 'f', desc = "Create a flat line") boolean flat, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius(radiusOpt); return set(session, context, new LineBrush(shell, select, flat)) - .setSize(radius) + .setSize(radiusOpt) .setFill(fill); } @@ -250,12 +251,12 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.spline") public BrushSettings splineBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, @Arg(desc = "The radius to sample for blending", def = "25") - Expression radius, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); - player.print(BBC.BRUSH_SPLINE.format(radius)); + Expression radiusOpt, InjectedValueAccess context) throws WorldEditException { + worldEdit.checkMaxBrushRadius(radiusOpt); + player.print(BBC.BRUSH_SPLINE.format(radiusOpt)); return set(session, context, new SplineBrush(player, session)) - .setSize(radius) + .setSize(radiusOpt) .setFill(fill); } @@ -281,7 +282,7 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.spline") public BrushSettings catenaryBrush(LocalSession session, Pattern fill, @Arg(def = "1.2", desc = "Length of wire compared to distance between points") @Range(min = 1) double lengthFactor, @Arg(desc = "The radius to sample for blending", def = "0") - Expression radius, + Expression radiusOpt, @Switch(name = 'h', desc = "Create only a shell") boolean shell, @Switch(name = 's', desc = "Select the clicked point after drawing") @@ -289,11 +290,11 @@ public class BrushCommands { @Switch(name = 'd', desc = "sags the catenary toward the facing direction") boolean facingDirection, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius(radiusOpt); Brush brush = new CatenaryBrush(shell, select, facingDirection, lengthFactor); return set(session, context, new CatenaryBrush(shell, select, facingDirection, lengthFactor)) - .setSize(radius) + .setSize(radiusOpt) .setFill(fill); } @@ -307,12 +308,12 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.surfacespline") // 0, 0, 0, 10, 0, public BrushSettings surfaceSpline(Player player, LocalSession session, Pattern fill, @Arg(desc = "The radius to sample for blending", def = "0") - Expression radius, @Arg(name = "tension", desc = "double", def = "0") double tension, @Arg(name = "bias", desc = "double", def = "0") double bias, @Arg(name = "continuity", desc = "double", def = "0") double continuity, @Arg(name = "quality", desc = "double", def = "10") double quality, InjectedValueAccess context) throws WorldEditException { - player.print(BBC.BRUSH_SPLINE.format(radius)); - worldEdit.checkMaxBrushRadius(radius); + Expression radiusOpt, @Arg(name = "tension", desc = "double", def = "0") double tension, @Arg(name = "bias", desc = "double", def = "0") double bias, @Arg(name = "continuity", desc = "double", def = "0") double continuity, @Arg(name = "quality", desc = "double", def = "10") double quality, InjectedValueAccess context) throws WorldEditException { + player.print(BBC.BRUSH_SPLINE.format(radiusOpt)); + worldEdit.checkMaxBrushRadius(radiusOpt); return set(session, context, new SurfaceSpline(tension, bias, continuity, quality)) - .setSize(radius) + .setSize(radiusOpt) .setFill(fill); } @@ -342,12 +343,12 @@ public class BrushCommands { @Arg(desc = "The pattern of blocks to set") Pattern pattern, @Arg(desc = "The radius of the sphere", def = "2") - Expression radius, + Expression radiusOpt, @Switch(name = 'h', desc = "Create hollow spheres instead") boolean hollow, @Switch(name = 'f', desc = "Create falling spheres instead") boolean falling, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius(radiusOpt); Brush brush; if (hollow) { brush = new HollowSphereBrush(); @@ -370,7 +371,7 @@ public class BrushCommands { } return set(session, context, brush) - .setSize(radius) + .setSize(radiusOpt) .setFill(pattern); } @@ -384,12 +385,12 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.shatter") public BrushSettings shatterBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, @Arg(desc = "The radius to sample for blending", def = "10") - Expression radius, + Expression radiusOpt, @Arg(desc = "Lines", def = "10") int count, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius(radiusOpt); return set(session, context, new ShatterBrush(count)) - .setSize(radius) + .setSize(radiusOpt) .setFill(fill) .setMask(new ExistingBlockMask(editSession)); } @@ -401,14 +402,14 @@ public class BrushCommands { ) @CommandPermissions("worldedit.brush.stencil") public BrushSettings stencilBrush(Player player, LocalSession session, Pattern fill, - @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, + @Arg(name = "radius", desc = "Expression", def = "5") Expression radiusOpt, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, @Switch(name = 'w', desc = "Apply at maximum saturation") boolean onlyWhite, @Switch(name = 'r', desc = "Apply random rotation") boolean randomRotate, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius(radiusOpt); InputStream stream = getHeightmapStream(image); HeightBrush brush; try { @@ -421,7 +422,7 @@ public class BrushCommands { } return set(session, context, brush) - .setSize(radius) + .setSize(radiusOpt) .setFill(fill); } @@ -431,14 +432,14 @@ public class BrushCommands { desc = "Use a height map to paint a surface", descFooter = "Use a height map to paint any surface.\n") @CommandPermissions("worldedit.brush.stencil") - public BrushSettings imageBrush(LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, + public BrushSettings imageBrush(LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radiusOpt, ProvideBindings.ImageUri imageUri, @Arg(def = "1", desc = "scale height") @Range(min = Double.MIN_NORMAL) double yscale, @Switch(name = 'a', desc = "Use image Alpha") boolean alpha, @Switch(name = 'f', desc = "Blend the image with existing terrain") boolean fadeOut, InjectedValueAccess context) throws WorldEditException, IOException { BufferedImage image = imageUri.load(); - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius(radiusOpt); if (yscale != 1) { ImageUtil.scaleAlpha(image, yscale); alpha = true; @@ -450,7 +451,7 @@ public class BrushCommands { ImageBrush brush = new ImageBrush(image, session, alpha); return set(session, context, brush) - .setSize(radius); + .setSize(radiusOpt); } @Command( @@ -464,10 +465,10 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.surface") public BrushSettings surfaceBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") - Expression radius, + Expression radiusOpt, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new SurfaceSphereBrush()).setFill(fill).setSize(radius); + worldEdit.checkMaxBrushRadius(radiusOpt); + return set(session, context, new SurfaceSphereBrush()).setFill(fill).setSize(radiusOpt); } @Command( @@ -477,17 +478,17 @@ public class BrushCommands { "Video: https://youtu.be/RPZIaTbqoZw?t=34s" ) @CommandPermissions("worldedit.brush.scatter") - public BrushSettings scatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "points", desc = "double", def = "5") double points, @Arg(name = "distance", desc = "double", def = "1") double distance, @Switch(name = 'o', desc = "Overlay the block") boolean overlay, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + public BrushSettings scatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radiusOpt, @Arg(name = "points", desc = "double", def = "5") double pointsOpt, @Arg(name = "distance", desc = "double", def = "1") double distanceOpt, @Switch(name = 'o', desc = "Overlay the block") boolean overlay, InjectedValueAccess context) throws WorldEditException { + worldEdit.checkMaxBrushRadius(radiusOpt); Brush brush; if (overlay) { - brush = new ScatterOverlayBrush((int) points, (int) distance); + brush = new ScatterOverlayBrush((int) pointsOpt, (int) distanceOpt); } else { - brush = new ScatterBrush((int) points, (int) distance); + brush = new ScatterBrush((int) pointsOpt, (int) distanceOpt); } return set(session, context, brush) - .setSize(radius) + .setSize(radiusOpt) .setFill(fill); } @@ -497,8 +498,8 @@ public class BrushCommands { desc = "Scatter a schematic on a surface" ) @CommandPermissions("worldedit.brush.populateschematic") - public BrushSettings scatterSchemBrush(Player player, LocalSession session, Mask mask, @Arg(name = "clipboard", desc = "Clipboard uri") String clipboardStr, @Arg(name = "radius", desc = "Expression", def = "30") Expression radius, @Arg(name = "density", desc = "double", def = "50") double density, @Switch(name = 'r', desc = "Apply random rotation") boolean rotate, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + public BrushSettings scatterSchemBrush(Player player, LocalSession session, Mask mask, @Arg(name = "clipboard", desc = "Clipboard uri") String clipboardStr, @Arg(name = "radius", desc = "Expression", def = "30") Expression radiusOpt, @Arg(name = "density", desc = "double", def = "50") double density, @Switch(name = 'r', desc = "Apply random rotation") boolean rotate, InjectedValueAccess context) throws WorldEditException { + worldEdit.checkMaxBrushRadius(radiusOpt); try { MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true); if (clipboards == null) { @@ -512,7 +513,7 @@ public class BrushCommands { } return set(session, context, - new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radius); + new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radiusOpt); } catch (IOException e) { throw new RuntimeException(e); } @@ -526,9 +527,9 @@ public class BrushCommands { "Pic: https://i.imgur.com/XV0vYoX.png" ) @CommandPermissions("worldedit.brush.layer") - public BrushSettings surfaceLayer(LocalSession session, Expression radius, List layers, InjectedValueAccess context) throws WorldEditException { + public BrushSettings surfaceLayer(LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, List blockLayers, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new LayerBrush(layers.toArray(new BlockState[0]))).setSize(radius); + return set(session, context, new LayerBrush(blockLayers.toArray(new BlockState[0]))).setSize(radius); } @Command( @@ -540,9 +541,9 @@ public class BrushCommands { "Note: The seeds define how many splotches there are, recursion defines how large, solid defines whether the pattern is applied per seed, else per block." ) @CommandPermissions("worldedit.brush.splatter") - public BrushSettings splatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "points", desc = "double", def = "1") double points, @Arg(name = "recursion", desc = "double", def = "5") double recursion, @Arg(name = "solid", desc = "boolean", def = "true") boolean solid, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); - return set(session, context, new SplatterBrush((int) points, (int) recursion, solid)).setSize(radius).setFill(fill); + public BrushSettings splatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radiusOpt, @Arg(name = "points", desc = "double", def = "1") double pointsOpt, @Arg(name = "recursion", desc = "double", def = "5") double recursion, @Arg(name = "solid", desc = "boolean", def = "true") boolean solid, InjectedValueAccess context) throws WorldEditException { + worldEdit.checkMaxBrushRadius(radiusOpt); + return set(session, context, new SplatterBrush((int) pointsOpt, (int) recursion, solid)).setSize(radiusOpt).setFill(fill); } @Command( @@ -556,10 +557,10 @@ public class BrushCommands { " - Placeholders: {x}, {y}, {z}, {world}, {size}" ) @CommandPermissions("worldedit.brush.scattercommand") - public BrushSettings scatterCommandBrush(Player player, EditSession editSession, LocalSession session, Expression radius, double points, double distance, List command, InjectedValueAccess context) throws WorldEditException { + public BrushSettings scatterCommandBrush(Player player, EditSession editSession, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, double points, double distance, List commandStr, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); return set(session, context, - new ScatterCommand((int) points, (int) distance, StringMan.join(command, " "))) + new ScatterCommand((int) points, (int) distance, StringMan.join(commandStr, " "))) .setSize(radius); } @@ -573,13 +574,13 @@ public class BrushCommands { @Arg(desc = "The pattern of blocks to set") Pattern pattern, @Arg(desc = "The radius of the cylinder", def = "2") - Expression radius, + Expression radiusOpt, @Arg(desc = "The height of the cylinder", def = "1") int height, @Switch(name = 'h', desc = "Create hollow cylinders instead") boolean hollow, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius(radiusOpt); worldEdit.checkMaxBrushRadius(height); BrushSettings settings; @@ -588,7 +589,7 @@ public class BrushCommands { } else { settings = set(session, context, new CylinderBrush(height)); } - settings.setSize(radius) + settings.setSize(radiusOpt) .setFill(pattern); return settings; } @@ -634,20 +635,20 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.smooth") public BrushSettings smoothBrush(Player player, LocalSession session, EditSession editSession, @Arg(desc = "The radius to sample for softening", def = "2") - Expression radius, + Expression radiusOpt, @Arg(desc = "The number of iterations to perform", def = "4") int iterations, @Arg(desc = "The mask of blocks to use for the heightmap", def = "") - Mask mask, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + Mask maskOpt, InjectedValueAccess context) throws WorldEditException { + worldEdit.checkMaxBrushRadius(radiusOpt); FawePlayer fp = FawePlayer.wrap(player); FaweLimit limit = Settings.IMP.getLimit(fp); iterations = Math.min(limit.MAX_ITERATIONS, iterations); return set(session, context, - new SmoothBrush(iterations, mask)) - .setSize(radius); + new SmoothBrush(iterations, maskOpt)) + .setSize(radiusOpt); } @Command( @@ -658,14 +659,14 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.ex") public BrushSettings extinguishBrush(Player player, LocalSession session, EditSession editSession, @Arg(desc = "The radius to extinguish", def = "5") - Expression radius, + Expression radiusOpt, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius(radiusOpt); Pattern fill = BlockTypes.AIR.getDefaultState(); return set(session, context, new SphereBrush()) - .setSize(radius) + .setSize(radiusOpt) .setFill(fill) .setMask(new SingleBlockTypeMask(editSession, BlockTypes.FIRE)); } @@ -678,15 +679,15 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.gravity") public BrushSettings gravityBrush(Player player, LocalSession session, @Arg(desc = "The radius to apply gravity in", def = "5") - Expression radius, + Expression radiusOpt, @Switch(name = 'h', desc = "Affect blocks starting at max Y, rather than the target location Y + radius") boolean fromMaxY, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius(radiusOpt); return set(session, context, new GravityBrush(fromMaxY)) - .setSize(radius); + .setSize(radiusOpt); } @Command( @@ -701,8 +702,8 @@ public class BrushCommands { "Snow Pic: https://i.imgur.com/Hrzn0I4.png" ) @CommandPermissions("worldedit.brush.height") - public BrushSettings heightBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, @Switch(name = 'r', desc = "TODO") boolean randomRotate, @Switch(name = 'l', desc = "TODO") boolean layers, @Switch(name = 's', desc = "TODO") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { - return terrainBrush(player, session, radius, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context); + public BrushSettings heightBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radiusOpt, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, @Switch(name = 'r', desc = "TODO") boolean randomRotate, @Switch(name = 'l', desc = "TODO") boolean layers, @Switch(name = 's', desc = "TODO") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { + return terrainBrush(player, session, radiusOpt, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context); } @Command( @@ -714,7 +715,7 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.height") public BrushSettings cliffBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") - Expression radius, + Expression radiusOpt, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min = 0, max = 360) @@ -727,7 +728,7 @@ public class BrushCommands { boolean layers, @Switch(name = 's', desc = "Disables smoothing") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { - return terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CYLINDER, context); + return terrainBrush(player, session, radiusOpt, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CYLINDER, context); } @Command( @@ -736,17 +737,17 @@ public class BrushCommands { desc = "This brush raises or lowers land towards the clicked point" ) @CommandPermissions("worldedit.brush.height") - public BrushSettings flattenBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, + public BrushSettings flattenBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radiusOpt, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, @Switch(name = 'r', desc = "Enables random off-axis rotation") boolean randomRotate, @Switch(name = 'l', desc = "Will work on snow layers") boolean layers, @Switch(name = 's', desc = "Disables smoothing") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { - return terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context); + return terrainBrush(player, session, radiusOpt, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context); } - private BrushSettings terrainBrush(Player player, LocalSession session, Expression radius, String image, int rotation, double yscale, boolean flat, boolean randomRotate, boolean layers, boolean smooth, ScalableHeightMap.Shape shape, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { + private BrushSettings terrainBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, String image, int rotation, double yscale, boolean flat, boolean randomRotate, boolean layers, boolean smooth, ScalableHeightMap.Shape shape, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { worldEdit.checkMaxBrushRadius(radius); InputStream stream = getHeightmapStream(image); HeightBrush brush; @@ -791,13 +792,13 @@ public class BrushCommands { "Video: https://www.youtube.com/watch?v=RPZIaTbqoZw" ) @CommandPermissions("worldedit.brush.copy") - public BrushSettings copy(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate, @Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate, InjectedValueAccess context) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); - player.print(BBC.BRUSH_COPY.format(radius)); + public BrushSettings copy(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radiusOpt, @Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate, @Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate, InjectedValueAccess context) throws WorldEditException { + worldEdit.checkMaxBrushRadius(radiusOpt); + player.print(BBC.BRUSH_COPY.format(radiusOpt)); return set(session, context, new CopyPastaBrush(player, session, randomRotate, autoRotate)) - .setSize(radius); + .setSize(radiusOpt); } @Command( @@ -809,7 +810,7 @@ public class BrushCommands { " - Placeholders: {x}, {y}, {z}, {world}, {size}" ) @CommandPermissions("worldedit.brush.command") - public BrushSettings command(Player player, LocalSession session, Expression radius, @Arg(desc = "Command to run") List input, InjectedValueAccess context) throws WorldEditException { + public BrushSettings command(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, @Arg(desc = "Command to run") List input, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); String cmd = StringMan.join(input, " "); return set(session, context, @@ -825,7 +826,7 @@ public class BrushCommands { @CommandPermissions("worldedit.brush.butcher") public BrushSettings butcherBrush(Player player, LocalSession session, InjectedValueAccess context, @Arg(desc = "Radius to kill mobs in", def = "5") - Expression radius, + Expression radiusOpt, @Switch(name = 'p', desc = "Also kill pets") boolean killPets, @Switch(name = 'n', desc = "Also kill NPCs") @@ -842,7 +843,7 @@ public class BrushCommands { boolean killFriendly, @Switch(name = 'r', desc = "Also destroy armor stands") boolean killArmorStands) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius(radiusOpt); CreatureButcher flags = new CreatureButcher(player); flags.or(CreatureButcher.Flags.FRIENDLY , killFriendly); // No permission check here. Flags will instead be filtered by the subsequent calls. @@ -856,7 +857,7 @@ public class BrushCommands { return set(session, context, new ButcherBrush(flags)) - .setSize(radius); + .setSize(radiusOpt); } public BrushSettings process(CommandLocals locals, BrushSettings settings) throws WorldEditException { @@ -898,12 +899,12 @@ public class BrushCommands { @Arg(desc = "The shape of the region") RegionFactory shape, @Arg(desc = "The size of the brush", def = "5") - double radius, + Expression radiusOpt, @Arg(desc = "The density of the brush", def = "20") double density, @Arg(desc = "The type of tree to use") - TreeGenerator.TreeType type) throws WorldEditException { - setOperationBasedBrush(player, localSession, radius, + TreeGenerator.TreeType type) throws WorldEditException, EvaluationException { + setOperationBasedBrush(player, localSession, radiusOpt, new Paint(new TreeGeneratorFactory(type), density / 100), shape, "worldedit.brush.forest"); } @@ -916,8 +917,8 @@ public class BrushCommands { @Arg(desc = "The shape of the region") RegionFactory shape, @Arg(desc = "The size of the brush", def = "5") - double radius) throws WorldEditException { - setOperationBasedBrush(player, localSession, radius, + Expression radiusOpt) throws WorldEditException, EvaluationException { + setOperationBasedBrush(player, localSession, radiusOpt, new Deform("y-=1"), shape, "worldedit.brush.raise"); } @@ -930,12 +931,12 @@ public class BrushCommands { @Arg(desc = "The shape of the region") RegionFactory shape, @Arg(desc = "The size of the brush", def = "5") - double radius) throws WorldEditException { - setOperationBasedBrush(player, localSession, radius, + Expression radiusOpt) throws WorldEditException, EvaluationException { + setOperationBasedBrush(player, localSession, radiusOpt, new Deform("y+=1"), shape, "worldedit.brush.lower"); } - static void setOperationBasedBrush(Player player, LocalSession session, double radius, + static void setOperationBasedBrush(Player player, LocalSession session, Expression radius, Contextual factory, RegionFactory shape, String permission) throws WorldEditException { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushOptionsCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushOptionsCommands.java index 806620f68..f87219bf2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushOptionsCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushOptionsCommands.java @@ -188,11 +188,11 @@ public class BrushOptionsCommands { ) @CommandPermissions("worldedit.brush.primary") public void primary(Player player, LocalSession session, - @Arg(desc = "The brush command", variable = true) List command) throws WorldEditException { + @Arg(desc = "The brush command", variable = true) List commandStr) throws WorldEditException { BaseItem item = player.getItemInHand(HandSide.MAIN_HAND); BrushTool tool = session.getBrushTool(player, false); session.setTool(item, null, player); - String cmd = "brush " + StringMan.join(command, " "); + String cmd = "brush " + StringMan.join(commandStr, " "); CommandEvent event = new CommandEvent(player, cmd); PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event); BrushTool newTool = session.getBrushTool(item, player, false); @@ -208,12 +208,12 @@ public class BrushOptionsCommands { ) @CommandPermissions("worldedit.brush.secondary") public void secondary(Player player, LocalSession session, - @Arg(desc = "The brush command", variable = true) List command) + @Arg(desc = "The brush command", variable = true) List commandStr) throws WorldEditException { BaseItem item = player.getItemInHand(HandSide.MAIN_HAND); BrushTool tool = session.getBrushTool(player, false); session.setTool(item, null, player); - String cmd = "brush " + StringMan.join(command, " "); + String cmd = "brush " + StringMan.join(commandStr, " "); CommandEvent event = new CommandEvent(player, cmd); PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event); BrushTool newTool = session.getBrushTool(item, player, false); @@ -232,7 +232,7 @@ public class BrushOptionsCommands { "2 = Glass showing what blocks will be changed" ) @CommandPermissions("worldedit.brush.visualize") - public void visual(Player player, LocalSession session, @Range(min = 0, max = 2) int mode) + public void visual(Player player, LocalSession session, @Arg(name = "mode", desc = "int", def = "0") @Range(min = 0, max = 2) int mode) throws WorldEditException { BrushTool tool = session.getBrushTool(player, false); if (tool == null) { @@ -270,14 +270,14 @@ public class BrushOptionsCommands { desc = "Set the targeting mask" ) @CommandPermissions("worldedit.brush.targetmask") - public void targetMask(Player player, EditSession editSession, LocalSession session, @Arg(desc = "The destination mask", def = "") Mask maskArg) throws WorldEditException { + public void targetMask(Player player, EditSession editSession, LocalSession session, @Arg(desc = "The destination mask", def = "") Mask maskOpt) throws WorldEditException { BrushTool tool = session.getBrushTool(player, false); if (tool == null) { BBC.BRUSH_NONE.send(player); return; } - tool.setTraceMask(maskArg); - BBC.BRUSH_TARGET_MASK_SET.send(player, maskArg.toString()); + tool.setTraceMask(maskOpt); + BBC.BRUSH_TARGET_MASK_SET.send(player, maskOpt.toString()); } @Command( @@ -308,7 +308,7 @@ public class BrushOptionsCommands { @Arg(desc = "Target Modes") String modes, @Arg(desc = "The scroll action", variable = true) - List command) throws WorldEditException { + List commandStr) throws WorldEditException { // TODO NOT IMPLEMENTED Convert ScrollAction to an argument converter BrushTool bt = session.getBrushTool(player, false); if (bt == null) { @@ -316,7 +316,7 @@ public class BrushOptionsCommands { return; } BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext(); - ScrollAction action = ScrollAction.fromArguments(bt, player, session, StringMan.join(command, " "), true); + ScrollAction action = ScrollAction.fromArguments(bt, player, session, StringMan.join(commandStr, " "), true); settings.setScrollAction(action); if (modes.equalsIgnoreCase("none")) { BBC.BRUSH_SCROLL_ACTION_UNSET.send(player); @@ -425,7 +425,7 @@ public class BrushOptionsCommands { ) @CommandPermissions("worldedit.brush.options.material") public void material(Player player, EditSession editSession, LocalSession session, - @Arg(desc = "brush material pattern", def = "") Pattern pattern, + @Arg(desc = "brush material pattern", def = "") Pattern patternOpt, @Switch(name = 'h', desc = "TODO") boolean offHand, Arguments arguments) throws WorldEditException { @@ -434,13 +434,13 @@ public class BrushOptionsCommands { player.print(BBC.BRUSH_NONE.s()); return; } - if (pattern == null) { + if (patternOpt == null) { BBC.BRUSH_MATERIAL.send(player); tool.setFill(null); return; } BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext(); - settings.setFill(pattern); + settings.setFill(patternOpt); String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring(); settings.addSetting(BrushSettings.SettingType.FILL, lastArg); tool.update(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index 4e24f8282..75075133c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -122,7 +122,7 @@ public class ClipboardCommands { @Switch(name = 'b', desc = "Also copy biomes") boolean copyBiomes, @ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "") - Mask mask, InjectedValueAccess context) throws WorldEditException { + Mask maskOpt, InjectedValueAccess context) throws WorldEditException { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); @@ -150,8 +150,8 @@ public class ClipboardCommands { copy.setSourceMask(sourceMask); editSession.setSourceMask(null); } - if (mask != null && mask != Masks.alwaysTrue()) { - copy.setSourceMask(mask); + if (maskOpt != null && maskOpt != Masks.alwaysTrue()) { + copy.setSourceMask(maskOpt); } Operations.completeLegacy(copy); BBC.COMMAND_COPY.send(player, region.getArea()); @@ -171,7 +171,7 @@ public class ClipboardCommands { @Switch(name = 'e', desc = "Skip copy entities") boolean skipEntities, @ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "") - Mask mask, + Mask maskOpt, @Switch(name = 'b', desc = "Also copy biomes") boolean copyBiomes) throws WorldEditException { BlockVector3 min = region.getMinimumPoint(); @@ -203,7 +203,7 @@ public class ClipboardCommands { @Switch(name = 'e', desc = "Skip copy entities") boolean skipEntities, @ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "") - Mask mask, + Mask maskOpt, @Switch(name = 'b', desc = "Also copy biomes") boolean copyBiomes) throws WorldEditException { BlockVector3 min = region.getMinimumPoint(); @@ -242,7 +242,7 @@ public class ClipboardCommands { @Switch(name = 'b', desc = "Also copy biomes, source biomes are unaffected") boolean copyBiomes, @ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "") - Mask mask, + Mask maskOpt, InjectedValueAccess context) throws WorldEditException { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); @@ -272,8 +272,8 @@ public class ClipboardCommands { copy.setSourceMask(sourceMask); editSession.setSourceMask(null); } - if (mask != null) { - copy.setSourceMask(mask); + if (maskOpt != null) { + copy.setSourceMask(maskOpt); } Operations.completeLegacy(copy); session.setClipboard(new ClipboardHolder(clipboard)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java index 7f659eb52..137ee9883 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java @@ -199,12 +199,11 @@ public class GeneralCommands { desc = "Set the global mask" ) @CommandPermissions({"worldedit.global-mask", "worldedit.mask.global"}) - public void gmask(Player player, LocalSession session, @Arg(desc = "The mask to set", def = "") Mask mask) { - if (mask == null) { - session.setMask(null); + public void gmask(Player player, LocalSession session, @Arg(desc = "The mask to set", def = "") Mask maskOpt) { + session.setMask(maskOpt); + if (maskOpt == null) { BBC.MASK_DISABLED.send(player); } else { - session.setMask(mask); BBC.MASK.send(player); } } @@ -357,12 +356,11 @@ public class GeneralCommands { descFooter = "The global source mask applies to all edits you do and masks based on the source blocks (e.g. the blocks in your clipboard)" ) @CommandPermissions({"worldedit.global-mask", "worldedit.mask.global"}) - public void gsmask(Player player, LocalSession session, EditSession editSession, @Arg(desc = "The mask to set", def = "") Mask mask) throws WorldEditException { - if (mask == null) { - session.setSourceMask((Mask) null); + public void gsmask(Player player, LocalSession session, EditSession editSession, @Arg(desc = "The mask to set", def = "") Mask maskOpt) throws WorldEditException { + session.setSourceMask(maskOpt); + if (maskOpt == null) { BBC.SOURCE_MASK_DISABLED.send(player); } else { - session.setSourceMask(mask); BBC.SOURCE_MASK.send(player); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index f15c2e22b..7bbb1e8b6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -94,17 +94,17 @@ public class GenerationCommands { @Logging(PLACEMENT) public void caves(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, @Arg(name = "size", desc = "TODO", def = "8") int sizeOpt, - @Arg(desc = "TODO", def = "40") int frequency, - @Arg(desc = "TODO", def = "7") int rarity, - @Arg(desc = "TODO", def = "8") int minY, - @Arg(desc = "TODO", def = "127") int maxY, - @Arg(desc = "TODO", def = "1") int systemFrequency, - @Arg(desc = "TODO", def = "25") int individualRarity, - @Arg(desc = "TODO", def = "0") int pocketChance, - @Arg(desc = "TODO", def = "0") int pocketMin, - @Arg(desc = "TODO", def = "3") int pocketMax, InjectedValueAccess context) throws WorldEditException { + @Arg(name = "frequency", desc = "TODO", def = "40") int frequencyOpt, + @Arg(name = "rarity", desc = "TODO", def = "7") int rarityOpt, + @Arg(name = "minY", desc = "TODO", def = "8") int minYOpt, + @Arg(name = "maxY", desc = "TODO", def = "127") int maxYOpt, + @Arg(name = "systemFrequency", desc = "TODO", def = "1") int systemFrequencyOpt, + @Arg(name = "individualRarity", desc = "TODO", def = "25") int individualRarityOpt, + @Arg(name = "pocketChance", desc = "TODO", def = "0") int pocketChanceOpt, + @Arg(name = "pocketMin", desc = "TODO", def = "0") int pocketMinOpt, + @Arg(name = "pocketMax", desc = "TODO", def = "3") int pocketMaxOpt, InjectedValueAccess context) throws WorldEditException { fp.checkConfirmationRegion(() -> { - CavesGen gen = new CavesGen(sizeOpt, frequency, rarity, minY, maxY, systemFrequency, individualRarity, pocketChance, pocketMin, pocketMax); + CavesGen gen = new CavesGen(sizeOpt, frequencyOpt, rarityOpt, minYOpt, maxYOpt, systemFrequencyOpt, individualRarityOpt, pocketChanceOpt, pocketMinOpt, pocketMaxOpt); editSession.generate(region, gen); BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount()); }, "/caves", region, context); @@ -130,10 +130,10 @@ public class GenerationCommands { ) @CommandPermissions("worldedit.generation.image") @Logging(PLACEMENT) - public void image(Player player, LocalSession session, EditSession editSession, String arg, @Arg(name = "randomize", desc = "boolean", def = "true") boolean randomize, + public void image(Player player, LocalSession session, EditSession editSession, String argStr, @Arg(name = "randomize", desc = "boolean", def = "true") boolean randomize, @Arg(desc = "TODO", def = "100") int threshold, @Arg(name = "dimensions", desc = "BlockVector2", def = "") BlockVector2 dimensions) throws WorldEditException, IOException { TextureUtil tu = Fawe.get().getCachedTextureUtil(randomize, 0, threshold); - URL url = new URL(arg); + URL url = new URL(argStr); if (!url.getHost().equalsIgnoreCase("i.imgur.com") && !url.getHost().equalsIgnoreCase("empcraft.com")) { throw new IOException("Only i.imgur.com or empcraft.com/ui links are allowed!"); } @@ -171,7 +171,7 @@ public class GenerationCommands { ) @CommandPermissions("worldedit.generation.ore") @Logging(PLACEMENT) - public void ore(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, @Range(min = 0) int size, int freq, @Range(min = 0, max = 100) int rarity, @Range(min = 0, max = 255) int minY, @Range(min = 0, max = 255) int maxY, InjectedValueAccess context) throws WorldEditException { + public void ore(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, @Arg(name="size", desc="Ore vein size") @Range(min = 0) int size, int freq, @Range(min = 0, max = 100) int rarity, @Range(min = 0, max = 255) int minY, @Range(min = 0, max = 255) int maxY, InjectedValueAccess context) throws WorldEditException { fp.checkConfirmationRegion(() -> { editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY); BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java index c730ded0c..c4e78042a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java @@ -60,7 +60,7 @@ import org.enginehub.piston.annotation.param.Switch; // "e.g. >[stone,dirt],#light[0][5],$jungle\n" + // "More Info: https://git.io/v9r4K" //) -@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) +@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class MaskCommands { private final WorldEdit worldEdit; @@ -74,9 +74,9 @@ public class MaskCommands { ) public Mask simplex(double scale, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { scale = 1d / Math.max(1, scale); - min = (min - 50) / 50; - max = (max - 50) / 50; - return new SimplexMask(scale, min, max); + minInt = (minInt - 50) / 50; + maxInt = (maxInt - 50) / 50; + return new SimplexMask(scale, minInt, maxInt); } @Command( @@ -84,7 +84,7 @@ public class MaskCommands { desc = "Restrict to specific light levels" ) public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { - return new LightMask(extent, (int) min, (int) max); + return new LightMask(extent, (int) minInt, (int) maxInt); } @Command( @@ -286,7 +286,7 @@ public class MaskCommands { "Example: /[3][20]\n" + "Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below" ) - public Mask angle(Extent extent, String minStr, String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distance) throws ExpressionException { + public Mask angle(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) throws ExpressionException { double y1, y2; boolean override; if (maxStr.endsWith("d")) { @@ -298,7 +298,7 @@ public class MaskCommands { y1 = Expression.compile(minStr).evaluate(); y2 = Expression.compile(maxStr).evaluate(); } - return new AngleMask(extent, y1, y2, overlay, distance); + return new AngleMask(extent, y1, y2, overlay, distanceOpt); } @Command( @@ -311,7 +311,7 @@ public class MaskCommands { "Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" + "Note: Use negatives for decreasing slope" ) - public Mask roc(Extent extent, String minStr, String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distance) throws ExpressionException { + public Mask roc(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException { double y1, y2; boolean override; if (maxStr.endsWith("d")) { @@ -323,7 +323,7 @@ public class MaskCommands { y1 = Expression.compile(minStr).evaluate(); y2 = Expression.compile(maxStr).evaluate(); } - return new ROCAngleMask(extent, y1, y2, overlay, distance); + return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt); } @Command( @@ -336,19 +336,19 @@ public class MaskCommands { "Explanation: Restrict to near 45 degrees of local maxima\n" + "Note: Use negatives for local minima" ) - public Mask extrema(Extent extent, String min, String max, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distance) throws ExpressionException { + public Mask extrema(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException { double y1, y2; boolean override; - if (max.endsWith("d")) { - double y1d = Expression.compile(min.substring(0, min.length() - 1)).evaluate(); - double y2d = Expression.compile(max.substring(0, max.length() - 1)).evaluate(); + if (maxStr.endsWith("d")) { + double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate(); + double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate(); y1 = Math.tan(y1d * (Math.PI / 180)); y2 = Math.tan(y2d * (Math.PI / 180)); } else { - y1 = Expression.compile(min).evaluate(); - y2 = Expression.compile(max).evaluate(); + y1 = Expression.compile(minStr).evaluate(); + y2 = Expression.compile(maxStr).evaluate(); } - return new ExtremaMask(extent, y1, y2, overlay, distance); + return new ExtremaMask(extent, y1, y2, overlay, distanceOpt); } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java index 5ed497f6b..0ed73a8e4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java @@ -45,7 +45,7 @@ import java.util.Set; // "e.g. #surfacespread[10][#existing],andesite\n" + // "More Info: https://git.io/vSPmA" //) -@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) +@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class PatternCommands { @Command( @@ -94,24 +94,24 @@ public class PatternCommands { name = "#anglecolor", desc = "A darker block based on the existing terrain angle" ) - public Pattern anglecolor(Extent extent, LocalSession session, @Arg(name = "randomize", desc = "boolean", def = "true") boolean randomize, @Arg(name = "maxcomplexity", desc = "double", def = "100") double maxComplexity, @Arg(name = "distance", desc = "int", def = "1") int distance) { - return new AngleColorPattern(extent, session, distance); + public Pattern anglecolor(Extent extent, LocalSession session, @Arg(name = "randomize", desc = "boolean", def = "true") boolean randomize, @Arg(name = "maxcomplexity", desc = "double", def = "100") double maxComplexity, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) { + return new AngleColorPattern(extent, session, distanceOpt); } @Command( name = "#angledata", desc = "Block data based on the existing terrain angle" ) - public Pattern angledata(Extent extent, @Arg(name = "distance", desc = "int", def = "1") int distance) { - return new DataAnglePattern(extent, distance); + public Pattern angledata(Extent extent, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) { + return new DataAnglePattern(extent, distanceOpt); } @Command( name = "#saturate", desc = "Saturate the existing block with a color" ) - public Pattern saturate(Extent extent, LocalSession session, String arg) { - Color color = ColorUtil.parseColor(arg); + public Pattern saturate(Extent extent, LocalSession session, String colorStr) { + Color color = ColorUtil.parseColor(colorStr); return new SaturatePattern(extent, color.getRGB(), session); } @@ -119,8 +119,8 @@ public class PatternCommands { name = "#averagecolor", desc = "Average between the existing block and a color" ) - public Pattern averagecolor(Extent extent, LocalSession session, String arg) { - Color color = ColorUtil.parseColor(arg); + public Pattern averagecolor(Extent extent, LocalSession session, String colorStr) { + Color color = ColorUtil.parseColor(colorStr); return new AverageColorPattern(extent, color.getRGB(), session); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 1bda55020..29816bdb0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -217,7 +217,7 @@ public class RegionCommands { public int line(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "The pattern of blocks to place") - Pattern patternArg, + Pattern patternArgOpt, @Range(min = 1) @Arg(desc = "The thickness of the line", def = "0") int thickness, @Switch(name = 'h', desc = "Generate only a shell") @@ -231,7 +231,7 @@ public class RegionCommands { CuboidRegion cuboidregion = (CuboidRegion) region; BlockVector3 pos1 = cuboidregion.getPos1(); BlockVector3 pos2 = cuboidregion.getPos2(); - int blocksChanged = editSession.drawLine(patternArg, pos1, pos2, thickness, !shell); + int blocksChanged = editSession.drawLine(patternArgOpt, pos1, pos2, thickness, !shell); BBC.VISITOR_BLOCK.send(actor, blocksChanged); return blocksChanged; @@ -317,7 +317,7 @@ public class RegionCommands { ) @CommandPermissions("worldedit.region.overlay") @Logging(REGION) - public void lay(FawePlayer fp, EditSession editSession, @Selection Region region, Pattern patternArg, InjectedValueAccess context) throws WorldEditException { + public void lay(FawePlayer fp, EditSession editSession, @Selection Region region, @Arg(name = "pattern", desc = "The pattern of blocks to lay") Pattern patternArg, InjectedValueAccess context) throws WorldEditException { fp.checkConfirmationRegion(() -> { BlockVector3 max = region.getMaximumPoint(); int maxY = max.getBlockY(); @@ -406,7 +406,7 @@ public class RegionCommands { @Arg(desc = "# of iterations to perform", def = "1") int iterations, @Arg(desc = "The mask of blocks to use as the height map", def = "") - Mask mask, + Mask maskOpt, @Switch(name = 's', desc = "TODO") boolean snow, InjectedValueAccess context) throws WorldEditException { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); @@ -417,7 +417,7 @@ public class RegionCommands { } fp.checkConfirmationRegion(() -> { try { - HeightMap heightMap = new HeightMap(editSession, region, mask, snow); + HeightMap heightMap = new HeightMap(editSession, region, maskOpt, snow); HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0)); int affected = heightMap.applyFilter(filter, iterations); BBC.VISITOR_BLOCK.send(fp, affected); @@ -671,14 +671,14 @@ public class RegionCommands { @Selection Region region, @Range(min = 0) @Arg(desc = "Thickness of the shell to leave", def = "0") int thickness, - @Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air") - Pattern patternArg, + @Arg(name = "pattern", desc = "The pattern of blocks to replace the hollowed area with", def = "air") + Pattern patternArgOpt, @ArgFlag(name = 'm', desc = "Mask to hollow with") Mask mask, InjectedValueAccess context) throws WorldEditException { checkCommandArgument(thickness >= 0, "Thickness must be >= 0"); Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask; fp.checkConfirmationRegion(() -> { - int affected = editSession.hollowOutRegion(region, thickness, patternArg, finalMask); + int affected = editSession.hollowOutRegion(region, thickness, patternArgOpt, finalMask); BBC.VISITOR_BLOCK.send(fp, affected); }, getArguments(context), region, context); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index 5481447e6..837669aa9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -555,7 +555,7 @@ public class SelectionCommands { public void select(Actor actor, World world, LocalSession session, EditSession editSession, @Arg(desc = "Selector to switch to", def = "") SelectorChoice selector, - @Arg(desc = "Selector mask", def = "") Mask mask, + @Arg(desc = "Selector mask", def = "") Mask maskOpt, @Switch(name = 'd', desc = "Set default selector") boolean setDefaultSelector) throws WorldEditException { if (selector == null) { @@ -614,11 +614,11 @@ public class SelectionCommands { break; case FUZZY: case MAGIC: - if (mask == null) { - mask = new IdMask(world); + if (maskOpt == null) { + maskOpt = new IdMask(world); } //TODO Make FuzzyRegionSelector accept actors - newSelector = new FuzzyRegionSelector((Player) actor, editSession, mask); + newSelector = new FuzzyRegionSelector((Player) actor, editSession, maskOpt); actor.print(BBC.SEL_FUZZY.s()); actor.print(BBC.SEL_LIST.s()); break; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java index f3a4d5252..6af865433 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java @@ -40,6 +40,7 @@ import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.world.item.ItemType; @@ -107,10 +108,7 @@ public class ToolCommands { desc = "Inspect edits within a radius" ) @CommandPermissions("worldedit.tool.inspect") - public void inspectBrush(Player player, LocalSession session, - @Arg(desc = "The radius of the brush", def = "1") - double radius) throws WorldEditException { - radius = Math.max(1,radius); + public void inspectBrush(Player player, LocalSession session) throws WorldEditException { BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); session.setTool(player, new InspectBrush()); BBC.TOOL_INSPECT.send(player, itemStack.getType().getName()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java index 3368eb3d1..471cd1304 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java @@ -74,9 +74,9 @@ public class ToolUtilCommands { @CommandPermissions("worldedit.brush.options.mask") public void mask(Player player, LocalSession session, @Arg(desc = "The mask to set", def = "") - Mask mask) throws WorldEditException { - session.getBrushTool(player).setMask(mask); - if (mask == null) { + Mask maskOpt) throws WorldEditException { + session.getBrushTool(player).setMask(maskOpt); + if (maskOpt == null) { player.print("Brush mask disabled."); } else { player.print("Brush mask set."); @@ -129,9 +129,9 @@ public class ToolUtilCommands { @CommandPermissions("worldedit.brush.options.tracemask") public void traceMask(Player player, LocalSession session, @Arg(desc = "The trace mask to set", def = "") - Mask mask) throws WorldEditException { - session.getBrushTool(player).setTraceMask(mask); - if (mask == null) { + Mask maskOpt) throws WorldEditException { + session.getBrushTool(player).setTraceMask(maskOpt); + if (maskOpt == null) { player.print("Trace mask disabled."); } else { player.print("Trace mask set."); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/TransformCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/TransformCommands.java index 159763252..f93ebe210 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/TransformCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/TransformCommands.java @@ -22,7 +22,7 @@ import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; -@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) +@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class TransformCommands { @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java index d5d4414f7..d734e09e8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java @@ -64,6 +64,7 @@ import com.sk89q.worldedit.function.visitor.EntityVisitor; import com.sk89q.worldedit.internal.annotation.Range; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; +import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CylinderRegion; @@ -102,7 +103,7 @@ import org.jetbrains.annotations.NotNull; /** * Utility commands. */ -@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class, CommandQueuedConditionGenerator.Registration.class}) +@CommandContainer(superTypes = {CommandQueuedConditionGenerator.Registration.class, CommandPermissionsConditionGenerator.Registration.class}) public class UtilityCommands { private final WorldEdit we; @@ -191,10 +192,11 @@ public class UtilityCommands { @Arg(desc = "The blocks to fill with") Pattern pattern, @Range(min=1) @Arg(desc = "The radius to fill in") - double radius, + Expression radiusExp, @Range(min=1) @Arg(desc = "The depth to fill", def = "1") int depth, - @Arg(desc = "Direction to fill", def = "down") BlockVector3 direction) throws WorldEditException { + @Arg(desc = "Direction to fill", def = "down") BlockVector3 direction) throws WorldEditException, EvaluationException { + double radius = radiusExp.evaluate(); radius = Math.max(1, radius); we.checkMaxRadius(radius); depth = Math.max(1, depth); @@ -286,9 +288,10 @@ public class UtilityCommands { @Arg(desc = "The blocks to fill with") Pattern pattern, @Range(min=1) @Arg(desc = "The radius to fill in") - double radius, + Expression radiusExp, @Arg(desc = "The depth to fill", def = "") - Integer depth) throws WorldEditException { + Integer depth) throws WorldEditException, EvaluationException { + double radius = radiusExp.evaluate(); radius = Math.max(1, radius); we.checkMaxRadius(radius); depth = depth == null ? Integer.MAX_VALUE : Math.max(1, depth); @@ -308,9 +311,10 @@ public class UtilityCommands { @Logging(PLACEMENT) public int drain(Player player, LocalSession session, EditSession editSession, @Range(min=0) @Arg(desc = "The radius to drain") - double radius, + Expression radiusExp, @Switch(name = 'w', desc = "Also un-waterlog blocks") - boolean waterlogged) throws WorldEditException { + boolean waterlogged) throws WorldEditException, EvaluationException { + double radius = radiusExp.evaluate(); radius = Math.max(0, radius); we.checkMaxRadius(radius); int affected = editSession.drainArea( @@ -328,7 +332,8 @@ public class UtilityCommands { @Logging(PLACEMENT) public int fixLava(Player player, LocalSession session, EditSession editSession, @Range(min=0) @Arg(desc = "The radius to fix in") - double radius) throws WorldEditException { + Expression radiusExp) throws WorldEditException, EvaluationException { + double radius = radiusExp.evaluate(); radius = Math.max(0, radius); we.checkMaxRadius(radius); int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, BlockTypes.LAVA); @@ -345,7 +350,8 @@ public class UtilityCommands { @Logging(PLACEMENT) public int fixWater(Player player, LocalSession session, EditSession editSession, @Range(min=0) @Arg(desc = "The radius to fix in") - double radius) throws WorldEditException { + Expression radiusExp) throws WorldEditException, EvaluationException { + double radius = radiusExp.evaluate(); radius = Math.max(0, radius); we.checkMaxRadius(radius); int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, BlockTypes.WATER); @@ -456,11 +462,11 @@ public class UtilityCommands { @Logging(PLACEMENT) public int snow(Player player, LocalSession session, EditSession editSession, @Range(min=1) @Arg(desc = "The radius of the circle to snow in", def = "10") - double size) throws WorldEditException { - size = Math.max(1, size); - we.checkMaxRadius(size); + double sizeOpt) throws WorldEditException { + sizeOpt = Math.max(1, sizeOpt); + we.checkMaxRadius(sizeOpt); - int affected = editSession.simulateSnow(session.getPlacementPosition(player), size); + int affected = editSession.simulateSnow(session.getPlacementPosition(player), sizeOpt); player.print(affected + " surface(s) covered. Let it snow~"); return affected; } @@ -474,11 +480,11 @@ public class UtilityCommands { @Logging(PLACEMENT) public int thaw(Player player, LocalSession session, EditSession editSession, @Range(min=1) @Arg(desc = "The radius of the circle to thaw in", def = "10") - double size) throws WorldEditException { - size = Math.max(1, size); - we.checkMaxRadius(size); + double sizeOpt) throws WorldEditException { + sizeOpt = Math.max(1, sizeOpt); + we.checkMaxRadius(sizeOpt); - int affected = editSession.thaw(session.getPlacementPosition(player), size); + int affected = editSession.thaw(session.getPlacementPosition(player), sizeOpt); player.print(affected + " surface(s) thawed."); return affected; } @@ -492,14 +498,14 @@ public class UtilityCommands { @Logging(PLACEMENT) public int green(Player player, LocalSession session, EditSession editSession, @Range(min=1) @Arg(desc = "The radius of the circle to convert in", def = "10") - double size, + double sizeOpt, @Switch(name = 'f', desc = "Also convert coarse dirt") boolean convertCoarse) throws WorldEditException { - size = Math.max(1, size); - we.checkMaxRadius(size); + sizeOpt = Math.max(1, sizeOpt); + we.checkMaxRadius(sizeOpt); final boolean onlyNormalDirt = !convertCoarse; - final int affected = editSession.green(session.getPlacementPosition(player), size, onlyNormalDirt); + final int affected = editSession.green(session.getPlacementPosition(player), sizeOpt, onlyNormalDirt); BBC.VISITOR_BLOCK.send(player, affected); return affected; } @@ -703,8 +709,8 @@ public class UtilityCommands { @ArgFlag(name = 'p', desc = "The page to retrieve", def = "1") int page, @Arg(desc = "The command to retrieve help for", def = "", variable = true) - List command) throws WorldEditException { - PrintCommandHelp.help(command, page, listSubCommands, we, actor); + List commandStr) throws WorldEditException { + PrintCommandHelp.help(commandStr, page, listSubCommands, we, actor); } public static void list(File dir, Actor actor, List args, @Range(min = 0) int page, String formatName, boolean playerFolder, String onClickCmd) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index 6b55e6457..1c72a8477 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -196,7 +196,7 @@ public class WorldEditCommands { @ArgFlag(name = 'p', desc = "The page to retrieve", def = "1") int page, @Arg(desc = "The command to retrieve help for", def = "", variable = true) - List command) throws WorldEditException { - PrintCommandHelp.help(command, page, listSubCommands, we, actor); + List commandStr) throws WorldEditException { + PrintCommandHelp.help(commandStr, page, listSubCommands, we, actor); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index c3f5963ec..dff89da9d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -422,7 +422,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool */ public void setRange(int range) { if (range == DEFAULT_RANGE) { - range = -1; + this.range = -1; } else { this.range = range; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CommandQueuedConditionGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CommandQueuedConditionGenerator.java index 8a3348eca..686f275e3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CommandQueuedConditionGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CommandQueuedConditionGenerator.java @@ -18,7 +18,9 @@ public final class CommandQueuedConditionGenerator implements CommandConditionGe @Override public Command.Condition generateCondition(Method commandMethod) { CommandQueued annotation = commandMethod.getAnnotation(CommandQueued.class); - checkNotNull(annotation, "Annotation is missing from commandMethod"); + if (annotation == null) { + return Command.Condition.TRUE; + } return new CommandQueuedCondition(annotation.value()); } }