Disabled FAWE commands until the plugin can actually set a block again

This commit is contained in:
MattBDev 2019-10-07 15:09:52 -04:00
parent 7ac29d6173
commit 11d30d2f94
15 changed files with 1044 additions and 1034 deletions

View File

@ -13,7 +13,6 @@ fun Project.applyCommonConfiguration() {
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") } maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
maven { url = uri("http://empcraft.com/maven2") } maven { url = uri("http://empcraft.com/maven2") }
maven { url = uri("https://repo.destroystokyo.com/repository/maven-public") } maven { url = uri("https://repo.destroystokyo.com/repository/maven-public") }
maven { url = uri("https://ci.athion.net/job/FAWE-Piston/ws/") }
ivy { url = uri("https://ci.athion.net/job") ivy { url = uri("https://ci.athion.net/job")
patternLayout { patternLayout {
artifact("/[organisation]/[revision]/artifact/[module].[ext]") artifact("/[organisation]/[revision]/artifact/[module].[ext]")
@ -24,5 +23,4 @@ fun Project.applyCommonConfiguration() {
cacheChangingModulesFor(10, "minutes") cacheChangingModulesFor(10, "minutes")
} }
} }
} }

View File

@ -20,7 +20,7 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.bukkit.BukkitTextAdapter.reduceToText; import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
import com.sk89q.bukkit.util.CommandInspector; import com.sk89q.bukkit.util.CommandInspector;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;

View File

@ -19,7 +19,7 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import static com.sk89q.worldedit.bukkit.BukkitTextAdapter.reduceToText; import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
import com.sk89q.bukkit.util.CommandInfo; import com.sk89q.bukkit.util.CommandInfo;
import com.sk89q.bukkit.util.CommandRegistration; import com.sk89q.bukkit.util.CommandRegistration;

View File

@ -43,8 +43,8 @@ public class CFICommand extends CommandProcessor<Object, Object> {
} }
@Override @Override
public Object process(InjectedValueAccess context, List<String> args, Object result) { public int process(InjectedValueAccess context, List<String> args, Object result) {
return result; return 0;
} }
private List<String> dispatch(Player player, CFISettings settings, List<String> args, InjectedValueAccess context) { private List<String> dispatch(Player player, CFISettings settings, List<String> args, InjectedValueAccess context) {

View File

@ -67,13 +67,13 @@ public abstract class CommandProcessor<I, O> implements CommandManager {
} }
@Override @Override
public final Object execute(InjectedValueAccess context, List<String> args) { public final int execute(InjectedValueAccess context, List<String> args) {
args = preprocess(context, args); args = preprocess(context, args);
if (args != null) { if (args != null) {
Object result = parent.execute(context, args); Object result = parent.execute(context, args);
return process(context, args, result); // TODO NOT IMPLEMENTED (recompile piston) return process(context, args, result); // TODO NOT IMPLEMENTED (recompile piston)
} else { } else {
return null; return 0;
} }
} }
@ -89,5 +89,5 @@ public abstract class CommandProcessor<I, O> implements CommandManager {
public abstract List<String> preprocess(InjectedValueAccess context, List<String> args); public abstract List<String> preprocess(InjectedValueAccess context, List<String> args);
public abstract Object process(InjectedValueAccess context, List<String> args, Object result); public abstract int process(InjectedValueAccess context, List<String> args, Object result);
} }

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.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.function.generator.CavesGen; import com.sk89q.worldedit.function.generator.CavesGen;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
@ -270,17 +271,18 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.forest") @CommandPermissions("worldedit.generation.forest")
@Logging(POSITION) @Logging(POSITION)
public int forestGen(Player player, LocalSession session, EditSession editSession, public int forestGen(Actor actor, LocalSession session, EditSession editSession,
@Arg(name = "size", desc = "The size of the forest, in blocks", def = "10") @Arg(desc = "The size of the forest, in blocks", def = "10")
int sizeOpt, int size,
@Arg(desc = "The type of forest", def = "tree") @Arg(desc = "The type of forest", def = "tree")
TreeType type, TreeType type,
@Range(min = 0, max = 100) @Arg(desc = "The density of the forest, between 0 and 100", def = "5") @Arg(desc = "The density of the forest, between 0 and 100", def = "5")
double density) throws WorldEditException { double density) throws WorldEditException {
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100"); checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
worldEdit.checkMaxRadius(size);
density /= 100; density /= 100;
int affected = editSession.makeForest(session.getPlacementPosition(player), sizeOpt, density, type); int affected = editSession.makeForest(session.getPlacementPosition(actor), size, density, type);
player.print(affected + " trees created."); actor.print(affected + " trees created.");
return affected; return affected;
} }
@ -290,16 +292,17 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.pumpkins") @CommandPermissions("worldedit.generation.pumpkins")
@Logging(POSITION) @Logging(POSITION)
public int pumpkins(Player player, LocalSession session, EditSession editSession, public int pumpkins(Actor actor, LocalSession session, EditSession editSession,
@Arg(name = "size", desc = "The size of the patch", def = "10") @Arg(desc = "The size of the patch", def = "10")
int sizeOpt, int size,
@Arg(desc = "//TODO", def = "10") @Arg(desc = "//TODO", def = "10")
int apothem, int apothem,
@Arg(desc = "//TODO ", def = "0.02") @Arg(desc = "//TODO ", def = "0.02")
double density) throws WorldEditException { double density) throws WorldEditException {
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100"); checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), apothem, density); worldEdit.checkMaxRadius(size);
BBC.COMMAND_PUMPKIN.send(player, affected); int affected = editSession.makePumpkinPatches(session.getPlacementPosition(actor), apothem, density);
BBC.COMMAND_PUMPKIN.send(actor, affected);
return affected; return affected;
} }

View File

@ -1,448 +1,448 @@
package com.sk89q.worldedit.command; //package com.sk89q.worldedit.command;
//
import com.boydti.fawe.object.mask.AdjacentAnyMask; //import com.boydti.fawe.object.mask.AdjacentAnyMask;
import com.boydti.fawe.object.mask.AdjacentMask; //import com.boydti.fawe.object.mask.AdjacentMask;
import com.boydti.fawe.object.mask.AngleMask; //import com.boydti.fawe.object.mask.AngleMask;
import com.boydti.fawe.object.mask.BiomeMask; //import com.boydti.fawe.object.mask.BiomeMask;
import com.boydti.fawe.object.mask.BlockLightMask; //import com.boydti.fawe.object.mask.BlockLightMask;
import com.boydti.fawe.object.mask.BrightnessMask; //import com.boydti.fawe.object.mask.BrightnessMask;
import com.boydti.fawe.object.mask.DataMask; //import com.boydti.fawe.object.mask.DataMask;
import com.boydti.fawe.object.mask.ExtremaMask; //import com.boydti.fawe.object.mask.ExtremaMask;
import com.boydti.fawe.object.mask.IdDataMask; //import com.boydti.fawe.object.mask.IdDataMask;
import com.boydti.fawe.object.mask.IdMask; //import com.boydti.fawe.object.mask.IdMask;
import com.boydti.fawe.object.mask.LightMask; //import com.boydti.fawe.object.mask.LightMask;
import com.boydti.fawe.object.mask.OpacityMask; //import com.boydti.fawe.object.mask.OpacityMask;
import com.boydti.fawe.object.mask.ROCAngleMask; //import com.boydti.fawe.object.mask.ROCAngleMask;
import com.boydti.fawe.object.mask.RadiusMask; //import com.boydti.fawe.object.mask.RadiusMask;
import com.boydti.fawe.object.mask.RandomMask; //import com.boydti.fawe.object.mask.RandomMask;
import com.boydti.fawe.object.mask.SimplexMask; //import com.boydti.fawe.object.mask.SimplexMask;
import com.boydti.fawe.object.mask.SkyLightMask; //import com.boydti.fawe.object.mask.SkyLightMask;
import com.boydti.fawe.object.mask.SurfaceMask; //import com.boydti.fawe.object.mask.SurfaceMask;
import com.boydti.fawe.object.mask.WallMask; //import com.boydti.fawe.object.mask.WallMask;
import com.boydti.fawe.object.mask.XAxisMask; //import com.boydti.fawe.object.mask.XAxisMask;
import com.boydti.fawe.object.mask.YAxisMask; //import com.boydti.fawe.object.mask.YAxisMask;
import com.boydti.fawe.object.mask.ZAxisMask; //import com.boydti.fawe.object.mask.ZAxisMask;
import com.sk89q.worldedit.IncompleteRegionException; //import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession; //import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; //import com.sk89q.worldedit.WorldEdit;
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.extent.Extent; //import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.BlockMaskBuilder; //import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
import com.sk89q.worldedit.function.mask.ExistingBlockMask; //import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.ExpressionMask; //import com.sk89q.worldedit.function.mask.ExpressionMask;
import com.sk89q.worldedit.function.mask.Mask; //import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.MaskIntersection; //import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.mask.MaskUnion; //import com.sk89q.worldedit.function.mask.MaskUnion;
import com.sk89q.worldedit.function.mask.Masks; //import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.mask.OffsetMask; //import com.sk89q.worldedit.function.mask.OffsetMask;
import com.sk89q.worldedit.function.mask.RegionMask; //import com.sk89q.worldedit.function.mask.RegionMask;
import com.sk89q.worldedit.function.mask.SolidBlockMask; //import com.sk89q.worldedit.function.mask.SolidBlockMask;
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.ExpressionEnvironment; //import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
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.shape.WorldEditExpressionEnvironment; //import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
import com.sk89q.worldedit.session.request.RequestSelection; //import com.sk89q.worldedit.session.request.RequestSelection;
import com.sk89q.worldedit.world.biome.BiomeType; //import com.sk89q.worldedit.world.biome.BiomeType;
import org.enginehub.piston.annotation.Command; //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;
import org.enginehub.piston.annotation.param.Switch; //import org.enginehub.piston.annotation.param.Switch;
//
//@Command(aliases = {"masks"}, ////@Command(aliases = {"masks"},
// desc = "Help for the various masks. [More Info](https://git.io/v9r4K)", //// desc = "Help for the various masks. [More Info](https://git.io/v9r4K)",
// descFooter = "Masks determine if a block can be placed\n" + //// descFooter = "Masks determine if a block can be placed\n" +
// " - Use [brackets] for arguments\n" + //// " - Use [brackets] for arguments\n" +
// " - Use , to OR multiple\n" + //// " - Use , to OR multiple\n" +
// " - Use & to AND multiple\n" + //// " - Use & to AND multiple\n" +
// "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)
//public class MaskCommands {
// private final WorldEdit worldEdit;
//
// public MaskCommands(WorldEdit worldEdit) {
// this.worldEdit = worldEdit;
// }
//
// @Command(
// name = "#simplex",
// desc = "Use simplex noise as the mask"
// ) // )
@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class) // public Mask simplex(double scale, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
public class MaskCommands { // scale = 1d / Math.max(1, scale);
private final WorldEdit worldEdit; // minInt = (minInt - 50) / 50;
// maxInt = (maxInt - 50) / 50;
public MaskCommands(WorldEdit worldEdit) { // return new SimplexMask(scale, minInt, maxInt);
this.worldEdit = worldEdit; // }
} //
// @Command(
@Command( // name = "#light",
name = "#simplex", // desc = "Restrict to specific light levels"
desc = "Use simplex noise as the mask" // )
) // public Mask light(Extent extent, @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) { // return new LightMask(extent, (int) minInt, (int) maxInt);
scale = 1d / Math.max(1, scale); // }
minInt = (minInt - 50) / 50; //
maxInt = (maxInt - 50) / 50; // @Command(
return new SimplexMask(scale, minInt, maxInt); // name = "#false",
} // desc = "Always false"
// )
@Command( // public Mask falseMask(Extent extent) {
name = "#light", // return Masks.alwaysFalse();
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) { // @Command(
return new LightMask(extent, (int) minInt, (int) maxInt); // name = "#true",
} // desc = "Always true"
// )
@Command( // public Mask trueMask(Extent extent) {
name = "#false", // return Masks.alwaysTrue();
desc = "Always false" // }
) //
public Mask falseMask(Extent extent) { // @Command(
return Masks.alwaysFalse(); // name = "#skylight",
} // desc = "Restrict to specific sky light levels"
// )
@Command( // public Mask skylight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
name = "#true", // return new SkyLightMask(extent, (int) minInt, (int) maxInt);
desc = "Always true" // }
) //
public Mask trueMask(Extent extent) { // @Command(
return Masks.alwaysTrue(); // name = "#blocklight",
} // aliases = {"#emittedlight"},
// desc = "Restrict to specific block light levels"
@Command( // )
name = "#skylight", // public Mask blocklight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
desc = "Restrict to specific sky light levels" // return new BlockLightMask(extent, (int) minInt, (int) maxInt);
) // }
public Mask skylight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { //
return new SkyLightMask(extent, (int) minInt, (int) maxInt); // @Command(
} // name = "#opacity",
// desc = "Restrict to specific opacity levels"
@Command( // )
name = "#blocklight", // public Mask opacity(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
aliases = {"#emittedlight"}, // return new OpacityMask(extent, (int) minInt, (int) maxInt);
desc = "Restrict to specific block light levels" // }
) //
public Mask blocklight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { // @Command(
return new BlockLightMask(extent, (int) minInt, (int) maxInt); // name = "#brightness",
} // desc = "Restrict to specific block brightness"
// )
@Command( // public Mask brightness(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
name = "#opacity", // return new BrightnessMask(extent, (int) minInt, (int) maxInt);
desc = "Restrict to specific opacity levels" // }
) //
public Mask opacity(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { // @Command(
return new OpacityMask(extent, (int) minInt, (int) maxInt); // name = "#offset",
} // desc = "Offset a mask"
// )
@Command( // public Mask offset(double x, double y, double z, Mask mask) {
name = "#brightness", // return new OffsetMask(mask, BlockVector3.at(x, y, z));
desc = "Restrict to specific block brightness" // }
) //
public Mask brightness(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { // @Command(
return new BrightnessMask(extent, (int) minInt, (int) maxInt); // name = "#haslight",
} // desc = "Restricts to blocks with light (sky or emitted)"
// )
@Command( // public Mask haslight(Extent extent) {
name = "#offset", // return new LightMask(extent, 1, Integer.MAX_VALUE);
desc = "Offset a mask" // }
) //
public Mask offset(double x, double y, double z, Mask mask) { // @Command(
return new OffsetMask(mask, BlockVector3.at(x, y, z)); // name = "#nolight",
} // desc = "Restrict to blocks without light (sky or emitted)"
// )
@Command( // public Mask nolight(Extent extent) {
name = "#haslight", // return new LightMask(extent, 0, 0);
desc = "Restricts to blocks with light (sky or emitted)" // }
) //
public Mask haslight(Extent extent) { // @Command(
return new LightMask(extent, 1, Integer.MAX_VALUE); // name = "#existing",
} // desc = "If there is a non air block"
// )
@Command( // public Mask existing(Extent extent) {
name = "#nolight", // return new ExistingBlockMask(extent);
desc = "Restrict to blocks without light (sky or emitted)" // }
) //
public Mask nolight(Extent extent) { // @Command(
return new LightMask(extent, 0, 0); // name = "#solid",
} // desc = "If there is a solid block"
// )
@Command( // public Mask solid(Extent extent) {
name = "#existing", // return new SolidBlockMask(extent);
desc = "If there is a non air block" // }
) //
public Mask existing(Extent extent) { // @Command(
return new ExistingBlockMask(extent); // name = "#liquid",
} // desc = "If there is a solid block"
// )
@Command( // public Mask liquid(Extent extent) {
name = "#solid", // return new BlockMaskBuilder().addAll(b -> b.getMaterial().isLiquid()).build(extent);
desc = "If there is a solid block" // }
) //
public Mask solid(Extent extent) { // @Command(
return new SolidBlockMask(extent); // name = "#dregion",
} // aliases = {"#dselection", "#dsel"},
// desc = "inside the player's selection"
@Command( // )
name = "#liquid", // public Mask dregion() {
desc = "If there is a solid block" // return new RegionMask(new RequestSelection());
) // }
public Mask liquid(Extent extent) { //
return new BlockMaskBuilder().addAll(b -> b.getMaterial().isLiquid()).build(extent); // @Command(
} // name = "#region",
// aliases = {"#selection", "#sel"},
@Command( // desc = "inside the provided selection"
name = "#dregion", // )
aliases = {"#dselection", "#dsel"}, // public Mask selection(Player player, LocalSession session) throws IncompleteRegionException {
desc = "inside the player's selection" // return new RegionMask(session.getSelection(player.getWorld()).clone());
) // }
public Mask dregion() { //
return new RegionMask(new RequestSelection()); // @Command(
} // name = "#xaxis",
// desc = "Restrict to initial x axis"
@Command( // )
name = "#region", // public Mask xaxis() {
aliases = {"#selection", "#sel"}, // return new XAxisMask();
desc = "inside the provided selection" // }
) //
public Mask selection(Player player, LocalSession session) throws IncompleteRegionException { // @Command(
return new RegionMask(session.getSelection(player.getWorld()).clone()); // name = "#yaxis",
} // desc = "Restrict to initial y axis"
// )
@Command( // public Mask yaxis() {
name = "#xaxis", // return new YAxisMask();
desc = "Restrict to initial x axis" // }
) //
public Mask xaxis() { // @Command(
return new XAxisMask(); // name = "#zaxis",
} // desc = "Restrict to initial z axis"
// )
@Command( // public Mask zaxis() {
name = "#yaxis", // return new ZAxisMask();
desc = "Restrict to initial y axis" // }
) //
public Mask yaxis() { // @Command(
return new YAxisMask(); // name = "#id",
} // desc = "Restrict to initial id"
// )
@Command( // public Mask id(Extent extent) {
name = "#zaxis", // return new IdMask(extent);
desc = "Restrict to initial z axis" // }
) //
public Mask zaxis() { // @Command(
return new ZAxisMask(); // name = "#data",
} // desc = "Restrict to initial data"
// )
@Command( // public Mask data(Extent extent) {
name = "#id", // return new DataMask(extent);
desc = "Restrict to initial id" // }
) //
public Mask id(Extent extent) { // @Command(
return new IdMask(extent); // name = "#iddata",
} // desc = "Restrict to initial block id and data"
// )
@Command( // public Mask iddata(Extent extent) {
name = "#data", // return new IdDataMask(extent);
desc = "Restrict to initial data" // }
) //
public Mask data(Extent extent) { // @Command(
return new DataMask(extent); // name = "#air",
} // desc = "Restrict to types of air"
// )
@Command( // public Mask air(Extent extent) {
name = "#iddata", // return new BlockMaskBuilder().addAll(b -> b.getMaterial().isAir()).build(extent);
desc = "Restrict to initial block id and data" // }
) //
public Mask iddata(Extent extent) { // @Command(
return new IdDataMask(extent); // name = "#wall",
} // desc = "Restrict to walls (any block n,e,s,w of air)"
// )
@Command( // public Mask wall(Extent extent) {
name = "#air", // Mask blockMask = air(extent);
desc = "Restrict to types of air" // return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8));
) // }
public Mask air(Extent extent) { //
return new BlockMaskBuilder().addAll(b -> b.getMaterial().isAir()).build(extent); // @Command(
} // name = "#surface",
// desc = "Restrict to surfaces (any solid block touching air)"
@Command( // )
name = "#wall", // public Mask surface(Extent extent) {
desc = "Restrict to walls (any block n,e,s,w of air)" // return new SurfaceMask(extent);
) // }
public Mask wall(Extent extent) { //
Mask blockMask = air(extent); // @Command(
return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8)); // name = "\\",
} // aliases = {"/", "#angle", "#\\", "#/"},
// desc = "Restrict to specific terrain angle",
@Command( // descFooter = "Restrict to specific terrain angle\n" +
name = "#surface", // "The -o flag will only overlay\n" +
desc = "Restrict to surfaces (any solid block touching air)" // "Example: /[0d][45d]\n" +
) // "Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" +
public Mask surface(Extent extent) { // "Example: /[3][20]\n" +
return new SurfaceMask(extent); // "Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below"
} //)
// 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 {
@Command( // double y1, y2;
name = "\\", // boolean override;
aliases = {"/", "#angle", "#\\", "#/"}, // if (maxStr.endsWith("d")) {
desc = "Restrict to specific terrain angle", // double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
descFooter = "Restrict to specific terrain angle\n" + // double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
"The -o flag will only overlay\n" + // y1 = Math.tan(y1d * (Math.PI / 180));
"Example: /[0d][45d]\n" + // y2 = Math.tan(y2d * (Math.PI / 180));
"Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" + // } else {
"Example: /[3][20]\n" + // y1 = Expression.compile(minStr).evaluate();
"Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below" // y2 = Expression.compile(maxStr).evaluate();
) // }
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 { // return new AngleMask(extent, y1, y2, overlay, distanceOpt);
double y1, y2; // }
boolean override; //
if (maxStr.endsWith("d")) { // @Command(
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate(); // name = "(",
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate(); // aliases = {")", "#roc", "#(", "#)"},
y1 = Math.tan(y1d * (Math.PI / 180)); // desc = "Restrict to near specific terrain slope rate of change",
y2 = Math.tan(y2d * (Math.PI / 180)); // descFooter = "Restrict to near specific terrain slope rate of change\n" +
} else { // "The -o flag will only overlay\n" +
y1 = Expression.compile(minStr).evaluate(); // "Example: ([0d][45d][5]\n" +
y2 = Expression.compile(maxStr).evaluate(); // "Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" +
} // "Note: Use negatives for decreasing slope"
return new AngleMask(extent, y1, y2, overlay, distanceOpt); //)
} // 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;
@Command( // boolean override;
name = "(", // if (maxStr.endsWith("d")) {
aliases = {")", "#roc", "#(", "#)"}, // double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
desc = "Restrict to near specific terrain slope rate of change", // double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
descFooter = "Restrict to near specific terrain slope rate of change\n" + // y1 = Math.tan(y1d * (Math.PI / 180));
"The -o flag will only overlay\n" + // y2 = Math.tan(y2d * (Math.PI / 180));
"Example: ([0d][45d][5]\n" + // } else {
"Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" + // y1 = Expression.compile(minStr).evaluate();
"Note: Use negatives for decreasing slope" // y2 = Expression.compile(maxStr).evaluate();
) // }
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 { // return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt);
double y1, y2; // }
boolean override; //
if (maxStr.endsWith("d")) { // @Command(
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate(); // name = "^",
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate(); // aliases = {"#extrema", "#^"},
y1 = Math.tan(y1d * (Math.PI / 180)); // desc = "Restrict to near specific terrain extrema",
y2 = Math.tan(y2d * (Math.PI / 180)); // descFooter = "Restrict to near specific terrain extrema\n" +
} else { // "The -o flag will only overlay\n" +
y1 = Expression.compile(minStr).evaluate(); // "Example: ([0d][45d][5]\n" +
y2 = Expression.compile(maxStr).evaluate(); // "Explanation: Restrict to near 45 degrees of local maxima\n" +
} // "Note: Use negatives for local minima"
return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt); //)
} // 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;
@Command( // boolean override;
name = "^", // if (maxStr.endsWith("d")) {
aliases = {"#extrema", "#^"}, // double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
desc = "Restrict to near specific terrain extrema", // double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
descFooter = "Restrict to near specific terrain extrema\n" + // y1 = Math.tan(y1d * (Math.PI / 180));
"The -o flag will only overlay\n" + // y2 = Math.tan(y2d * (Math.PI / 180));
"Example: ([0d][45d][5]\n" + // } else {
"Explanation: Restrict to near 45 degrees of local maxima\n" + // y1 = Expression.compile(minStr).evaluate();
"Note: Use negatives for local minima" // y2 = Expression.compile(maxStr).evaluate();
) // }
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 { // return new ExtremaMask(extent, y1, y2, overlay, distanceOpt);
double y1, y2; // }
boolean override; //
if (maxStr.endsWith("d")) { // @Command(
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate(); // name = "{",
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate(); // aliases = {"#{"},
y1 = Math.tan(y1d * (Math.PI / 180)); // desc = "Restricts blocks to within a specific radius range of the initial block"
y2 = Math.tan(y2d * (Math.PI / 180)); //)
} else { // public Mask radius(@Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
y1 = Expression.compile(minStr).evaluate(); // return new RadiusMask((int) minInt, (int) maxInt);
y2 = Expression.compile(maxStr).evaluate(); // }
} //
return new ExtremaMask(extent, y1, y2, overlay, distanceOpt); // @Command(
} // name = "|",
// aliases = {"#|", "#side"},
@Command( // desc = "sides with a specific number of other blocks"
name = "{", //)
aliases = {"#{"}, // public Mask wall(Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
desc = "Restricts blocks to within a specific radius range of the initial block" // return new WallMask(mask, (int) minInt, (int) maxInt);
) // }
public Mask radius(@Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException { //
return new RadiusMask((int) minInt, (int) maxInt); // @Command(
} // name = "~",
// aliases = {"#~", "#adjacent"},
@Command( // desc = "Adjacent to a specific number of other blocks"
name = "|", //)
aliases = {"#|", "#side"}, // public Mask adjacent(Mask mask, @Arg(name = "min", desc = "double", def = "-1") double min, @Arg(name = "max", desc = "double", def = "-1") double max) throws ExpressionException {
desc = "sides with a specific number of other blocks" // if (min == -1 && max == -1) {
) // min = 1;
public Mask wall(Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException { // max = 8;
return new WallMask(mask, (int) minInt, (int) maxInt); // } else if (max == -1) max = min;
} // if (max >= 8 && min == 1) {
// return new AdjacentAnyMask(mask);
@Command( // }
name = "~", // return new AdjacentMask(mask, (int) min, (int) max);
aliases = {"#~", "#adjacent"}, // }
desc = "Adjacent to a specific number of other blocks" //
) // @Command(
public Mask adjacent(Mask mask, @Arg(name = "min", desc = "double", def = "-1") double min, @Arg(name = "max", desc = "double", def = "-1") double max) throws ExpressionException { // name = "<",
if (min == -1 && max == -1) { // aliases = {"#<", "#below"},
min = 1; // desc = "below a specific block"
max = 8; //)
} else if (max == -1) max = min; // public Mask below(Mask mask) throws ExpressionException {
if (max >= 8 && min == 1) { // OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0));
return new AdjacentAnyMask(mask); // return new MaskIntersection(offsetMask, Masks.negate(mask));
} // }
return new AdjacentMask(mask, (int) min, (int) max); //
} // @Command(
// name = ">",
@Command( // aliases = {"#>", "#above"},
name = "<", // desc = "above a specific block"
aliases = {"#<", "#below"}, //)
desc = "below a specific block" // public Mask above(Mask mask) throws ExpressionException {
) // OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0));
public Mask below(Mask mask) throws ExpressionException { // return new MaskIntersection(offsetMask, Masks.negate(mask));
OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0)); // }
return new MaskIntersection(offsetMask, Masks.negate(mask)); //
} // @Command(
// name = "$",
@Command( // aliases = {"#biome", "#$"},
name = ">", // desc = "in a specific biome",
aliases = {"#>", "#above"}, // descFooter = "in a specific biome. For a list of biomes use //biomelist"
desc = "above a specific block" //)
) // public Mask biome(Extent extent, BiomeType biome) throws ExpressionException {
public Mask above(Mask mask) throws ExpressionException { // return new BiomeMask(extent, biome);
OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0)); // }
return new MaskIntersection(offsetMask, Masks.negate(mask)); //
} // @Command(
// name = "%",
@Command( // aliases = {"#%", "#percent"},
name = "$", // desc = "percentage chance"
aliases = {"#biome", "#$"}, //)
desc = "in a specific biome", // public Mask random(double chance) throws ExpressionException {
descFooter = "in a specific biome. For a list of biomes use //biomelist" // chance = chance / 100;
) // return new RandomMask(chance);
public Mask biome(Extent extent, BiomeType biome) throws ExpressionException { // }
return new BiomeMask(extent, biome); //
} // @Command(
// name = "=",
@Command( // aliases = {"#=", "#expression"},
name = "%", // desc = "expression mask"
aliases = {"#%", "#percent"}, //)
desc = "percentage chance" // public Mask expression(Extent extent, String input) throws ExpressionException {
) // Expression exp = Expression.compile(input, "x", "y", "z");
public Mask random(double chance) throws ExpressionException { // ExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
chance = chance / 100; // exp.setEnvironment(env);
return new RandomMask(chance); // return new ExpressionMask(exp);
} // }
//
@Command( // @Command(
name = "=", // name = "!",
aliases = {"#=", "#expression"}, // aliases = {"#not", "#negate", "#!"},
desc = "expression mask" // desc = "Negate another mask"
) //)
public Mask expression(Extent extent, String input) throws ExpressionException { // public Mask expression(Mask mask) throws ExpressionException {
Expression exp = Expression.compile(input, "x", "y", "z"); // return Masks.negate(mask);
ExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO); // }
exp.setEnvironment(env); //}
return new ExpressionMask(exp);
}
@Command(
name = "!",
aliases = {"#not", "#negate", "#!"},
desc = "Negate another mask"
)
public Mask expression(Mask mask) throws ExpressionException {
return Masks.negate(mask);
}
}

View File

@ -1,403 +1,403 @@
package com.sk89q.worldedit.command; //package com.sk89q.worldedit.command;
//
import com.boydti.fawe.object.DataAnglePattern; //import com.boydti.fawe.object.DataAnglePattern;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; //import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.boydti.fawe.object.collection.RandomCollection; //import com.boydti.fawe.object.collection.RandomCollection;
import com.boydti.fawe.object.pattern.AngleColorPattern; //import com.boydti.fawe.object.pattern.AngleColorPattern;
import com.boydti.fawe.object.pattern.AverageColorPattern; //import com.boydti.fawe.object.pattern.AverageColorPattern;
import com.boydti.fawe.object.pattern.BiomePattern; //import com.boydti.fawe.object.pattern.BiomePattern;
import com.boydti.fawe.object.pattern.BufferedPattern; //import com.boydti.fawe.object.pattern.BufferedPattern;
import com.boydti.fawe.object.pattern.BufferedPattern2D; //import com.boydti.fawe.object.pattern.BufferedPattern2D;
import com.boydti.fawe.object.pattern.DataPattern; //import com.boydti.fawe.object.pattern.DataPattern;
import com.boydti.fawe.object.pattern.DesaturatePattern; //import com.boydti.fawe.object.pattern.DesaturatePattern;
import com.boydti.fawe.object.pattern.ExistingPattern; //import com.boydti.fawe.object.pattern.ExistingPattern;
import com.boydti.fawe.object.pattern.ExpressionPattern; //import com.boydti.fawe.object.pattern.ExpressionPattern;
import com.boydti.fawe.object.pattern.FullClipboardPattern; //import com.boydti.fawe.object.pattern.FullClipboardPattern;
import com.boydti.fawe.object.pattern.IdDataMaskPattern; //import com.boydti.fawe.object.pattern.IdDataMaskPattern;
import com.boydti.fawe.object.pattern.IdPattern; //import com.boydti.fawe.object.pattern.IdPattern;
import com.boydti.fawe.object.pattern.Linear2DBlockPattern; //import com.boydti.fawe.object.pattern.Linear2DBlockPattern;
import com.boydti.fawe.object.pattern.Linear3DBlockPattern; //import com.boydti.fawe.object.pattern.Linear3DBlockPattern;
import com.boydti.fawe.object.pattern.LinearBlockPattern; //import com.boydti.fawe.object.pattern.LinearBlockPattern;
import com.boydti.fawe.object.pattern.MaskedPattern; //import com.boydti.fawe.object.pattern.MaskedPattern;
import com.boydti.fawe.object.pattern.NoXPattern; //import com.boydti.fawe.object.pattern.NoXPattern;
import com.boydti.fawe.object.pattern.NoYPattern; //import com.boydti.fawe.object.pattern.NoYPattern;
import com.boydti.fawe.object.pattern.NoZPattern; //import com.boydti.fawe.object.pattern.NoZPattern;
import com.boydti.fawe.object.pattern.OffsetPattern; //import com.boydti.fawe.object.pattern.OffsetPattern;
import com.boydti.fawe.object.pattern.PropertyPattern; //import com.boydti.fawe.object.pattern.PropertyPattern;
import com.boydti.fawe.object.pattern.RandomFullClipboardPattern; //import com.boydti.fawe.object.pattern.RandomFullClipboardPattern;
import com.boydti.fawe.object.pattern.RandomOffsetPattern; //import com.boydti.fawe.object.pattern.RandomOffsetPattern;
import com.boydti.fawe.object.pattern.RelativePattern; //import com.boydti.fawe.object.pattern.RelativePattern;
import com.boydti.fawe.object.pattern.SaturatePattern; //import com.boydti.fawe.object.pattern.SaturatePattern;
import com.boydti.fawe.object.pattern.ShadePattern; //import com.boydti.fawe.object.pattern.ShadePattern;
import com.boydti.fawe.object.pattern.SolidRandomOffsetPattern; //import com.boydti.fawe.object.pattern.SolidRandomOffsetPattern;
import com.boydti.fawe.object.pattern.SurfaceRandomOffsetPattern; //import com.boydti.fawe.object.pattern.SurfaceRandomOffsetPattern;
import com.boydti.fawe.object.random.SimplexRandom; //import com.boydti.fawe.object.random.SimplexRandom;
import com.boydti.fawe.util.ColorUtil; //import com.boydti.fawe.util.ColorUtil;
import com.boydti.fawe.util.TextureUtil; //import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.EmptyClipboardException; //import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.LocalSession; //import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.entity.Player; //import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.InputParseException; //import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.platform.Actor; //import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.Extent; //import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.Clipboard; //import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; //import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.function.mask.Mask; //import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.ClipboardPattern; //import com.sk89q.worldedit.function.pattern.ClipboardPattern;
import com.sk89q.worldedit.function.pattern.Pattern; //import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.RandomPattern; //import com.sk89q.worldedit.function.pattern.RandomPattern;
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.math.Vector3; //import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; //import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
import com.sk89q.worldedit.session.ClipboardHolder; //import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.biome.BiomeType; //import com.sk89q.worldedit.world.biome.BiomeType;
import java.awt.Color; //import java.awt.Color;
import java.io.IOException; //import java.io.IOException;
import java.util.Collections; //import java.util.Collections;
import java.util.List; //import java.util.List;
import java.util.Set; //import java.util.Set;
import org.enginehub.piston.annotation.Command; //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;
//
//@Command(aliases = {"patterns"}, ////@Command(aliases = {"patterns"},
// desc = "Help for the various patterns. [More Info](https://git.io/vSPmA)", //// desc = "Help for the various patterns. [More Info](https://git.io/vSPmA)",
// descFooter = "Patterns determine what blocks are placed\n" + //// descFooter = "Patterns determine what blocks are placed\n" +
// " - Use [brackets] for arguments\n" + //// " - Use [brackets] for arguments\n" +
// " - Use , to OR multiple\n" + //// " - Use , to OR multiple\n" +
// "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)
//public class PatternCommands {
//
// @Command(
// name = "#existing",
// aliases = {"#*", "*", ".*"},
// desc = "Use the block that is already there"
// ) // )
@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class) // public Pattern existing(Extent extent, @Arg(name = "properties", desc = "String", def = "") String properties) { // TODO FIXME , @Arg(name = "properties", desc = "String", def = "") String properties
public class PatternCommands { // if (properties == null) return new ExistingPattern(extent);
// return new PropertyPattern(extent).addRegex(".*[" + properties + "]");
@Command( // }
name = "#existing", //
aliases = {"#*", "*", ".*"}, // @Command(
desc = "Use the block that is already there" // name = "#clipboard",
) // aliases = {"#copy"},
public Pattern existing(Extent extent, @Arg(name = "properties", desc = "String", def = "") String properties) { // TODO FIXME , @Arg(name = "properties", desc = "String", def = "") String properties // desc = "Use the blocks in your clipboard as the pattern")
if (properties == null) return new ExistingPattern(extent); // public Pattern clipboard(LocalSession session) throws EmptyClipboardException {
return new PropertyPattern(extent).addRegex(".*[" + properties + "]"); // ClipboardHolder holder = session.getClipboard();
} // Clipboard clipboard = holder.getClipboard();
// return new ClipboardPattern(clipboard);
@Command( // }
name = "#clipboard", //
aliases = {"#copy"}, // @Command(
desc = "Use the blocks in your clipboard as the pattern") // name = "#simplex",
public Pattern clipboard(LocalSession session) throws EmptyClipboardException { // desc = "Use simplex noise to randomize blocks. Tutorial: https://imgur.com/a/rwVAE"
ClipboardHolder holder = session.getClipboard(); //)
Clipboard clipboard = holder.getClipboard(); // public Pattern simplex(@Arg(desc = "scale factor") double scale, Pattern other) {
return new ClipboardPattern(clipboard); // if (other instanceof RandomPattern) {
} // scale = (1d / Math.max(1, scale));
// RandomCollection<Pattern> collection = ((RandomPattern) other).getCollection();
@Command( // collection.setRandom(new SimplexRandom(scale));
name = "#simplex", // }
desc = "Use simplex noise to randomize blocks. Tutorial: https://imgur.com/a/rwVAE" // return other;
) // }
public Pattern simplex(@Arg(desc = "scale factor") double scale, Pattern other) { //
if (other instanceof RandomPattern) { // @Command(
scale = (1d / Math.max(1, scale)); // name = "#color",
RandomCollection<Pattern> collection = ((RandomPattern) other).getCollection(); // desc = "Use the block closest to a specific color"
collection.setRandom(new SimplexRandom(scale)); //)
} // public Pattern color(TextureUtil textureUtil, String color) {
return other; // Color colorObj = ColorUtil.parseColor(color);
} // return textureUtil.getNearestBlock(colorObj.getRGB()).getDefaultState();
// }
@Command( //
name = "#color", // @Command(
desc = "Use the block closest to a specific color" // name = "#anglecolor",
) // desc = "A darker block based on the existing terrain angle"
public Pattern color(TextureUtil textureUtil, String color) { //)
Color colorObj = ColorUtil.parseColor(color); // 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 textureUtil.getNearestBlock(colorObj.getRGB()).getDefaultState(); // return new AngleColorPattern(extent, session, distanceOpt);
} // }
//
@Command( // @Command(
name = "#anglecolor", // name = "#angledata",
desc = "A darker block based on the existing terrain angle" // desc = "Block data 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 distanceOpt) { // public Pattern angledata(Extent extent, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) {
return new AngleColorPattern(extent, session, distanceOpt); // return new DataAnglePattern(extent, distanceOpt);
} // }
//
@Command( // @Command(
name = "#angledata", // name = "#saturate",
desc = "Block data based on the existing terrain angle" // desc = "Saturate the existing block with a color"
) //)
public Pattern angledata(Extent extent, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) { // public Pattern saturate(Extent extent, LocalSession session, String colorStr) {
return new DataAnglePattern(extent, distanceOpt); // Color color = ColorUtil.parseColor(colorStr);
} // return new SaturatePattern(extent, color.getRGB(), session);
// }
@Command( //
name = "#saturate", // @Command(
desc = "Saturate the existing block with a color" // name = "#averagecolor",
) // desc = "Average between the existing block and a color"
public Pattern saturate(Extent extent, LocalSession session, String colorStr) { //)
Color color = ColorUtil.parseColor(colorStr); // public Pattern averagecolor(Extent extent, LocalSession session, String colorStr) {
return new SaturatePattern(extent, color.getRGB(), session); // Color color = ColorUtil.parseColor(colorStr);
} // return new AverageColorPattern(extent, color.getRGB(), session);
// }
@Command( //
name = "#averagecolor", // @Command(
desc = "Average between the existing block and a color" // name = "#desaturate",
) // desc = "Desaturated color of the existing block"
public Pattern averagecolor(Extent extent, LocalSession session, String colorStr) { //)
Color color = ColorUtil.parseColor(colorStr); // public Pattern desaturate(Extent extent, LocalSession session, @Arg(name = "percent", desc = "double", def = "100") double percent) {
return new AverageColorPattern(extent, color.getRGB(), session); // return new DesaturatePattern(extent, percent / 100d, session);
} // }
//
@Command( // @Command(
name = "#desaturate", // name = "#lighten",
desc = "Desaturated color of the existing block" // desc = "Lighten the existing block"
) //)
public Pattern desaturate(Extent extent, LocalSession session, @Arg(name = "percent", desc = "double", def = "100") double percent) { // public Pattern lighten(Extent extent, TextureUtil util) {
return new DesaturatePattern(extent, percent / 100d, session); // return new ShadePattern(extent, false, util);
} // }
//
@Command( // @Command(
name = "#lighten", // name = "#darken",
desc = "Lighten the existing block" // desc = "Darken the existing block"
) //)
public Pattern lighten(Extent extent, TextureUtil util) { // public Pattern darken(Extent extent, TextureUtil util) {
return new ShadePattern(extent, false, util); // return new ShadePattern(extent, true, util);
} // }
//
@Command( // @Command(
name = "#darken", // name = "#fullcopy",
desc = "Darken the existing block" // desc = "Places your full clipboard at each block"
) //)
public Pattern darken(Extent extent, TextureUtil util) { // public Pattern fullcopy(Player player, Extent extent, LocalSession session, @Arg(name = "location", desc = "String", def = "#copy") String location, @Arg(name = "rotate", desc = "boolean", def = "false") boolean rotate, @Arg(name = "flip", desc = "boolean", def = "false") boolean flip) throws EmptyClipboardException, InputParseException, IOException {
return new ShadePattern(extent, true, util); // List<ClipboardHolder> clipboards;
} // switch (location.toLowerCase()) {
// case "#copy":
@Command( // case "#clipboard":
name = "#fullcopy", // ClipboardHolder clipboard = session.getExistingClipboard();
desc = "Places your full clipboard at each block" // if (clipboard == null) {
) // throw new InputParseException("To use #fullcopy, please first copy something to your clipboard");
public Pattern fullcopy(Player player, Extent extent, LocalSession session, @Arg(name = "location", desc = "String", def = "#copy") String location, @Arg(name = "rotate", desc = "boolean", def = "false") boolean rotate, @Arg(name = "flip", desc = "boolean", def = "false") boolean flip) throws EmptyClipboardException, InputParseException, IOException { // }
List<ClipboardHolder> clipboards; // if (!rotate && !flip) {
switch (location.toLowerCase()) { // return new FullClipboardPattern(extent, clipboard.getClipboard());
case "#copy": // }
case "#clipboard": // clipboards = Collections.singletonList(clipboard);
ClipboardHolder clipboard = session.getExistingClipboard(); // break;
if (clipboard == null) { // default:
throw new InputParseException("To use #fullcopy, please first copy something to your clipboard"); // MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(player, location, null, true);
} // clipboards = multi != null ? multi.getHolders() : null;
if (!rotate && !flip) { // break;
return new FullClipboardPattern(extent, clipboard.getClipboard()); // }
} // if (clipboards == null) {
clipboards = Collections.singletonList(clipboard); // throw new InputParseException("#fullcopy:<source>");
break; // }
default: // return new RandomFullClipboardPattern(extent, clipboards, rotate, flip);
MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(player, location, null, true); // }
clipboards = multi != null ? multi.getHolders() : null; //
break; // @Command(
} // name = "#buffer",
if (clipboards == null) { // desc = "Only place a block once while a pattern is in use",
throw new InputParseException("#fullcopy:<source>"); // descFooter = "Only place a block once while a pattern is in use\n" +
} // "Use with a brush when you don't want to apply to the same spot twice"
return new RandomFullClipboardPattern(extent, clipboards, rotate, flip); //)
} // public Pattern buffer(Actor actor, Pattern pattern) {
// return new BufferedPattern(actor, pattern);
@Command( // }
name = "#buffer", //
desc = "Only place a block once while a pattern is in use", // @Command(
descFooter = "Only place a block once while a pattern is in use\n" + // name = "#buffer2d",
"Use with a brush when you don't want to apply to the same spot twice" // desc = "Only place a block once in a column while a pattern is in use"
) //)
public Pattern buffer(Actor actor, Pattern pattern) { // public Pattern buffer2d(Actor actor, Pattern pattern) {
return new BufferedPattern(actor, pattern); // return new BufferedPattern2D(actor, pattern);
} // }
//
@Command( // @Command(
name = "#buffer2d", // name = "#iddatamask",
desc = "Only place a block once in a column while a pattern is in use" // desc = "Use the pattern's id and the existing blocks data with the provided mask",
) // descFooter = "Use the pattern's id and the existing blocks data with the provided mask\n" +
public Pattern buffer2d(Actor actor, Pattern pattern) { // " - Use to replace slabs or where the data values needs to be shifted instead of set"
return new BufferedPattern2D(actor, pattern); //)
} // public Pattern iddatamask(Actor actor, LocalSession session, Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) {
//
@Command( // return new IdDataMaskPattern(extent, pattern, bitmask);
name = "#iddatamask", // }
desc = "Use the pattern's id and the existing blocks data with the provided mask", //
descFooter = "Use the pattern's id and the existing blocks data with the provided mask\n" + // @Command(
" - Use to replace slabs or where the data values needs to be shifted instead of set" // name = "#id",
) // desc = "Only change the block id"
public Pattern iddatamask(Actor actor, LocalSession session, Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) { //)
// public Pattern id(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new IdDataMaskPattern(extent, pattern, bitmask); //
} // return new IdPattern(extent, pattern);
// }
@Command( //
name = "#id", // @Command(
desc = "Only change the block id" // name = "#data",
) // desc = "Only change the block data"
public Pattern id(Actor actor, LocalSession session, Extent extent, Pattern pattern) { //)
// public Pattern data(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new IdPattern(extent, pattern); //
} // return new DataPattern(extent, pattern);
// }
@Command( //
name = "#data", // @Command(
desc = "Only change the block data" // name = "#biome",
) // aliases = {"$"},
public Pattern data(Actor actor, LocalSession session, Extent extent, Pattern pattern) { // desc = "Set the biome"
//)
return new DataPattern(extent, pattern); // public Pattern biome(Actor actor, LocalSession session, Extent extent, BiomeType biome) {
} //
// return new BiomePattern(extent, biome);
@Command( // }
name = "#biome", //
aliases = {"$"}, // @Command(
desc = "Set the biome" // name = "#relative",
) // aliases = {"#~", "#r", "#rel"},
public Pattern biome(Actor actor, LocalSession session, Extent extent, BiomeType biome) { // desc = "Offset the pattern to where you click"
//)
return new BiomePattern(extent, biome); // public Pattern relative(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
} //
// return new RelativePattern(pattern);
@Command( // }
name = "#relative", //
aliases = {"#~", "#r", "#rel"}, // @Command(
desc = "Offset the pattern to where you click" // name = "#!x",
) // aliases = {"#nx", "#nox"},
public Pattern relative(Actor actor, LocalSession session, Extent extent, Pattern pattern) { // desc = "The pattern will not be provided the x axis info",
// descFooter = "The pattern will not be provided the z axis info.\n" +
return new RelativePattern(pattern); // "Example: #!x[#!z[#~[#l3d[pattern]]]]"
} //)
// public Pattern nox(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
@Command( //
name = "#!x", // return new NoXPattern(pattern);
aliases = {"#nx", "#nox"}, // }
desc = "The pattern will not be provided the x axis info", //
descFooter = "The pattern will not be provided the z axis info.\n" + // @Command(
"Example: #!x[#!z[#~[#l3d[pattern]]]]" // name = "#!y",
) // aliases = {"#ny", "#noy"},
public Pattern nox(Actor actor, LocalSession session, Extent extent, Pattern pattern) { // desc = "The pattern will not be provided the y axis info"
//)
return new NoXPattern(pattern); // public Pattern noy(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
} //
// return new NoYPattern(pattern);
@Command( // }
name = "#!y", //
aliases = {"#ny", "#noy"}, // @Command(
desc = "The pattern will not be provided the y axis info" // name = "#!z",
) // aliases = {"#nz", "#noz"},
public Pattern noy(Actor actor, LocalSession session, Extent extent, Pattern pattern) { // desc = "The pattern will not be provided the z axis info"
//)
return new NoYPattern(pattern); // public Pattern noz(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
} //
// return new NoZPattern(pattern);
@Command( // }
name = "#!z", //
aliases = {"#nz", "#noz"}, // @Command(
desc = "The pattern will not be provided the z axis info" // name = "#mask",
) // desc = "Apply a pattern depending on a mask"
public Pattern noz(Actor actor, LocalSession session, Extent extent, Pattern pattern) { //)
// public Pattern mask(Actor actor, LocalSession session, Mask mask, Pattern pass, Pattern fail) {
return new NoZPattern(pattern); // return new MaskedPattern(mask, pass, fail);
} // }
//
@Command( // @Command(
name = "#mask", // name = "#offset",
desc = "Apply a pattern depending on a mask" // desc = "Offset a pattern"
) //)
public Pattern mask(Actor actor, LocalSession session, Mask mask, Pattern pass, Pattern fail) { // public Pattern offset(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
return new MaskedPattern(mask, pass, fail); //
} // return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
// }
@Command( //
name = "#offset", // @Command(
desc = "Offset a pattern" // name = "#surfacespread",
) // desc = "Applies to only blocks on a surface. Selects a block from provided pattern with a given ranomized offset `[0, <distance>)`. e.g. Use `#existing` to randomly offset blocks in the world, or `#copy` to offset blocks in your clipboard"
public Pattern offset(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) { //)
// public Pattern surfacespread(Actor actor, LocalSession session, double distance, Pattern pattern) {
return new OffsetPattern(pattern, (int) x, (int) y, (int) z); //
} // return new SurfaceRandomOffsetPattern(pattern, (int) distance);
// }
@Command( //
name = "#surfacespread", // @Command(
desc = "Applies to only blocks on a surface. Selects a block from provided pattern with a given ranomized offset `[0, <distance>)`. e.g. Use `#existing` to randomly offset blocks in the world, or `#copy` to offset blocks in your clipboard" // name = "#solidspread",
) // desc = "Randomly spread solid blocks"
public Pattern surfacespread(Actor actor, LocalSession session, double distance, Pattern pattern) { //)
// public Pattern solidspread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
return new SurfaceRandomOffsetPattern(pattern, (int) distance); //
} // return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
// }
@Command( //
name = "#solidspread", // @Command(
desc = "Randomly spread solid blocks" // name = "#spread",
) // aliases = {"#randomoffset"},
public Pattern solidspread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) { // desc = "Randomly spread blocks"
//)
return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z); // public Pattern spread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
} //
// return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
@Command( // }
name = "#spread", //
aliases = {"#randomoffset"}, // @Command(
desc = "Randomly spread blocks" // name = "#linear",
) // aliases = {"#l"},
public Pattern spread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) { // desc = "Sequentially set blocks from a list of patterns"
//)
return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z); // public Pattern linear(Actor actor, LocalSession session, Pattern other) {
} //
// if (other instanceof RandomPattern) {
@Command( // Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
name = "#linear", // return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
aliases = {"#l"}, // }
desc = "Sequentially set blocks from a list of patterns" // return other;
) // }
public Pattern linear(Actor actor, LocalSession session, Pattern other) { //
// @Command(
if (other instanceof RandomPattern) { // name = "#linear3d",
Set<Pattern> patterns = ((RandomPattern) other).getPatterns(); // aliases = {"#l3d"},
return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()])); // desc = "Use the x,y,z coordinate to pick a block from the list"
} //)
return other; // public Pattern linear3d(Actor actor, LocalSession session, Pattern other) {
} //
// if (other instanceof RandomPattern) {
@Command( // Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
name = "#linear3d", // return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
aliases = {"#l3d"}, // }
desc = "Use the x,y,z coordinate to pick a block from the list" // return other;
) // }
public Pattern linear3d(Actor actor, LocalSession session, Pattern other) { //
// @Command(
if (other instanceof RandomPattern) { // name = "#linear2d",
Set<Pattern> patterns = ((RandomPattern) other).getPatterns(); // aliases = {"#l2d"},
return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()])); // desc = "Use the x,z coordinate to pick a block from the list"
} //)
return other; // public Pattern linear2d(Actor actor, LocalSession session, Pattern other) {
} //
// if (other instanceof RandomPattern) {
@Command( // Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
name = "#linear2d", // return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
aliases = {"#l2d"}, // }
desc = "Use the x,z coordinate to pick a block from the list" // return other;
) // }
public Pattern linear2d(Actor actor, LocalSession session, Pattern other) { //
// @Command(
if (other instanceof RandomPattern) { // name = "=",
Set<Pattern> patterns = ((RandomPattern) other).getPatterns(); // aliases = {"#=", "#expression"},
return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()])); // desc = "Expression pattern: http://wiki.sk89q.com/wiki/WorldEdit/Expression_syntax"
} //)
return other; // public Pattern expression(Actor actor, LocalSession session, Extent extent, String input) throws ExpressionException {
} //
// Expression exp = Expression.compile(input, "x", "y", "z");
@Command( // WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
name = "=", // exp.setEnvironment(env);
aliases = {"#=", "#expression"}, // return new ExpressionPattern(exp);
desc = "Expression pattern: http://wiki.sk89q.com/wiki/WorldEdit/Expression_syntax" // }
) //}
public Pattern expression(Actor actor, LocalSession session, Extent extent, String input) throws ExpressionException {
Expression exp = Expression.compile(input, "x", "y", "z");
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
exp.setEnvironment(env);
return new ExpressionPattern(exp);
}
}

View File

@ -276,7 +276,7 @@ public class SelectionCommands {
player.print("Left click: jump to location; Right click: pass through walls"); player.print("Left click: jump to location; Right click: pass through walls");
} else { } else {
session.setTool(itemType, new SelectionWand()); session.setTool(itemType, new SelectionWand());
BBC.SELECTION_WAND.send(player); player.print(BBC.SELECTION_WAND.s());
} }
if (!player.hasPermission("fawe.tips")) if (!player.hasPermission("fawe.tips"))
BBC.TIP_SEL_LIST.or(BBC.TIP_SELECT_CONNECTED, BBC.TIP_SET_POS1, BBC.TIP_FARWAND, BBC.TIP_DISCORD).send(player); BBC.TIP_SEL_LIST.or(BBC.TIP_SELECT_CONNECTED, BBC.TIP_SET_POS1, BBC.TIP_FARWAND, BBC.TIP_DISCORD).send(player);
@ -360,7 +360,7 @@ public class SelectionCommands {
session.getRegionSelector(world).explainRegionAdjust(actor, session); session.getRegionSelector(world).explainRegionAdjust(actor, session);
BBC.SELECTION_SHIFT.send(actor); actor.print(BBC.SELECTION_SHIFT.s());
} catch (RegionOperationException e) { } catch (RegionOperationException e) {
actor.printError(e.getMessage()); actor.printError(e.getMessage());
} }
@ -383,7 +383,7 @@ public class SelectionCommands {
region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical)); region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
session.getRegionSelector(world).learnChanges(); session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session); session.getRegionSelector(world).explainRegionAdjust(actor, session);
BBC.SELECTION_OUTSET.send(actor); actor.print(BBC.SELECTION_OUTSET.s());
} }
@Command( @Command(
@ -560,7 +560,7 @@ public class SelectionCommands {
if (selector == null) { if (selector == null) {
session.getRegionSelector(world).clear(); session.getRegionSelector(world).clear();
session.dispatchCUISelection(actor); session.dispatchCUISelection(actor);
BBC.SELECTION_CLEARED.send(actor); actor.print(BBC.SELECTION_CLEARED.s());
return; return;
} }

View File

@ -44,6 +44,7 @@ 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.command.CommandRegistrationHandler; import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
import com.sk89q.worldedit.internal.command.CommandUtil; import com.sk89q.worldedit.internal.command.CommandUtil;
import com.sk89q.worldedit.command.ToolCommandsRegistration;
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.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;

View File

@ -1,104 +1,104 @@
package com.sk89q.worldedit.command; //package com.sk89q.worldedit.command;
//
import com.boydti.fawe.object.extent.Linear3DTransform; //import com.boydti.fawe.object.extent.Linear3DTransform;
import com.boydti.fawe.object.extent.LinearTransform; //import com.boydti.fawe.object.extent.LinearTransform;
import com.boydti.fawe.object.extent.OffsetExtent; //import com.boydti.fawe.object.extent.OffsetExtent;
import com.boydti.fawe.object.extent.PatternTransform; //import com.boydti.fawe.object.extent.PatternTransform;
import com.boydti.fawe.object.extent.RandomOffsetTransform; //import com.boydti.fawe.object.extent.RandomOffsetTransform;
import com.boydti.fawe.object.extent.RandomTransform; //import com.boydti.fawe.object.extent.RandomTransform;
import com.boydti.fawe.object.extent.ResettableExtent; //import com.boydti.fawe.object.extent.ResettableExtent;
import com.boydti.fawe.object.extent.ScaleTransform; //import com.boydti.fawe.object.extent.ScaleTransform;
import com.boydti.fawe.object.extent.TransformExtent; //import com.boydti.fawe.object.extent.TransformExtent;
import com.boydti.fawe.util.ExtentTraverser; //import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.worldedit.LocalSession; //import com.sk89q.worldedit.LocalSession;
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.extension.platform.Actor; //import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.transform.BlockTransformExtent; //import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
import com.sk89q.worldedit.function.pattern.Pattern; //import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.transform.AffineTransform; //import com.sk89q.worldedit.math.transform.AffineTransform;
import java.util.Set; //import java.util.Set;
import org.enginehub.piston.annotation.Command; //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(
name = "#linear", // name = "#linear",
aliases = {"#l"}, // aliases = {"#l"},
desc = "Sequentially pick from a list of transform" // desc = "Sequentially pick from a list of transform"
) // )
public ResettableExtent linear(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { // public ResettableExtent linear(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
if (other instanceof RandomTransform) { // if (other instanceof RandomTransform) {
Set<ResettableExtent> extents = ((RandomTransform) other).getExtents(); // Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
return new LinearTransform(extents.toArray(new ResettableExtent[0])); // return new LinearTransform(extents.toArray(new ResettableExtent[0]));
} // }
return other; // return other;
} // }
//
@Command( // @Command(
name = "#linear3d", // name = "#linear3d",
aliases = {"#l3d"}, // aliases = {"#l3d"},
desc = "Use the x,y,z coordinate to pick a transform from the list" // desc = "Use the x,y,z coordinate to pick a transform from the list"
) // )
public ResettableExtent linear3d(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { // public ResettableExtent linear3d(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
if (other instanceof RandomTransform) { // if (other instanceof RandomTransform) {
Set<ResettableExtent> extents = ((RandomTransform) other).getExtents(); // Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
return new Linear3DTransform(extents.toArray(new ResettableExtent[0])); // return new Linear3DTransform(extents.toArray(new ResettableExtent[0]));
} // }
return other; // return other;
} // }
//
@Command( // @Command(
name = "#pattern", // name = "#pattern",
desc = "Always use a specific pattern" // desc = "Always use a specific pattern"
) // )
public ResettableExtent pattern(Actor actor, LocalSession session, Pattern pattern, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { // public ResettableExtent pattern(Actor actor, LocalSession session, Pattern pattern, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
return new PatternTransform(other, pattern); // return new PatternTransform(other, pattern);
} // }
//
@Command( // @Command(
name = "#offset", // name = "#offset",
desc = "Offset transform" // desc = "Offset transform"
) // )
public ResettableExtent offset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { // public ResettableExtent offset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
return new OffsetExtent(other, (int) x, (int) y, (int) z); // return new OffsetExtent(other, (int) x, (int) y, (int) z);
} // }
//
@Command( // @Command(
name = "#spread", // name = "#spread",
aliases = {"#randomoffset"}, // aliases = {"#randomoffset"},
desc = "Random offset transform" // desc = "Random offset transform"
) //)
public ResettableExtent randomOffset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { // public ResettableExtent randomOffset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
return new RandomOffsetTransform(other, (int) x, (int) y, (int) z); // return new RandomOffsetTransform(other, (int) x, (int) y, (int) z);
} // }
//
@Command( // @Command(
name = "#scale", // name = "#scale",
desc = "All changes will be scaled" // desc = "All changes will be scaled"
) // )
public ResettableExtent scale(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { // public ResettableExtent scale(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
return new ScaleTransform(other, x, y, z); // return new ScaleTransform(other, x, y, z);
} // }
//
@Command( // @Command(
name = "#rotate", // name = "#rotate",
desc = "All changes will be rotate around the initial position" // desc = "All changes will be rotate around the initial position"
) // )
public ResettableExtent rotate(Player player, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) { // public ResettableExtent rotate(Player player, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
ExtentTraverser<TransformExtent> traverser = new ExtentTraverser<>(other).find(TransformExtent.class); // ExtentTraverser<TransformExtent> traverser = new ExtentTraverser<>(other).find(TransformExtent.class);
BlockTransformExtent affine = traverser != null ? traverser.get() : null; // BlockTransformExtent affine = traverser != null ? traverser.get() : null;
if (affine == null) { // if (affine == null) {
other = affine = new TransformExtent(other); // other = affine = new TransformExtent(other);
} // }
AffineTransform transform = (AffineTransform) affine.getTransform(); // AffineTransform transform = (AffineTransform) affine.getTransform();
transform = transform.rotateX(x); // transform = transform.rotateX(x);
transform = transform.rotateY(y); // transform = transform.rotateY(y);
transform = transform.rotateZ(z); // transform = transform.rotateZ(z);
affine.setTransform(transform); // affine.setTransform(transform);
return other; // return other;
} // }
} //}

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.command.argument;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.command.util.HookMode;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ArgumentConverter;
@ -46,6 +47,8 @@ public final class EnumConverter {
full(EditSession.ReorderMode.class, full(EditSession.ReorderMode.class,
r -> ImmutableSet.of(r.getDisplayName()), r -> ImmutableSet.of(r.getDisplayName()),
null)); null));
commandManager.registerConverter(Key.of(HookMode.class),
basic(HookMode.class));
} }
private static <E extends Enum<E>> ArgumentConverter<E> basic(Class<E> enumClass) { private static <E extends Enum<E>> ArgumentConverter<E> basic(Class<E> enumClass) {

View File

@ -61,7 +61,7 @@ public class DelegateCommandManager implements CommandManager {
} }
@Override @Override
public Object execute(InjectedValueAccess context, List<String> args) { public int execute(InjectedValueAccess context, List<String> args) {
return parent.execute(context, args); return parent.execute(context, args);
} }

View File

@ -0,0 +1,24 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.command.util;
public enum HookMode {
ACTIVE, INACTIVE
}

View File

@ -57,13 +57,9 @@ import com.sk89q.worldedit.command.GenerationCommands;
import com.sk89q.worldedit.command.GenerationCommandsRegistration; import com.sk89q.worldedit.command.GenerationCommandsRegistration;
import com.sk89q.worldedit.command.HistoryCommands; import com.sk89q.worldedit.command.HistoryCommands;
import com.sk89q.worldedit.command.HistoryCommandsRegistration; import com.sk89q.worldedit.command.HistoryCommandsRegistration;
import com.sk89q.worldedit.command.MaskCommands;
import com.sk89q.worldedit.command.MaskCommandsRegistration;
import com.sk89q.worldedit.command.NavigationCommands; import com.sk89q.worldedit.command.NavigationCommands;
import com.sk89q.worldedit.command.NavigationCommandsRegistration; import com.sk89q.worldedit.command.NavigationCommandsRegistration;
import com.sk89q.worldedit.command.PaintBrushCommands; import com.sk89q.worldedit.command.PaintBrushCommands;
import com.sk89q.worldedit.command.PatternCommands;
import com.sk89q.worldedit.command.PatternCommandsRegistration;
import com.sk89q.worldedit.command.RegionCommands; import com.sk89q.worldedit.command.RegionCommands;
import com.sk89q.worldedit.command.RegionCommandsRegistration; import com.sk89q.worldedit.command.RegionCommandsRegistration;
import com.sk89q.worldedit.command.SchematicCommands; import com.sk89q.worldedit.command.SchematicCommands;
@ -82,8 +78,6 @@ import com.sk89q.worldedit.command.ToolCommands;
import com.sk89q.worldedit.command.ToolCommandsRegistration; import com.sk89q.worldedit.command.ToolCommandsRegistration;
import com.sk89q.worldedit.command.ToolUtilCommands; import com.sk89q.worldedit.command.ToolUtilCommands;
import com.sk89q.worldedit.command.ToolUtilCommandsRegistration; import com.sk89q.worldedit.command.ToolUtilCommandsRegistration;
import com.sk89q.worldedit.command.TransformCommands;
import com.sk89q.worldedit.command.TransformCommandsRegistration;
import com.sk89q.worldedit.command.UtilityCommands; import com.sk89q.worldedit.command.UtilityCommands;
import com.sk89q.worldedit.command.UtilityCommandsRegistration; import com.sk89q.worldedit.command.UtilityCommandsRegistration;
import com.sk89q.worldedit.command.WorldEditCommands; import com.sk89q.worldedit.command.WorldEditCommands;
@ -201,7 +195,6 @@ public final class PlatformCommandManager {
checkNotNull(worldEdit); checkNotNull(worldEdit);
checkNotNull(platformManager); checkNotNull(platformManager);
INSTANCE = this; INSTANCE = this;
this.worldEdit = worldEdit; this.worldEdit = worldEdit;
this.platformManager = platformManager; this.platformManager = platformManager;
this.exceptionConverter = new WorldEditExceptionConverter(worldEdit); this.exceptionConverter = new WorldEditExceptionConverter(worldEdit);
@ -292,7 +285,6 @@ public final class PlatformCommandManager {
} else { } else {
throw new MissingWorldException(); throw new MissingWorldException();
} }
} catch (MissingWorldException e) { } catch (MissingWorldException e) {
exceptionConverter.convert(e); exceptionConverter.convert(e);
throw new AssertionError("Should have thrown a new exception.", e); throw new AssertionError("Should have thrown a new exception.", e);
@ -324,6 +316,7 @@ public final class PlatformCommandManager {
handler, handler,
instance instance
)); ));
additionalConfig.accept(manager);
final List<Command> subCommands = manager.getAllCommands().collect(Collectors.toList()); final List<Command> subCommands = manager.getAllCommands().collect(Collectors.toList());
cmd.addPart(SubCommandPart.builder(TranslatableComponent.of("worldedit.argument.action"), cmd.addPart(SubCommandPart.builder(TranslatableComponent.of("worldedit.argument.action"),
@ -343,27 +336,27 @@ public final class PlatformCommandManager {
public void registerAllCommands() { public void registerAllCommands() {
if (Settings.IMP.ENABLED_COMPONENTS.COMMANDS) { if (Settings.IMP.ENABLED_COMPONENTS.COMMANDS) {
registerSubCommands( // registerSubCommands(
"patterns", // "patterns",
ImmutableList.of(), // ImmutableList.of(),
"Patterns determine what blocks are placed", // "Patterns determine what blocks are placed",
PatternCommandsRegistration.builder(), // PatternCommandsRegistration.builder(),
new PatternCommands() // new PatternCommands()
); // );
registerSubCommands( // registerSubCommands(
"masks", // "masks",
ImmutableList.of(), // ImmutableList.of(),
"Masks determine which blocks are placed", // "Masks determine which blocks are placed",
MaskCommandsRegistration.builder(), // MaskCommandsRegistration.builder(),
new MaskCommands(worldEdit) // new MaskCommands(worldEdit)
); // );
registerSubCommands( // registerSubCommands(
"transforms", // "transforms",
ImmutableList.of(), // ImmutableList.of(),
"Transforms modify how a block is placed", // "Transforms modify how a block is placed",
TransformCommandsRegistration.builder(), // TransformCommandsRegistration.builder(),
new TransformCommands() // new TransformCommands()
); // );
registerSubCommands( registerSubCommands(
"schematic", "schematic",
ImmutableList.of("schem", "/schematic", "/schem"), ImmutableList.of("schem", "/schematic", "/schem"),
@ -476,11 +469,7 @@ public final class PlatformCommandManager {
SnapshotUtilCommandsRegistration.builder(), SnapshotUtilCommandsRegistration.builder(),
new SnapshotUtilCommands(worldEdit) new SnapshotUtilCommands(worldEdit)
); );
this.registration.register( ToolCommands.register(registration, commandManager, commandManagerService, worldEdit);
commandManager,
ToolCommandsRegistration.builder(),
new ToolCommands(worldEdit)
);
this.registration.register( this.registration.register(
commandManager, commandManager,
ToolUtilCommandsRegistration.builder(), ToolUtilCommandsRegistration.builder(),
@ -505,13 +494,6 @@ public final class PlatformCommandManager {
void registerCommandsWith(Platform platform) { void registerCommandsWith(Platform platform) {
log.info("Registering commands with " + platform.getClass().getCanonicalName()); log.info("Registering commands with " + platform.getClass().getCanonicalName());
// Delay command registration to allow time for other plugins to hook into FAWE
try {
// new CommandScriptLoader().load();
} catch (Throwable e) {
e.printStackTrace();
}
LocalConfiguration config = platform.getConfiguration(); LocalConfiguration config = platform.getConfiguration();
boolean logging = config.logCommands; boolean logging = config.logCommands;
String path = config.logFile; String path = config.logFile;
@ -536,7 +518,6 @@ public final class PlatformCommandManager {
} }
platform.registerCommands(commandManager); platform.registerCommands(commandManager);
// commandManager.getCommand("pattern").get()
} }
void removeCommands() { void removeCommands() {
@ -544,7 +525,7 @@ public final class PlatformCommandManager {
} }
private Stream<Substring> parseArgs(String input) { private Stream<Substring> parseArgs(String input) {
return new CommandArgParser(CommandArgParser.spaceSplit(input)).parseArgs(); return CommandArgParser.forArgString(input.substring(1)).parseArgs();
} }
public <T> Collection<T> parse(Class<T> clazz, String arguments, @Nullable Actor actor) { public <T> Collection<T> parse(Class<T> clazz, String arguments, @Nullable Actor actor) {