Fix some arguments

This commit is contained in:
Jesse Boyd 2019-08-07 06:18:44 +10:00
parent 4c2b753687
commit 92fb90de09
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
19 changed files with 275 additions and 278 deletions

View File

@ -116,7 +116,7 @@ public class AnvilCommands {
public void replaceAll(Player player, String folder, public void replaceAll(Player player, String folder,
@Arg(name = "from", desc = "String", def = "") @Arg(name = "from", desc = "String", def = "")
String fromPattern, String fromPattern,
String toPattern, String toPatternStr,
@Switch(name = 'd', desc = "Disable wildcard data matching") @Switch(name = 'd', desc = "Disable wildcard data matching")
boolean useData) throws WorldEditException { boolean useData) throws WorldEditException {
// final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED // final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED
@ -299,7 +299,7 @@ public class AnvilCommands {
desc = "Replace all blocks in the selection with another" desc = "Replace all blocks in the selection with another"
) )
@CommandPermissions("worldedit.anvil.replaceall") @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 // MCAFilterCounter filter; TODO NOT IMPLEMENTED
// if (useMap) { // if (useMap) {
// if (to instanceof RandomPattern) { // if (to instanceof RandomPattern) {
@ -328,7 +328,7 @@ public class AnvilCommands {
desc = "Count all blocks in a world" desc = "Count all blocks in a world"
) )
@CommandPermissions("worldedit.anvil.countall") @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<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true); // Set<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true);
// MCAFilterCounter filter; // MCAFilterCounter filter;
// if (useData || arg.contains(":")) { // Optimize for both cases // if (useData || arg.contains(":")) { // Optimize for both cases
@ -402,7 +402,7 @@ public class AnvilCommands {
desc = "Count blocks in a selection" desc = "Count blocks in a selection"
) )
@CommandPermissions("worldedit.anvil.count") @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<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true); TODO NOT IMPLEMENTED // Set<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true); TODO NOT IMPLEMENTED
// MCAFilterCounter filter; // MCAFilterCounter filter;
// if (useData || arg.contains(":")) { // Optimize for both cases // if (useData || arg.contains(":")) { // Optimize for both cases
@ -503,7 +503,7 @@ public class AnvilCommands {
desc = "Replace all blocks in the selection with another" desc = "Replace all blocks in the selection with another"
) )
@CommandPermissions("worldedit.anvil.replace") @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 // final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED
// if (from == null) { // if (from == null) {
// matchFrom = FaweBlockMatcher.NOT_AIR; // matchFrom = FaweBlockMatcher.NOT_AIR;
@ -525,8 +525,7 @@ public class AnvilCommands {
desc = "Replace all blocks in the selection with a pattern" desc = "Replace all blocks in the selection with a pattern"
) )
@CommandPermissions("worldedit.anvil.replace") @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 toPattern, @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 to, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap) throws WorldEditException {
// MCAFilterCounter filter; TODO NOT IMPLEMENTED // MCAFilterCounter filter; TODO NOT IMPLEMENTED
// if (useMap) { // if (useMap) {
// if (to instanceof RandomPattern) { // if (to instanceof RandomPattern) {
@ -556,8 +555,8 @@ public class AnvilCommands {
desc = "Set all blocks in the selection with a pattern" desc = "Set all blocks in the selection with a pattern"
) )
@CommandPermissions("worldedit.anvil.set") @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 // 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 to) throws WorldEditException { public void set(Player player, EditSession editSession, @Selection Region selection, final Pattern toPattern) throws WorldEditException {
// MCAFilterCounter filter = new SetPatternFilter(to); TODO NOT IMPLEMENTED // MCAFilterCounter filter = new SetPatternFilter(to); TODO NOT IMPLEMENTED
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) { // if (result != null) {

View File

@ -240,12 +240,12 @@ public class CFICommands {
desc = "Set the floor and main block" desc = "Set the floor and main block"
) )
@CommandPermissions("worldedit.anvil.cfi") @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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) { if (image != null) {
gen.setColumn(load(image), patternArg, !disableWhiteOnly); gen.setColumn(load(image), patternArg, !disableWhiteOnly);
} else if (mask != null) { } else if (maskOpt != null) {
gen.setColumn(mask, patternArg); gen.setColumn(maskOpt, patternArg);
} else { } else {
gen.setColumn(patternArg); gen.setColumn(patternArg);
} }
@ -259,19 +259,19 @@ public class CFICommands {
desc = "Set the floor (default: grass)" desc = "Set the floor (default: grass)"
) )
@CommandPermissions("worldedit.anvil.cfi") @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){ 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, mask, disableWhiteOnly); floor(fp, patternArg, image, maskOpt, disableWhiteOnly);
fp.sendMessage("Set floor!"); fp.sendMessage("Set floor!");
assertSettings(fp).resetComponent(); assertSettings(fp).resetComponent();
component(fp); 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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) { if (image != null) {
gen.setFloor(load(image), patternArg, !disableWhiteOnly); gen.setFloor(load(image), patternArg, !disableWhiteOnly);
} else if (mask != null) { } else if (maskOpt != null) {
gen.setFloor(mask, patternArg); gen.setFloor(maskOpt, patternArg);
} else { } else {
gen.setFloor(patternArg); gen.setFloor(patternArg);
} }
@ -282,19 +282,19 @@ public class CFICommands {
desc = "Set the main block (default: stone)" desc = "Set the main block (default: stone)"
) )
@CommandPermissions("worldedit.anvil.cfi") @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){ 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, mask, disableWhiteOnly); main(fp, patternArg, image, maskOpt, disableWhiteOnly);
fp.sendMessage("Set main!"); fp.sendMessage("Set main!");
assertSettings(fp).resetComponent(); assertSettings(fp).resetComponent();
component(fp); 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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) { if (image != null) {
gen.setMain(load(image), patternArg, !disableWhiteOnly); gen.setMain(load(image), patternArg, !disableWhiteOnly);
} else if (mask != null) { } else if (maskOpt != null) {
gen.setMain(mask, patternArg); gen.setMain(maskOpt, patternArg);
} else { } else {
gen.setMain(patternArg); gen.setMain(patternArg);
} }
@ -308,12 +308,12 @@ public class CFICommands {
"e.g. Tallgrass" "e.g. Tallgrass"
) )
@CommandPermissions("worldedit.anvil.cfi") @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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) { if (image != null) {
gen.setOverlay(load(image), patternArg, !disableWhiteOnly); gen.setOverlay(load(image), patternArg, !disableWhiteOnly);
} else if (mask != null) { } else if (maskOpt != null) {
gen.setOverlay(mask, patternArg); gen.setOverlay(maskOpt, patternArg);
} else { } else {
gen.setOverlay(patternArg); gen.setOverlay(patternArg);
} }
@ -330,18 +330,18 @@ public class CFICommands {
" - A good value for radius and iterations would be 1 8." " - A good value for radius and iterations would be 1 8."
) )
@CommandPermissions("worldedit.anvil.cfi") @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){ 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, mask, disableWhiteOnly); smooth(fp, radius, iterations, image, maskOpt, disableWhiteOnly);
assertSettings(fp).resetComponent(); assertSettings(fp).resetComponent();
component(fp); 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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) { if (image != null) {
gen.smooth(load(image), !disableWhiteOnly, radius, iterations); gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
} else { } else {
gen.smooth(mask, radius, iterations); gen.smooth(maskOpt, radius, iterations);
} }
} }
@ -350,11 +350,11 @@ public class CFICommands {
desc = "Create some snow" desc = "Create some snow"
) )
@CommandPermissions("worldedit.anvil.cfi") @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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, mask, disableWhiteOnly); floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, maskOpt, disableWhiteOnly);
main(fp, BlockTypes.SNOW_BLOCK, image, mask, disableWhiteOnly); main(fp, BlockTypes.SNOW_BLOCK, image, maskOpt, disableWhiteOnly);
smooth(fp, 1, 8, image, mask, disableWhiteOnly); smooth(fp, 1, 8, image, maskOpt, disableWhiteOnly);
fp.toWorldEditPlayer().print(TextComponent.of("Added snow!")); fp.toWorldEditPlayer().print(TextComponent.of("Added snow!"));
assertSettings(fp).resetComponent(); assertSettings(fp).resetComponent();
component(fp); component(fp);
@ -382,8 +382,8 @@ public class CFICommands {
"`#clipboard` will only use the blocks present in your clipboard." "`#clipboard` will only use the blocks present in your clipboard."
) )
@CommandPermissions("worldedit.anvil.cfi") @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 { public void paletteblocks(FawePlayer fp, Player player, LocalSession session, @Arg(name = "arg", desc = "String", def = "") String argOpt) throws EmptyClipboardException, InputParseException, FileNotFoundException {
if (arg == null) { if (argOpt == null) {
TextComponent build = TextComponent.builder("What blocks do you want to color with?") TextComponent build = TextComponent.builder("What blocks do you want to color with?")
.append(newline()) .append(newline())
.append(TextComponent.of("[All]") .append(TextComponent.of("[All]")
@ -417,7 +417,7 @@ public class CFICommands {
Request.request().setExtent(generator); Request.request().setExtent(generator);
Set<BlockType> blocks; Set<BlockType> blocks;
switch (arg.toLowerCase()) { switch (argOpt.toLowerCase()) {
case "true": case "true":
case "*": { case "*": {
generator.setTextureUtil(Fawe.get().getTextureUtil()); generator.setTextureUtil(Fawe.get().getTextureUtil());
@ -447,7 +447,7 @@ public class CFICommands {
parserContext.setSession(session); parserContext.setSession(session);
parserContext.setExtent(extent); parserContext.setExtent(extent);
Request.request().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(); TextureUtil tu = Fawe.get().getTextureUtil();
for (int typeId : tu.getValidBlockIds()) { for (int typeId : tu.getValidBlockIds()) {
BlockType type = BlockTypes.get(typeId); BlockType type = BlockTypes.get(typeId);
@ -504,7 +504,7 @@ public class CFICommands {
" - The distance is the spacing between each schematic" " - The distance is the spacing between each schematic"
) )
@CommandPermissions("worldedit.anvil.cfi") @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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
World world = fp.getWorld(); 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" " - If a mask is used, the biome will be set anywhere the mask applies"
) )
@CommandPermissions("worldedit.anvil.cfi") @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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) { if (image != null) {
gen.setBiome(load(image), biomeType, !disableWhiteOnly); gen.setBiome(load(image), biomeType, !disableWhiteOnly);
} else if (mask != null) { } else if (maskOpt != null) {
gen.setBiome(mask, biomeType); gen.setBiome(maskOpt, biomeType);
} else { } else {
gen.setBiome(biomeType); gen.setBiome(biomeType);
} }
@ -561,7 +561,7 @@ public class CFICommands {
descFooter = "Use a specific pattern and settings to generate ore" descFooter = "Use a specific pattern and settings to generate ore"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); assertSettings(fp).getGenerator().addOre(mask, patternArg, size, frequency, rariry, minY, maxY);
fp.toWorldEditPlayer().print(TextComponent.of("Added ore!")); fp.toWorldEditPlayer().print(TextComponent.of("Added ore!"));
populate(fp); populate(fp);
@ -572,7 +572,7 @@ public class CFICommands {
desc = "Generate the vanilla ores" desc = "Generate the vanilla ores"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); assertSettings(fp).getGenerator().addDefaultOres(mask);
fp.toWorldEditPlayer().print(TextComponent.of("Added ores!")); fp.toWorldEditPlayer().print(TextComponent.of("Added ores!"));
populate(fp); populate(fp);
@ -584,12 +584,12 @@ public class CFICommands {
descFooter = "Set the terrain height either based on an image heightmap, or a numeric value." descFooter = "Set the terrain height either based on an image heightmap, or a numeric value."
) )
@CommandPermissions("worldedit.anvil.cfi") @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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (!MathMan.isInteger(arg)) { if (!MathMan.isInteger(imageStr)) {
gen.setHeight(ImageUtil.getImage(arg)); gen.setHeight(ImageUtil.getImage(imageStr));
} else { } else {
gen.setHeights(Integer.parseInt(arg)); gen.setHeights(Integer.parseInt(imageStr));
} }
fp.toWorldEditPlayer().print("Set Height!"); fp.toWorldEditPlayer().print("Set Height!");
component(fp); component(fp);
@ -698,7 +698,7 @@ public class CFICommands {
) )
// ![79,174,212,5:3,5:4,18,161,20] // ![79,174,212,5:3,5:4,18,161,20]
@CommandPermissions("worldedit.anvil.cfi") @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); CFISettings settings = assertSettings(fp);
settings.getGenerator().setColorWithGlass(load(image)); settings.getGenerator().setColorWithGlass(load(image));
fp.toWorldEditPlayer().print(TextComponent.of("Set color with glass!")); 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" "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); CFISettings settings = assertSettings(fp);
HeightMapMCAGenerator gen = settings.getGenerator(); HeightMapMCAGenerator gen = settings.getGenerator();
if (imageMask != null) { if (imageMask != null) {
gen.setColor(load(image), load(imageMask), !disableWhiteOnly); gen.setColor(load(image), load(imageMask), !disableWhiteOnly);
} else if (mask != null) { } else if (maskOpt != null) {
gen.setColor(load(image), mask); gen.setColor(load(image), maskOpt);
} else { } else {
gen.setColor(load(image)); gen.setColor(load(image));
} }
@ -739,9 +739,9 @@ public class CFICommands {
"The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance" "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); 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!")); fp.toWorldEditPlayer().print(TextComponent.of("Set color with blocks and biomes!"));
settings.resetColoring(); settings.resetColoring();
mainMenu(fp); mainMenu(fp);
@ -755,7 +755,7 @@ public class CFICommands {
" - If you changed the block to something other than grass you will not see anything." " - If you changed the block to something other than grass you will not see anything."
) )
@CommandPermissions("worldedit.anvil.cfi") @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); CFISettings settings = assertSettings(fp);
settings.getGenerator().setBiomeColor(load(image)); settings.getGenerator().setBiomeColor(load(image));
fp.toWorldEditPlayer().print(TextComponent.of("Set color with biomes!")); fp.toWorldEditPlayer().print(TextComponent.of("Set color with biomes!"));
@ -855,14 +855,14 @@ public class CFICommands {
desc = "Select a mask" desc = "Select a mask"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); CFISettings settings = assertSettings(fp);
String[] split = getArguments(context).split(" "); String[] split = getArguments(context).split(" ");
int index = 2; int index = 2;
settings.imageMask = imageMask; settings.imageMask = imageMask;
settings.imageMaskArg = imageMask != null ? split[index++] : null; settings.imageMaskArg = imageMask != null ? split[index++] : null;
settings.mask = mask; settings.mask = maskOpt;
settings.maskArg = mask != null ? split[index++] : null; settings.maskArg = maskOpt != null ? split[index++] : null;
settings.whiteOnly = !disableWhiteOnly; settings.whiteOnly = !disableWhiteOnly;
String s = "/cfi mask http://"; String s = "/cfi mask http://";

View File

@ -167,12 +167,6 @@ public class EditSession extends AbstractDelegateExtent implements SimpleWorld,
private static final Logger log = LoggerFactory.getLogger(EditSession.class); 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 * Used by {@link EditSession#setBlock(BlockVector3, BlockStateHolder, Stage)} to
* determine which {@link Extent}s should be bypassed. * determine which {@link Extent}s should be bypassed.
@ -240,7 +234,7 @@ public class EditSession extends AbstractDelegateExtent implements SimpleWorld,
this.world = builder.getWorld(); this.world = builder.getWorld();
this.worldName = builder.getWorldName(); this.worldName = builder.getWorldName();
this.wrapped = builder.isWrapped(); this.wrapped = builder.isWrapped();
this.fastMode = builder.hasFastMode(); // this.fastMode = builder.hasFastMode(); Not used
this.history = builder.getHistory(); this.history = builder.getHistory();
this.bypassHistory = builder.getBypassHistory(); this.bypassHistory = builder.getBypassHistory();
this.bypassAll = builder.getBypassAll(); this.bypassAll = builder.getBypassAll();
@ -610,7 +604,6 @@ public class EditSession extends AbstractDelegateExtent implements SimpleWorld,
* @param enabled true to enable * @param enabled true to enable
*/ */
public void setFastMode(boolean enabled) { public void setFastMode(boolean enabled) {
this.fastMode = enabled;
disableHistory(enabled); disableHistory(enabled);
} }

View File

@ -97,6 +97,7 @@ import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.annotation.Range; import com.sk89q.worldedit.internal.annotation.Range;
import com.sk89q.worldedit.internal.expression.Expression; 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.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.factory.RegionFactory; import com.sk89q.worldedit.regions.factory.RegionFactory;
@ -152,9 +153,9 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.blendball") @CommandPermissions("worldedit.brush.blendball")
public BrushSettings blendBallBrush(Player player, LocalSession session, public BrushSettings blendBallBrush(Player player, LocalSession session,
@Arg(desc = "The radius to sample for blending", def = "5") @Arg(desc = "The radius to sample for blending", def = "5")
Expression radius, InjectedValueAccess context) throws WorldEditException { Expression radiusOpt, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
return set(session, context, new BlendBall()).setSize(radius); return set(session, context, new BlendBall()).setSize(radiusOpt);
} }
@Command( @Command(
@ -164,9 +165,9 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.erode") @CommandPermissions("worldedit.brush.erode")
public BrushSettings erodeBrush(Player player, LocalSession session, public BrushSettings erodeBrush(Player player, LocalSession session,
@Arg(desc = "The radius for eroding", def = "5") @Arg(desc = "The radius for eroding", def = "5")
Expression radius, InjectedValueAccess context) throws WorldEditException { Expression radiusOpt, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
return set(session, context, new ErodeBrush()).setSize(radius); return set(session, context, new ErodeBrush()).setSize(radiusOpt);
} }
@Command( @Command(
@ -176,9 +177,9 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.pull") @CommandPermissions("worldedit.brush.pull")
public BrushSettings pullBrush(Player player, LocalSession session, public BrushSettings pullBrush(Player player, LocalSession session,
@Arg(desc = "The radius to sample for blending", def = "5") @Arg(desc = "The radius to sample for blending", def = "5")
Expression radius, InjectedValueAccess context) throws WorldEditException { Expression radiusOpt, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
return set(session, context, new RaiseBrush()).setSize(radius); return set(session, context, new RaiseBrush()).setSize(radiusOpt);
} }
@Command( @Command(
@ -188,9 +189,9 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.sphere") @CommandPermissions("worldedit.brush.sphere")
public BrushSettings circleBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, public BrushSettings circleBrush(Player player, EditSession editSession, LocalSession session, Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "5") @Arg(desc = "The radius to sample for blending", def = "5")
Expression radius, InjectedValueAccess context) throws WorldEditException { Expression radiusOpt, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
return set(session, context, new CircleBrush(player)).setSize(radius).setFill(fill); return set(session, context, new CircleBrush(player)).setSize(radiusOpt).setFill(fill);
} }
@Command( @Command(
@ -203,14 +204,14 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.recursive") @CommandPermissions("worldedit.brush.recursive")
public BrushSettings recursiveBrush(Player player, LocalSession session, EditSession editSession, Pattern fill, public BrushSettings recursiveBrush(Player player, LocalSession session, EditSession editSession, Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "5") @Arg(desc = "The radius to sample for blending", def = "5")
Expression radius, Expression radiusOpt,
@Switch(name = 'd', desc = "Apply in depth first order") @Switch(name = 'd', desc = "Apply in depth first order")
boolean depthFirst, boolean depthFirst,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
return set(session, context, return set(session, context,
new RecurseBrush(depthFirst)) new RecurseBrush(depthFirst))
.setSize(radius) .setSize(radiusOpt)
.setFill(fill) .setFill(fill)
.setMask(new IdMask(editSession)); .setMask(new IdMask(editSession));
} }
@ -223,17 +224,17 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.line") @CommandPermissions("worldedit.brush.line")
public BrushSettings lineBrush(Player player, LocalSession session, Pattern fill, public BrushSettings lineBrush(Player player, LocalSession session, Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "0") @Arg(desc = "The radius to sample for blending", def = "0")
Expression radius, Expression radiusOpt,
@Switch(name = 'h', desc = "Create only a shell") @Switch(name = 'h', desc = "Create only a shell")
boolean shell, boolean shell,
@Switch(name = 's', desc = "Selects the clicked point after drawing") @Switch(name = 's', desc = "Selects the clicked point after drawing")
boolean select, boolean select,
@Switch(name = 'f', desc = "Create a flat line") @Switch(name = 'f', desc = "Create a flat line")
boolean flat, InjectedValueAccess context) throws WorldEditException { boolean flat, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
return set(session, context, return set(session, context,
new LineBrush(shell, select, flat)) new LineBrush(shell, select, flat))
.setSize(radius) .setSize(radiusOpt)
.setFill(fill); .setFill(fill);
} }
@ -250,12 +251,12 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.spline") @CommandPermissions("worldedit.brush.spline")
public BrushSettings splineBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, public BrushSettings splineBrush(Player player, EditSession editSession, LocalSession session, Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "25") @Arg(desc = "The radius to sample for blending", def = "25")
Expression radius, InjectedValueAccess context) throws WorldEditException { Expression radiusOpt, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
player.print(BBC.BRUSH_SPLINE.format(radius)); player.print(BBC.BRUSH_SPLINE.format(radiusOpt));
return set(session, context, return set(session, context,
new SplineBrush(player, session)) new SplineBrush(player, session))
.setSize(radius) .setSize(radiusOpt)
.setFill(fill); .setFill(fill);
} }
@ -281,7 +282,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.spline") @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, 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") @Arg(desc = "The radius to sample for blending", def = "0")
Expression radius, Expression radiusOpt,
@Switch(name = 'h', desc = "Create only a shell") @Switch(name = 'h', desc = "Create only a shell")
boolean shell, boolean shell,
@Switch(name = 's', desc = "Select the clicked point after drawing") @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") @Switch(name = 'd', desc = "sags the catenary toward the facing direction")
boolean facingDirection, boolean facingDirection,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
Brush brush = new CatenaryBrush(shell, select, facingDirection, lengthFactor); Brush brush = new CatenaryBrush(shell, select, facingDirection, lengthFactor);
return set(session, context, return set(session, context,
new CatenaryBrush(shell, select, facingDirection, lengthFactor)) new CatenaryBrush(shell, select, facingDirection, lengthFactor))
.setSize(radius) .setSize(radiusOpt)
.setFill(fill); .setFill(fill);
} }
@ -307,12 +308,12 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.surfacespline") // 0, 0, 0, 10, 0, @CommandPermissions("worldedit.brush.surfacespline") // 0, 0, 0, 10, 0,
public BrushSettings surfaceSpline(Player player, LocalSession session, Pattern fill, public BrushSettings surfaceSpline(Player player, LocalSession session, Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "0") @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 { 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(radius)); player.print(BBC.BRUSH_SPLINE.format(radiusOpt));
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
return set(session, context, return set(session, context,
new SurfaceSpline(tension, bias, continuity, quality)) new SurfaceSpline(tension, bias, continuity, quality))
.setSize(radius) .setSize(radiusOpt)
.setFill(fill); .setFill(fill);
} }
@ -342,12 +343,12 @@ public class BrushCommands {
@Arg(desc = "The pattern of blocks to set") @Arg(desc = "The pattern of blocks to set")
Pattern pattern, Pattern pattern,
@Arg(desc = "The radius of the sphere", def = "2") @Arg(desc = "The radius of the sphere", def = "2")
Expression radius, Expression radiusOpt,
@Switch(name = 'h', desc = "Create hollow spheres instead") @Switch(name = 'h', desc = "Create hollow spheres instead")
boolean hollow, boolean hollow,
@Switch(name = 'f', desc = "Create falling spheres instead") @Switch(name = 'f', desc = "Create falling spheres instead")
boolean falling, InjectedValueAccess context) throws WorldEditException { boolean falling, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
Brush brush; Brush brush;
if (hollow) { if (hollow) {
brush = new HollowSphereBrush(); brush = new HollowSphereBrush();
@ -370,7 +371,7 @@ public class BrushCommands {
} }
return set(session, context, return set(session, context,
brush) brush)
.setSize(radius) .setSize(radiusOpt)
.setFill(pattern); .setFill(pattern);
} }
@ -384,12 +385,12 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.shatter") @CommandPermissions("worldedit.brush.shatter")
public BrushSettings shatterBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, public BrushSettings shatterBrush(Player player, EditSession editSession, LocalSession session, Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "10") @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 { @Arg(desc = "Lines", def = "10") int count, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
return set(session, context, return set(session, context,
new ShatterBrush(count)) new ShatterBrush(count))
.setSize(radius) .setSize(radiusOpt)
.setFill(fill) .setFill(fill)
.setMask(new ExistingBlockMask(editSession)); .setMask(new ExistingBlockMask(editSession));
} }
@ -401,14 +402,14 @@ public class BrushCommands {
) )
@CommandPermissions("worldedit.brush.stencil") @CommandPermissions("worldedit.brush.stencil")
public BrushSettings stencilBrush(Player player, LocalSession session, Pattern fill, 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(name = "image", desc = "String", def = "") String image,
@Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation, @Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation,
@Arg(name = "yscale", desc = "double", def = "1") double yscale, @Arg(name = "yscale", desc = "double", def = "1") double yscale,
@Switch(name = 'w', desc = "Apply at maximum saturation") boolean onlyWhite, @Switch(name = 'w', desc = "Apply at maximum saturation") boolean onlyWhite,
@Switch(name = 'r', desc = "Apply random rotation") boolean randomRotate, @Switch(name = 'r', desc = "Apply random rotation") boolean randomRotate,
InjectedValueAccess context) throws WorldEditException, FileNotFoundException { InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
InputStream stream = getHeightmapStream(image); InputStream stream = getHeightmapStream(image);
HeightBrush brush; HeightBrush brush;
try { try {
@ -421,7 +422,7 @@ public class BrushCommands {
} }
return set(session, context, return set(session, context,
brush) brush)
.setSize(radius) .setSize(radiusOpt)
.setFill(fill); .setFill(fill);
} }
@ -431,14 +432,14 @@ public class BrushCommands {
desc = "Use a height map to paint a surface", desc = "Use a height map to paint a surface",
descFooter = "Use a height map to paint any surface.\n") descFooter = "Use a height map to paint any surface.\n")
@CommandPermissions("worldedit.brush.stencil") @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, ProvideBindings.ImageUri imageUri,
@Arg(def = "1", desc = "scale height") @Range(min = Double.MIN_NORMAL) double yscale, @Arg(def = "1", desc = "scale height") @Range(min = Double.MIN_NORMAL) double yscale,
@Switch(name = 'a', desc = "Use image Alpha") boolean alpha, @Switch(name = 'a', desc = "Use image Alpha") boolean alpha,
@Switch(name = 'f', desc = "Blend the image with existing terrain") boolean fadeOut, @Switch(name = 'f', desc = "Blend the image with existing terrain") boolean fadeOut,
InjectedValueAccess context) throws WorldEditException, IOException { InjectedValueAccess context) throws WorldEditException, IOException {
BufferedImage image = imageUri.load(); BufferedImage image = imageUri.load();
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
if (yscale != 1) { if (yscale != 1) {
ImageUtil.scaleAlpha(image, yscale); ImageUtil.scaleAlpha(image, yscale);
alpha = true; alpha = true;
@ -450,7 +451,7 @@ public class BrushCommands {
ImageBrush brush = new ImageBrush(image, session, alpha); ImageBrush brush = new ImageBrush(image, session, alpha);
return set(session, context, return set(session, context,
brush) brush)
.setSize(radius); .setSize(radiusOpt);
} }
@Command( @Command(
@ -464,10 +465,10 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.surface") @CommandPermissions("worldedit.brush.surface")
public BrushSettings surfaceBrush(LocalSession session, Pattern fill, public BrushSettings surfaceBrush(LocalSession session, Pattern fill,
@Arg(name = "radius", desc = "Expression", def = "5") @Arg(name = "radius", desc = "Expression", def = "5")
Expression radius, Expression radiusOpt,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
return set(session, context, new SurfaceSphereBrush()).setFill(fill).setSize(radius); return set(session, context, new SurfaceSphereBrush()).setFill(fill).setSize(radiusOpt);
} }
@Command( @Command(
@ -477,17 +478,17 @@ public class BrushCommands {
"Video: https://youtu.be/RPZIaTbqoZw?t=34s" "Video: https://youtu.be/RPZIaTbqoZw?t=34s"
) )
@CommandPermissions("worldedit.brush.scatter") @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 { 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(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
Brush brush; Brush brush;
if (overlay) { if (overlay) {
brush = new ScatterOverlayBrush((int) points, (int) distance); brush = new ScatterOverlayBrush((int) pointsOpt, (int) distanceOpt);
} else { } else {
brush = new ScatterBrush((int) points, (int) distance); brush = new ScatterBrush((int) pointsOpt, (int) distanceOpt);
} }
return set(session, context, return set(session, context,
brush) brush)
.setSize(radius) .setSize(radiusOpt)
.setFill(fill); .setFill(fill);
} }
@ -497,8 +498,8 @@ public class BrushCommands {
desc = "Scatter a schematic on a surface" desc = "Scatter a schematic on a surface"
) )
@CommandPermissions("worldedit.brush.populateschematic") @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 { 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(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
try { try {
MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true); MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true);
if (clipboards == null) { if (clipboards == null) {
@ -512,7 +513,7 @@ public class BrushCommands {
} }
return set(session, context, 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) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -526,9 +527,9 @@ public class BrushCommands {
"Pic: https://i.imgur.com/XV0vYoX.png" "Pic: https://i.imgur.com/XV0vYoX.png"
) )
@CommandPermissions("worldedit.brush.layer") @CommandPermissions("worldedit.brush.layer")
public BrushSettings surfaceLayer(LocalSession session, Expression radius, List<BlockState> layers, InjectedValueAccess context) throws WorldEditException { public BrushSettings surfaceLayer(LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, List<BlockState> blockLayers, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); 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( @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." "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") @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 { 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(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
return set(session, context, new SplatterBrush((int) points, (int) recursion, solid)).setSize(radius).setFill(fill); return set(session, context, new SplatterBrush((int) pointsOpt, (int) recursion, solid)).setSize(radiusOpt).setFill(fill);
} }
@Command( @Command(
@ -556,10 +557,10 @@ public class BrushCommands {
" - Placeholders: {x}, {y}, {z}, {world}, {size}" " - Placeholders: {x}, {y}, {z}, {world}, {size}"
) )
@CommandPermissions("worldedit.brush.scattercommand") @CommandPermissions("worldedit.brush.scattercommand")
public BrushSettings scatterCommandBrush(Player player, EditSession editSession, LocalSession session, Expression radius, double points, double distance, List<String> 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<String> commandStr, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
return set(session, context, return set(session, context,
new ScatterCommand((int) points, (int) distance, StringMan.join(command, " "))) new ScatterCommand((int) points, (int) distance, StringMan.join(commandStr, " ")))
.setSize(radius); .setSize(radius);
} }
@ -573,13 +574,13 @@ public class BrushCommands {
@Arg(desc = "The pattern of blocks to set") @Arg(desc = "The pattern of blocks to set")
Pattern pattern, Pattern pattern,
@Arg(desc = "The radius of the cylinder", def = "2") @Arg(desc = "The radius of the cylinder", def = "2")
Expression radius, Expression radiusOpt,
@Arg(desc = "The height of the cylinder", def = "1") @Arg(desc = "The height of the cylinder", def = "1")
int height, int height,
@Switch(name = 'h', desc = "Create hollow cylinders instead") @Switch(name = 'h', desc = "Create hollow cylinders instead")
boolean hollow, boolean hollow,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
worldEdit.checkMaxBrushRadius(height); worldEdit.checkMaxBrushRadius(height);
BrushSettings settings; BrushSettings settings;
@ -588,7 +589,7 @@ public class BrushCommands {
} else { } else {
settings = set(session, context, new CylinderBrush(height)); settings = set(session, context, new CylinderBrush(height));
} }
settings.setSize(radius) settings.setSize(radiusOpt)
.setFill(pattern); .setFill(pattern);
return settings; return settings;
} }
@ -634,20 +635,20 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.smooth") @CommandPermissions("worldedit.brush.smooth")
public BrushSettings smoothBrush(Player player, LocalSession session, EditSession editSession, public BrushSettings smoothBrush(Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The radius to sample for softening", def = "2") @Arg(desc = "The radius to sample for softening", def = "2")
Expression radius, Expression radiusOpt,
@Arg(desc = "The number of iterations to perform", def = "4") @Arg(desc = "The number of iterations to perform", def = "4")
int iterations, int iterations,
@Arg(desc = "The mask of blocks to use for the heightmap", def = "") @Arg(desc = "The mask of blocks to use for the heightmap", def = "")
Mask mask, InjectedValueAccess context) throws WorldEditException { Mask maskOpt, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
FawePlayer fp = FawePlayer.wrap(player); FawePlayer fp = FawePlayer.wrap(player);
FaweLimit limit = Settings.IMP.getLimit(fp); FaweLimit limit = Settings.IMP.getLimit(fp);
iterations = Math.min(limit.MAX_ITERATIONS, iterations); iterations = Math.min(limit.MAX_ITERATIONS, iterations);
return set(session, context, return set(session, context,
new SmoothBrush(iterations, mask)) new SmoothBrush(iterations, maskOpt))
.setSize(radius); .setSize(radiusOpt);
} }
@Command( @Command(
@ -658,14 +659,14 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.ex") @CommandPermissions("worldedit.brush.ex")
public BrushSettings extinguishBrush(Player player, LocalSession session, EditSession editSession, public BrushSettings extinguishBrush(Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The radius to extinguish", def = "5") @Arg(desc = "The radius to extinguish", def = "5")
Expression radius, Expression radiusOpt,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
Pattern fill = BlockTypes.AIR.getDefaultState(); Pattern fill = BlockTypes.AIR.getDefaultState();
return set(session, context, return set(session, context,
new SphereBrush()) new SphereBrush())
.setSize(radius) .setSize(radiusOpt)
.setFill(fill) .setFill(fill)
.setMask(new SingleBlockTypeMask(editSession, BlockTypes.FIRE)); .setMask(new SingleBlockTypeMask(editSession, BlockTypes.FIRE));
} }
@ -678,15 +679,15 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.gravity") @CommandPermissions("worldedit.brush.gravity")
public BrushSettings gravityBrush(Player player, LocalSession session, public BrushSettings gravityBrush(Player player, LocalSession session,
@Arg(desc = "The radius to apply gravity in", def = "5") @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") @Switch(name = 'h', desc = "Affect blocks starting at max Y, rather than the target location Y + radius")
boolean fromMaxY, boolean fromMaxY,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
return set(session, context, return set(session, context,
new GravityBrush(fromMaxY)) new GravityBrush(fromMaxY))
.setSize(radius); .setSize(radiusOpt);
} }
@Command( @Command(
@ -701,8 +702,8 @@ public class BrushCommands {
"Snow Pic: https://i.imgur.com/Hrzn0I4.png" "Snow Pic: https://i.imgur.com/Hrzn0I4.png"
) )
@CommandPermissions("worldedit.brush.height") @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 { 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, radius, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context); return terrainBrush(player, session, radiusOpt, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context);
} }
@Command( @Command(
@ -714,7 +715,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.height") @CommandPermissions("worldedit.brush.height")
public BrushSettings cliffBrush(Player player, LocalSession session, public BrushSettings cliffBrush(Player player, LocalSession session,
@Arg(name = "radius", desc = "Expression", def = "5") @Arg(name = "radius", desc = "Expression", def = "5")
Expression radius, Expression radiusOpt,
@Arg(name = "image", desc = "String", def = "") @Arg(name = "image", desc = "String", def = "")
String image, String image,
@Arg(def = "0", desc = "rotation") @Step(90) @Range(min = 0, max = 360) @Arg(def = "0", desc = "rotation") @Step(90) @Range(min = 0, max = 360)
@ -727,7 +728,7 @@ public class BrushCommands {
boolean layers, boolean layers,
@Switch(name = 's', desc = "Disables smoothing") @Switch(name = 's', desc = "Disables smoothing")
boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { 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( @Command(
@ -736,17 +737,17 @@ public class BrushCommands {
desc = "This brush raises or lowers land towards the clicked point" desc = "This brush raises or lowers land towards the clicked point"
) )
@CommandPermissions("worldedit.brush.height") @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") @Switch(name = 'r', desc = "Enables random off-axis rotation")
boolean randomRotate, boolean randomRotate,
@Switch(name = 'l', desc = "Will work on snow layers") @Switch(name = 'l', desc = "Will work on snow layers")
boolean layers, boolean layers,
@Switch(name = 's', desc = "Disables smoothing") @Switch(name = 's', desc = "Disables smoothing")
boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { 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); worldEdit.checkMaxBrushRadius(radius);
InputStream stream = getHeightmapStream(image); InputStream stream = getHeightmapStream(image);
HeightBrush brush; HeightBrush brush;
@ -791,13 +792,13 @@ public class BrushCommands {
"Video: https://www.youtube.com/watch?v=RPZIaTbqoZw" "Video: https://www.youtube.com/watch?v=RPZIaTbqoZw"
) )
@CommandPermissions("worldedit.brush.copy") @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 { 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(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
player.print(BBC.BRUSH_COPY.format(radius)); player.print(BBC.BRUSH_COPY.format(radiusOpt));
return set(session, context, return set(session, context,
new CopyPastaBrush(player, session, randomRotate, autoRotate)) new CopyPastaBrush(player, session, randomRotate, autoRotate))
.setSize(radius); .setSize(radiusOpt);
} }
@Command( @Command(
@ -809,7 +810,7 @@ public class BrushCommands {
" - Placeholders: {x}, {y}, {z}, {world}, {size}" " - Placeholders: {x}, {y}, {z}, {world}, {size}"
) )
@CommandPermissions("worldedit.brush.command") @CommandPermissions("worldedit.brush.command")
public BrushSettings command(Player player, LocalSession session, Expression radius, @Arg(desc = "Command to run") List<String> 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<String> input, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
String cmd = StringMan.join(input, " "); String cmd = StringMan.join(input, " ");
return set(session, context, return set(session, context,
@ -825,7 +826,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.butcher") @CommandPermissions("worldedit.brush.butcher")
public BrushSettings butcherBrush(Player player, LocalSession session, InjectedValueAccess context, public BrushSettings butcherBrush(Player player, LocalSession session, InjectedValueAccess context,
@Arg(desc = "Radius to kill mobs in", def = "5") @Arg(desc = "Radius to kill mobs in", def = "5")
Expression radius, Expression radiusOpt,
@Switch(name = 'p', desc = "Also kill pets") @Switch(name = 'p', desc = "Also kill pets")
boolean killPets, boolean killPets,
@Switch(name = 'n', desc = "Also kill NPCs") @Switch(name = 'n', desc = "Also kill NPCs")
@ -842,7 +843,7 @@ public class BrushCommands {
boolean killFriendly, boolean killFriendly,
@Switch(name = 'r', desc = "Also destroy armor stands") @Switch(name = 'r', desc = "Also destroy armor stands")
boolean killArmorStands) throws WorldEditException { boolean killArmorStands) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radiusOpt);
CreatureButcher flags = new CreatureButcher(player); CreatureButcher flags = new CreatureButcher(player);
flags.or(CreatureButcher.Flags.FRIENDLY , killFriendly); // No permission check here. Flags will instead be filtered by the subsequent calls. 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, return set(session, context,
new ButcherBrush(flags)) new ButcherBrush(flags))
.setSize(radius); .setSize(radiusOpt);
} }
public BrushSettings process(CommandLocals locals, BrushSettings settings) throws WorldEditException { public BrushSettings process(CommandLocals locals, BrushSettings settings) throws WorldEditException {
@ -898,12 +899,12 @@ public class BrushCommands {
@Arg(desc = "The shape of the region") @Arg(desc = "The shape of the region")
RegionFactory shape, RegionFactory shape,
@Arg(desc = "The size of the brush", def = "5") @Arg(desc = "The size of the brush", def = "5")
double radius, Expression radiusOpt,
@Arg(desc = "The density of the brush", def = "20") @Arg(desc = "The density of the brush", def = "20")
double density, double density,
@Arg(desc = "The type of tree to use") @Arg(desc = "The type of tree to use")
TreeGenerator.TreeType type) throws WorldEditException { TreeGenerator.TreeType type) throws WorldEditException, EvaluationException {
setOperationBasedBrush(player, localSession, radius, setOperationBasedBrush(player, localSession, radiusOpt,
new Paint(new TreeGeneratorFactory(type), density / 100), shape, "worldedit.brush.forest"); 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") @Arg(desc = "The shape of the region")
RegionFactory shape, RegionFactory shape,
@Arg(desc = "The size of the brush", def = "5") @Arg(desc = "The size of the brush", def = "5")
double radius) throws WorldEditException { Expression radiusOpt) throws WorldEditException, EvaluationException {
setOperationBasedBrush(player, localSession, radius, setOperationBasedBrush(player, localSession, radiusOpt,
new Deform("y-=1"), shape, "worldedit.brush.raise"); new Deform("y-=1"), shape, "worldedit.brush.raise");
} }
@ -930,12 +931,12 @@ public class BrushCommands {
@Arg(desc = "The shape of the region") @Arg(desc = "The shape of the region")
RegionFactory shape, RegionFactory shape,
@Arg(desc = "The size of the brush", def = "5") @Arg(desc = "The size of the brush", def = "5")
double radius) throws WorldEditException { Expression radiusOpt) throws WorldEditException, EvaluationException {
setOperationBasedBrush(player, localSession, radius, setOperationBasedBrush(player, localSession, radiusOpt,
new Deform("y+=1"), shape, "worldedit.brush.lower"); 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<? extends Operation> factory, Contextual<? extends Operation> factory,
RegionFactory shape, RegionFactory shape,
String permission) throws WorldEditException { String permission) throws WorldEditException {

View File

@ -188,11 +188,11 @@ public class BrushOptionsCommands {
) )
@CommandPermissions("worldedit.brush.primary") @CommandPermissions("worldedit.brush.primary")
public void primary(Player player, LocalSession session, public void primary(Player player, LocalSession session,
@Arg(desc = "The brush command", variable = true) List<String> command) throws WorldEditException { @Arg(desc = "The brush command", variable = true) List<String> commandStr) throws WorldEditException {
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND); BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
session.setTool(item, null, player); session.setTool(item, null, player);
String cmd = "brush " + StringMan.join(command, " "); String cmd = "brush " + StringMan.join(commandStr, " ");
CommandEvent event = new CommandEvent(player, cmd); CommandEvent event = new CommandEvent(player, cmd);
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event); PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
BrushTool newTool = session.getBrushTool(item, player, false); BrushTool newTool = session.getBrushTool(item, player, false);
@ -208,12 +208,12 @@ public class BrushOptionsCommands {
) )
@CommandPermissions("worldedit.brush.secondary") @CommandPermissions("worldedit.brush.secondary")
public void secondary(Player player, LocalSession session, public void secondary(Player player, LocalSession session,
@Arg(desc = "The brush command", variable = true) List<String> command) @Arg(desc = "The brush command", variable = true) List<String> commandStr)
throws WorldEditException { throws WorldEditException {
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND); BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
session.setTool(item, null, player); session.setTool(item, null, player);
String cmd = "brush " + StringMan.join(command, " "); String cmd = "brush " + StringMan.join(commandStr, " ");
CommandEvent event = new CommandEvent(player, cmd); CommandEvent event = new CommandEvent(player, cmd);
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event); PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
BrushTool newTool = session.getBrushTool(item, player, false); BrushTool newTool = session.getBrushTool(item, player, false);
@ -232,7 +232,7 @@ public class BrushOptionsCommands {
"2 = Glass showing what blocks will be changed" "2 = Glass showing what blocks will be changed"
) )
@CommandPermissions("worldedit.brush.visualize") @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 { throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
@ -270,14 +270,14 @@ public class BrushOptionsCommands {
desc = "Set the targeting mask" desc = "Set the targeting mask"
) )
@CommandPermissions("worldedit.brush.targetmask") @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); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
BBC.BRUSH_NONE.send(player); BBC.BRUSH_NONE.send(player);
return; return;
} }
tool.setTraceMask(maskArg); tool.setTraceMask(maskOpt);
BBC.BRUSH_TARGET_MASK_SET.send(player, maskArg.toString()); BBC.BRUSH_TARGET_MASK_SET.send(player, maskOpt.toString());
} }
@Command( @Command(
@ -308,7 +308,7 @@ public class BrushOptionsCommands {
@Arg(desc = "Target Modes") @Arg(desc = "Target Modes")
String modes, String modes,
@Arg(desc = "The scroll action", variable = true) @Arg(desc = "The scroll action", variable = true)
List<String> command) throws WorldEditException { List<String> commandStr) throws WorldEditException {
// TODO NOT IMPLEMENTED Convert ScrollAction to an argument converter // TODO NOT IMPLEMENTED Convert ScrollAction to an argument converter
BrushTool bt = session.getBrushTool(player, false); BrushTool bt = session.getBrushTool(player, false);
if (bt == null) { if (bt == null) {
@ -316,7 +316,7 @@ public class BrushOptionsCommands {
return; return;
} }
BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext(); 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); settings.setScrollAction(action);
if (modes.equalsIgnoreCase("none")) { if (modes.equalsIgnoreCase("none")) {
BBC.BRUSH_SCROLL_ACTION_UNSET.send(player); BBC.BRUSH_SCROLL_ACTION_UNSET.send(player);
@ -425,7 +425,7 @@ public class BrushOptionsCommands {
) )
@CommandPermissions("worldedit.brush.options.material") @CommandPermissions("worldedit.brush.options.material")
public void material(Player player, EditSession editSession, LocalSession session, 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") @Switch(name = 'h', desc = "TODO")
boolean offHand, boolean offHand,
Arguments arguments) throws WorldEditException { Arguments arguments) throws WorldEditException {
@ -434,13 +434,13 @@ public class BrushOptionsCommands {
player.print(BBC.BRUSH_NONE.s()); player.print(BBC.BRUSH_NONE.s());
return; return;
} }
if (pattern == null) { if (patternOpt == null) {
BBC.BRUSH_MATERIAL.send(player); BBC.BRUSH_MATERIAL.send(player);
tool.setFill(null); tool.setFill(null);
return; return;
} }
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext(); BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
settings.setFill(pattern); settings.setFill(patternOpt);
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring(); String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.FILL, lastArg); settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
tool.update(); tool.update();

View File

@ -122,7 +122,7 @@ public class ClipboardCommands {
@Switch(name = 'b', desc = "Also copy biomes") @Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes, boolean copyBiomes,
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "") @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 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
@ -150,8 +150,8 @@ public class ClipboardCommands {
copy.setSourceMask(sourceMask); copy.setSourceMask(sourceMask);
editSession.setSourceMask(null); editSession.setSourceMask(null);
} }
if (mask != null && mask != Masks.alwaysTrue()) { if (maskOpt != null && maskOpt != Masks.alwaysTrue()) {
copy.setSourceMask(mask); copy.setSourceMask(maskOpt);
} }
Operations.completeLegacy(copy); Operations.completeLegacy(copy);
BBC.COMMAND_COPY.send(player, region.getArea()); BBC.COMMAND_COPY.send(player, region.getArea());
@ -171,7 +171,7 @@ public class ClipboardCommands {
@Switch(name = 'e', desc = "Skip copy entities") @Switch(name = 'e', desc = "Skip copy entities")
boolean skipEntities, boolean skipEntities,
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "") @ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
Mask mask, Mask maskOpt,
@Switch(name = 'b', desc = "Also copy biomes") @Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes) throws WorldEditException { boolean copyBiomes) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
@ -203,7 +203,7 @@ public class ClipboardCommands {
@Switch(name = 'e', desc = "Skip copy entities") @Switch(name = 'e', desc = "Skip copy entities")
boolean skipEntities, boolean skipEntities,
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "") @ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
Mask mask, Mask maskOpt,
@Switch(name = 'b', desc = "Also copy biomes") @Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes) throws WorldEditException { boolean copyBiomes) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
@ -242,7 +242,7 @@ public class ClipboardCommands {
@Switch(name = 'b', desc = "Also copy biomes, source biomes are unaffected") @Switch(name = 'b', desc = "Also copy biomes, source biomes are unaffected")
boolean copyBiomes, boolean copyBiomes,
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "") @ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
Mask mask, Mask maskOpt,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
@ -272,8 +272,8 @@ public class ClipboardCommands {
copy.setSourceMask(sourceMask); copy.setSourceMask(sourceMask);
editSession.setSourceMask(null); editSession.setSourceMask(null);
} }
if (mask != null) { if (maskOpt != null) {
copy.setSourceMask(mask); copy.setSourceMask(maskOpt);
} }
Operations.completeLegacy(copy); Operations.completeLegacy(copy);
session.setClipboard(new ClipboardHolder(clipboard)); session.setClipboard(new ClipboardHolder(clipboard));

View File

@ -199,12 +199,11 @@ public class GeneralCommands {
desc = "Set the global mask" desc = "Set the global mask"
) )
@CommandPermissions({"worldedit.global-mask", "worldedit.mask.global"}) @CommandPermissions({"worldedit.global-mask", "worldedit.mask.global"})
public void gmask(Player player, LocalSession session, @Arg(desc = "The mask to set", def = "") Mask mask) { public void gmask(Player player, LocalSession session, @Arg(desc = "The mask to set", def = "") Mask maskOpt) {
if (mask == null) { session.setMask(maskOpt);
session.setMask(null); if (maskOpt == null) {
BBC.MASK_DISABLED.send(player); BBC.MASK_DISABLED.send(player);
} else { } else {
session.setMask(mask);
BBC.MASK.send(player); 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)" 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"}) @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 { public void gsmask(Player player, LocalSession session, EditSession editSession, @Arg(desc = "The mask to set", def = "") Mask maskOpt) throws WorldEditException {
if (mask == null) { session.setSourceMask(maskOpt);
session.setSourceMask((Mask) null); if (maskOpt == null) {
BBC.SOURCE_MASK_DISABLED.send(player); BBC.SOURCE_MASK_DISABLED.send(player);
} else { } else {
session.setSourceMask(mask);
BBC.SOURCE_MASK.send(player); BBC.SOURCE_MASK.send(player);
} }
} }

View File

@ -94,17 +94,17 @@ public class GenerationCommands {
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void caves(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, public void caves(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region,
@Arg(name = "size", desc = "TODO", def = "8") int sizeOpt, @Arg(name = "size", desc = "TODO", def = "8") int sizeOpt,
@Arg(desc = "TODO", def = "40") int frequency, @Arg(name = "frequency", desc = "TODO", def = "40") int frequencyOpt,
@Arg(desc = "TODO", def = "7") int rarity, @Arg(name = "rarity", desc = "TODO", def = "7") int rarityOpt,
@Arg(desc = "TODO", def = "8") int minY, @Arg(name = "minY", desc = "TODO", def = "8") int minYOpt,
@Arg(desc = "TODO", def = "127") int maxY, @Arg(name = "maxY", desc = "TODO", def = "127") int maxYOpt,
@Arg(desc = "TODO", def = "1") int systemFrequency, @Arg(name = "systemFrequency", desc = "TODO", def = "1") int systemFrequencyOpt,
@Arg(desc = "TODO", def = "25") int individualRarity, @Arg(name = "individualRarity", desc = "TODO", def = "25") int individualRarityOpt,
@Arg(desc = "TODO", def = "0") int pocketChance, @Arg(name = "pocketChance", desc = "TODO", def = "0") int pocketChanceOpt,
@Arg(desc = "TODO", def = "0") int pocketMin, @Arg(name = "pocketMin", desc = "TODO", def = "0") int pocketMinOpt,
@Arg(desc = "TODO", def = "3") int pocketMax, InjectedValueAccess context) throws WorldEditException { @Arg(name = "pocketMax", desc = "TODO", def = "3") int pocketMaxOpt, InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> { 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); editSession.generate(region, gen);
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount()); BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
}, "/caves", region, context); }, "/caves", region, context);
@ -130,10 +130,10 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.image") @CommandPermissions("worldedit.generation.image")
@Logging(PLACEMENT) @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 { @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); 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")) { 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!"); 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") @CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT) @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(() -> { fp.checkConfirmationRegion(() -> {
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY); editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount()); BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());

View File

@ -60,7 +60,7 @@ import org.enginehub.piston.annotation.param.Switch;
// "e.g. >[stone,dirt],#light[0][5],$jungle\n" + // "e.g. >[stone,dirt],#light[0][5],$jungle\n" +
// "More Info: https://git.io/v9r4K" // "More Info: https://git.io/v9r4K"
//) //)
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) @CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class MaskCommands { public class MaskCommands {
private final WorldEdit worldEdit; 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) { 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); scale = 1d / Math.max(1, scale);
min = (min - 50) / 50; minInt = (minInt - 50) / 50;
max = (max - 50) / 50; maxInt = (maxInt - 50) / 50;
return new SimplexMask(scale, min, max); return new SimplexMask(scale, minInt, maxInt);
} }
@Command( @Command(
@ -84,7 +84,7 @@ public class MaskCommands {
desc = "Restrict to specific light levels" 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) { 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( @Command(
@ -286,7 +286,7 @@ public class MaskCommands {
"Example: /[3][20]\n" + "Example: /[3][20]\n" +
"Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below" "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; double y1, y2;
boolean override; boolean override;
if (maxStr.endsWith("d")) { if (maxStr.endsWith("d")) {
@ -298,7 +298,7 @@ public class MaskCommands {
y1 = Expression.compile(minStr).evaluate(); y1 = Expression.compile(minStr).evaluate();
y2 = Expression.compile(maxStr).evaluate(); y2 = Expression.compile(maxStr).evaluate();
} }
return new AngleMask(extent, y1, y2, overlay, distance); return new AngleMask(extent, y1, y2, overlay, distanceOpt);
} }
@Command( @Command(
@ -311,7 +311,7 @@ public class MaskCommands {
"Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" + "Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" +
"Note: Use negatives for decreasing slope" "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; double y1, y2;
boolean override; boolean override;
if (maxStr.endsWith("d")) { if (maxStr.endsWith("d")) {
@ -323,7 +323,7 @@ public class MaskCommands {
y1 = Expression.compile(minStr).evaluate(); y1 = Expression.compile(minStr).evaluate();
y2 = Expression.compile(maxStr).evaluate(); y2 = Expression.compile(maxStr).evaluate();
} }
return new ROCAngleMask(extent, y1, y2, overlay, distance); return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt);
} }
@Command( @Command(
@ -336,19 +336,19 @@ public class MaskCommands {
"Explanation: Restrict to near 45 degrees of local maxima\n" + "Explanation: Restrict to near 45 degrees of local maxima\n" +
"Note: Use negatives for local minima" "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; double y1, y2;
boolean override; boolean override;
if (max.endsWith("d")) { if (maxStr.endsWith("d")) {
double y1d = Expression.compile(min.substring(0, min.length() - 1)).evaluate(); double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
double y2d = Expression.compile(max.substring(0, max.length() - 1)).evaluate(); double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
y1 = Math.tan(y1d * (Math.PI / 180)); y1 = Math.tan(y1d * (Math.PI / 180));
y2 = Math.tan(y2d * (Math.PI / 180)); y2 = Math.tan(y2d * (Math.PI / 180));
} else { } else {
y1 = Expression.compile(min).evaluate(); y1 = Expression.compile(minStr).evaluate();
y2 = Expression.compile(max).evaluate(); y2 = Expression.compile(maxStr).evaluate();
} }
return new ExtremaMask(extent, y1, y2, overlay, distance); return new ExtremaMask(extent, y1, y2, overlay, distanceOpt);
} }
@Command( @Command(

View File

@ -45,7 +45,7 @@ import java.util.Set;
// "e.g. #surfacespread[10][#existing],andesite\n" + // "e.g. #surfacespread[10][#existing],andesite\n" +
// "More Info: https://git.io/vSPmA" // "More Info: https://git.io/vSPmA"
//) //)
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) @CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class PatternCommands { public class PatternCommands {
@Command( @Command(
@ -94,24 +94,24 @@ public class PatternCommands {
name = "#anglecolor", name = "#anglecolor",
desc = "A darker block based on the existing terrain angle" 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) { 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, distance); return new AngleColorPattern(extent, session, distanceOpt);
} }
@Command( @Command(
name = "#angledata", name = "#angledata",
desc = "Block data based on the existing terrain angle" desc = "Block data based on the existing terrain angle"
) )
public Pattern angledata(Extent extent, @Arg(name = "distance", desc = "int", def = "1") int distance) { public Pattern angledata(Extent extent, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) {
return new DataAnglePattern(extent, distance); return new DataAnglePattern(extent, distanceOpt);
} }
@Command( @Command(
name = "#saturate", name = "#saturate",
desc = "Saturate the existing block with a color" desc = "Saturate the existing block with a color"
) )
public Pattern saturate(Extent extent, LocalSession session, String arg) { public Pattern saturate(Extent extent, LocalSession session, String colorStr) {
Color color = ColorUtil.parseColor(arg); Color color = ColorUtil.parseColor(colorStr);
return new SaturatePattern(extent, color.getRGB(), session); return new SaturatePattern(extent, color.getRGB(), session);
} }
@ -119,8 +119,8 @@ public class PatternCommands {
name = "#averagecolor", name = "#averagecolor",
desc = "Average between the existing block and a color" desc = "Average between the existing block and a color"
) )
public Pattern averagecolor(Extent extent, LocalSession session, String arg) { public Pattern averagecolor(Extent extent, LocalSession session, String colorStr) {
Color color = ColorUtil.parseColor(arg); Color color = ColorUtil.parseColor(colorStr);
return new AverageColorPattern(extent, color.getRGB(), session); return new AverageColorPattern(extent, color.getRGB(), session);
} }

View File

@ -217,7 +217,7 @@ public class RegionCommands {
public int line(Actor actor, EditSession editSession, public int line(Actor actor, EditSession editSession,
@Selection Region region, @Selection Region region,
@Arg(desc = "The pattern of blocks to place") @Arg(desc = "The pattern of blocks to place")
Pattern patternArg, Pattern patternArgOpt,
@Range(min = 1) @Arg(desc = "The thickness of the line", def = "0") @Range(min = 1) @Arg(desc = "The thickness of the line", def = "0")
int thickness, int thickness,
@Switch(name = 'h', desc = "Generate only a shell") @Switch(name = 'h', desc = "Generate only a shell")
@ -231,7 +231,7 @@ public class RegionCommands {
CuboidRegion cuboidregion = (CuboidRegion) region; CuboidRegion cuboidregion = (CuboidRegion) region;
BlockVector3 pos1 = cuboidregion.getPos1(); BlockVector3 pos1 = cuboidregion.getPos1();
BlockVector3 pos2 = cuboidregion.getPos2(); 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); BBC.VISITOR_BLOCK.send(actor, blocksChanged);
return blocksChanged; return blocksChanged;
@ -317,7 +317,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.overlay") @CommandPermissions("worldedit.region.overlay")
@Logging(REGION) @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(() -> { fp.checkConfirmationRegion(() -> {
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
int maxY = max.getBlockY(); int maxY = max.getBlockY();
@ -406,7 +406,7 @@ public class RegionCommands {
@Arg(desc = "# of iterations to perform", def = "1") @Arg(desc = "# of iterations to perform", def = "1")
int iterations, int iterations,
@Arg(desc = "The mask of blocks to use as the height map", def = "") @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 { @Switch(name = 's', desc = "TODO") boolean snow, InjectedValueAccess context) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
@ -417,7 +417,7 @@ public class RegionCommands {
} }
fp.checkConfirmationRegion(() -> { fp.checkConfirmationRegion(() -> {
try { 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)); HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
int affected = heightMap.applyFilter(filter, iterations); int affected = heightMap.applyFilter(filter, iterations);
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(fp, affected);
@ -671,14 +671,14 @@ public class RegionCommands {
@Selection Region region, @Selection Region region,
@Range(min = 0) @Arg(desc = "Thickness of the shell to leave", def = "0") @Range(min = 0) @Arg(desc = "Thickness of the shell to leave", def = "0")
int thickness, int thickness,
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air") @Arg(name = "pattern", desc = "The pattern of blocks to replace the hollowed area with", def = "air")
Pattern patternArg, Pattern patternArgOpt,
@ArgFlag(name = 'm', desc = "Mask to hollow with") Mask mask, @ArgFlag(name = 'm', desc = "Mask to hollow with") Mask mask,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {
checkCommandArgument(thickness >= 0, "Thickness must be >= 0"); checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask; Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
fp.checkConfirmationRegion(() -> { fp.checkConfirmationRegion(() -> {
int affected = editSession.hollowOutRegion(region, thickness, patternArg, finalMask); int affected = editSession.hollowOutRegion(region, thickness, patternArgOpt, finalMask);
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(fp, affected);
}, getArguments(context), region, context); }, getArguments(context), region, context);
} }

View File

@ -555,7 +555,7 @@ public class SelectionCommands {
public void select(Actor actor, World world, LocalSession session, EditSession editSession, public void select(Actor actor, World world, LocalSession session, EditSession editSession,
@Arg(desc = "Selector to switch to", def = "") @Arg(desc = "Selector to switch to", def = "")
SelectorChoice selector, SelectorChoice selector,
@Arg(desc = "Selector mask", def = "") Mask mask, @Arg(desc = "Selector mask", def = "") Mask maskOpt,
@Switch(name = 'd', desc = "Set default selector") @Switch(name = 'd', desc = "Set default selector")
boolean setDefaultSelector) throws WorldEditException { boolean setDefaultSelector) throws WorldEditException {
if (selector == null) { if (selector == null) {
@ -614,11 +614,11 @@ public class SelectionCommands {
break; break;
case FUZZY: case FUZZY:
case MAGIC: case MAGIC:
if (mask == null) { if (maskOpt == null) {
mask = new IdMask(world); maskOpt = new IdMask(world);
} }
//TODO Make FuzzyRegionSelector accept actors //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_FUZZY.s());
actor.print(BBC.SEL_LIST.s()); actor.print(BBC.SEL_LIST.s());
break; break;

View File

@ -40,6 +40,7 @@ import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.function.pattern.Pattern; 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.HandSide;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
@ -107,10 +108,7 @@ public class ToolCommands {
desc = "Inspect edits within a radius" desc = "Inspect edits within a radius"
) )
@CommandPermissions("worldedit.tool.inspect") @CommandPermissions("worldedit.tool.inspect")
public void inspectBrush(Player player, LocalSession session, public void inspectBrush(Player player, LocalSession session) throws WorldEditException {
@Arg(desc = "The radius of the brush", def = "1")
double radius) throws WorldEditException {
radius = Math.max(1,radius);
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(player, new InspectBrush()); session.setTool(player, new InspectBrush());
BBC.TOOL_INSPECT.send(player, itemStack.getType().getName()); BBC.TOOL_INSPECT.send(player, itemStack.getType().getName());

View File

@ -74,9 +74,9 @@ public class ToolUtilCommands {
@CommandPermissions("worldedit.brush.options.mask") @CommandPermissions("worldedit.brush.options.mask")
public void mask(Player player, LocalSession session, public void mask(Player player, LocalSession session,
@Arg(desc = "The mask to set", def = "") @Arg(desc = "The mask to set", def = "")
Mask mask) throws WorldEditException { Mask maskOpt) throws WorldEditException {
session.getBrushTool(player).setMask(mask); session.getBrushTool(player).setMask(maskOpt);
if (mask == null) { if (maskOpt == null) {
player.print("Brush mask disabled."); player.print("Brush mask disabled.");
} else { } else {
player.print("Brush mask set."); player.print("Brush mask set.");
@ -129,9 +129,9 @@ public class ToolUtilCommands {
@CommandPermissions("worldedit.brush.options.tracemask") @CommandPermissions("worldedit.brush.options.tracemask")
public void traceMask(Player player, LocalSession session, public void traceMask(Player player, LocalSession session,
@Arg(desc = "The trace mask to set", def = "") @Arg(desc = "The trace mask to set", def = "")
Mask mask) throws WorldEditException { Mask maskOpt) throws WorldEditException {
session.getBrushTool(player).setTraceMask(mask); session.getBrushTool(player).setTraceMask(maskOpt);
if (mask == null) { if (maskOpt == null) {
player.print("Trace mask disabled."); player.print("Trace mask disabled.");
} else { } else {
player.print("Trace mask set."); player.print("Trace mask set.");

View File

@ -22,7 +22,7 @@ import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) @CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class TransformCommands { public class TransformCommands {
@Command( @Command(

View File

@ -64,6 +64,7 @@ import com.sk89q.worldedit.function.visitor.EntityVisitor;
import com.sk89q.worldedit.internal.annotation.Range; import com.sk89q.worldedit.internal.annotation.Range;
import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException; 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.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.CylinderRegion; import com.sk89q.worldedit.regions.CylinderRegion;
@ -102,7 +103,7 @@ import org.jetbrains.annotations.NotNull;
/** /**
* Utility commands. * Utility commands.
*/ */
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class, CommandQueuedConditionGenerator.Registration.class}) @CommandContainer(superTypes = {CommandQueuedConditionGenerator.Registration.class, CommandPermissionsConditionGenerator.Registration.class})
public class UtilityCommands { public class UtilityCommands {
private final WorldEdit we; private final WorldEdit we;
@ -191,10 +192,11 @@ public class UtilityCommands {
@Arg(desc = "The blocks to fill with") @Arg(desc = "The blocks to fill with")
Pattern pattern, Pattern pattern,
@Range(min=1) @Arg(desc = "The radius to fill in") @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") @Range(min=1) @Arg(desc = "The depth to fill", def = "1")
int depth, 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); radius = Math.max(1, radius);
we.checkMaxRadius(radius); we.checkMaxRadius(radius);
depth = Math.max(1, depth); depth = Math.max(1, depth);
@ -286,9 +288,10 @@ public class UtilityCommands {
@Arg(desc = "The blocks to fill with") @Arg(desc = "The blocks to fill with")
Pattern pattern, Pattern pattern,
@Range(min=1) @Arg(desc = "The radius to fill in") @Range(min=1) @Arg(desc = "The radius to fill in")
double radius, Expression radiusExp,
@Arg(desc = "The depth to fill", def = "") @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); radius = Math.max(1, radius);
we.checkMaxRadius(radius); we.checkMaxRadius(radius);
depth = depth == null ? Integer.MAX_VALUE : Math.max(1, depth); depth = depth == null ? Integer.MAX_VALUE : Math.max(1, depth);
@ -308,9 +311,10 @@ public class UtilityCommands {
@Logging(PLACEMENT) @Logging(PLACEMENT)
public int drain(Player player, LocalSession session, EditSession editSession, public int drain(Player player, LocalSession session, EditSession editSession,
@Range(min=0) @Arg(desc = "The radius to drain") @Range(min=0) @Arg(desc = "The radius to drain")
double radius, Expression radiusExp,
@Switch(name = 'w', desc = "Also un-waterlog blocks") @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); radius = Math.max(0, radius);
we.checkMaxRadius(radius); we.checkMaxRadius(radius);
int affected = editSession.drainArea( int affected = editSession.drainArea(
@ -328,7 +332,8 @@ public class UtilityCommands {
@Logging(PLACEMENT) @Logging(PLACEMENT)
public int fixLava(Player player, LocalSession session, EditSession editSession, public int fixLava(Player player, LocalSession session, EditSession editSession,
@Range(min=0) @Arg(desc = "The radius to fix in") @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); radius = Math.max(0, radius);
we.checkMaxRadius(radius); we.checkMaxRadius(radius);
int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, BlockTypes.LAVA); int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, BlockTypes.LAVA);
@ -345,7 +350,8 @@ public class UtilityCommands {
@Logging(PLACEMENT) @Logging(PLACEMENT)
public int fixWater(Player player, LocalSession session, EditSession editSession, public int fixWater(Player player, LocalSession session, EditSession editSession,
@Range(min=0) @Arg(desc = "The radius to fix in") @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); radius = Math.max(0, radius);
we.checkMaxRadius(radius); we.checkMaxRadius(radius);
int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, BlockTypes.WATER); int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, BlockTypes.WATER);
@ -456,11 +462,11 @@ public class UtilityCommands {
@Logging(PLACEMENT) @Logging(PLACEMENT)
public int snow(Player player, LocalSession session, EditSession editSession, public int snow(Player player, LocalSession session, EditSession editSession,
@Range(min=1) @Arg(desc = "The radius of the circle to snow in", def = "10") @Range(min=1) @Arg(desc = "The radius of the circle to snow in", def = "10")
double size) throws WorldEditException { double sizeOpt) throws WorldEditException {
size = Math.max(1, size); sizeOpt = Math.max(1, sizeOpt);
we.checkMaxRadius(size); 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~"); player.print(affected + " surface(s) covered. Let it snow~");
return affected; return affected;
} }
@ -474,11 +480,11 @@ public class UtilityCommands {
@Logging(PLACEMENT) @Logging(PLACEMENT)
public int thaw(Player player, LocalSession session, EditSession editSession, public int thaw(Player player, LocalSession session, EditSession editSession,
@Range(min=1) @Arg(desc = "The radius of the circle to thaw in", def = "10") @Range(min=1) @Arg(desc = "The radius of the circle to thaw in", def = "10")
double size) throws WorldEditException { double sizeOpt) throws WorldEditException {
size = Math.max(1, size); sizeOpt = Math.max(1, sizeOpt);
we.checkMaxRadius(size); 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."); player.print(affected + " surface(s) thawed.");
return affected; return affected;
} }
@ -492,14 +498,14 @@ public class UtilityCommands {
@Logging(PLACEMENT) @Logging(PLACEMENT)
public int green(Player player, LocalSession session, EditSession editSession, public int green(Player player, LocalSession session, EditSession editSession,
@Range(min=1) @Arg(desc = "The radius of the circle to convert in", def = "10") @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") @Switch(name = 'f', desc = "Also convert coarse dirt")
boolean convertCoarse) throws WorldEditException { boolean convertCoarse) throws WorldEditException {
size = Math.max(1, size); sizeOpt = Math.max(1, sizeOpt);
we.checkMaxRadius(size); we.checkMaxRadius(sizeOpt);
final boolean onlyNormalDirt = !convertCoarse; 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); BBC.VISITOR_BLOCK.send(player, affected);
return affected; return affected;
} }
@ -703,8 +709,8 @@ public class UtilityCommands {
@ArgFlag(name = 'p', desc = "The page to retrieve", def = "1") @ArgFlag(name = 'p', desc = "The page to retrieve", def = "1")
int page, int page,
@Arg(desc = "The command to retrieve help for", def = "", variable = true) @Arg(desc = "The command to retrieve help for", def = "", variable = true)
List<String> command) throws WorldEditException { List<String> commandStr) throws WorldEditException {
PrintCommandHelp.help(command, page, listSubCommands, we, actor); PrintCommandHelp.help(commandStr, page, listSubCommands, we, actor);
} }
public static void list(File dir, Actor actor, List<String> args, @Range(min = 0) int page, String formatName, boolean playerFolder, String onClickCmd) { public static void list(File dir, Actor actor, List<String> args, @Range(min = 0) int page, String formatName, boolean playerFolder, String onClickCmd) {

View File

@ -196,7 +196,7 @@ public class WorldEditCommands {
@ArgFlag(name = 'p', desc = "The page to retrieve", def = "1") @ArgFlag(name = 'p', desc = "The page to retrieve", def = "1")
int page, int page,
@Arg(desc = "The command to retrieve help for", def = "", variable = true) @Arg(desc = "The command to retrieve help for", def = "", variable = true)
List<String> command) throws WorldEditException { List<String> commandStr) throws WorldEditException {
PrintCommandHelp.help(command, page, listSubCommands, we, actor); PrintCommandHelp.help(commandStr, page, listSubCommands, we, actor);
} }
} }

View File

@ -422,7 +422,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
*/ */
public void setRange(int range) { public void setRange(int range) {
if (range == DEFAULT_RANGE) { if (range == DEFAULT_RANGE) {
range = -1; this.range = -1;
} else { } else {
this.range = range; this.range = range;
} }

View File

@ -18,7 +18,9 @@ public final class CommandQueuedConditionGenerator implements CommandConditionGe
@Override @Override
public Command.Condition generateCondition(Method commandMethod) { public Command.Condition generateCondition(Method commandMethod) {
CommandQueued annotation = commandMethod.getAnnotation(CommandQueued.class); 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()); return new CommandQueuedCondition(annotation.value());
} }
} }