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("http://empcraft.com/maven2") }
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")
patternLayout {
artifact("/[organisation]/[revision]/artifact/[module].[ext]")
@ -24,5 +23,4 @@ fun Project.applyCommonConfiguration() {
cacheChangingModulesFor(10, "minutes")
}
}
}

View File

@ -20,7 +20,7 @@
package com.sk89q.worldedit.bukkit;
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.worldedit.extension.platform.Actor;

View File

@ -19,7 +19,7 @@
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.CommandRegistration;

View File

@ -43,8 +43,8 @@ public class CFICommand extends CommandProcessor<Object, Object> {
}
@Override
public Object process(InjectedValueAccess context, List<String> args, Object result) {
return result;
public int process(InjectedValueAccess context, List<String> args, Object result) {
return 0;
}
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
public final Object execute(InjectedValueAccess context, List<String> args) {
public final int execute(InjectedValueAccess context, List<String> args) {
args = preprocess(context, args);
if (args != null) {
Object result = parent.execute(context, args);
return process(context, args, result); // TODO NOT IMPLEMENTED (recompile piston)
} 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 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.Logging;
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.mask.Mask;
import com.sk89q.worldedit.function.operation.Operations;
@ -270,17 +271,18 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.forest")
@Logging(POSITION)
public int forestGen(Player player, LocalSession session, EditSession editSession,
@Arg(name = "size", desc = "The size of the forest, in blocks", def = "10")
int sizeOpt,
public int forestGen(Actor actor, LocalSession session, EditSession editSession,
@Arg(desc = "The size of the forest, in blocks", def = "10")
int size,
@Arg(desc = "The type of forest", def = "tree")
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 {
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
worldEdit.checkMaxRadius(size);
density /= 100;
int affected = editSession.makeForest(session.getPlacementPosition(player), sizeOpt, density, type);
player.print(affected + " trees created.");
int affected = editSession.makeForest(session.getPlacementPosition(actor), size, density, type);
actor.print(affected + " trees created.");
return affected;
}
@ -290,16 +292,17 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.pumpkins")
@Logging(POSITION)
public int pumpkins(Player player, LocalSession session, EditSession editSession,
@Arg(name = "size", desc = "The size of the patch", def = "10")
int sizeOpt,
public int pumpkins(Actor actor, LocalSession session, EditSession editSession,
@Arg(desc = "The size of the patch", def = "10")
int size,
@Arg(desc = "//TODO", def = "10")
int apothem,
@Arg(desc = "//TODO ", def = "0.02")
double density) throws WorldEditException {
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), apothem, density);
BBC.COMMAND_PUMPKIN.send(player, affected);
worldEdit.checkMaxRadius(size);
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(actor), apothem, density);
BBC.COMMAND_PUMPKIN.send(actor, affected);
return affected;
}

View File

@ -1,448 +1,448 @@
package com.sk89q.worldedit.command;
import com.boydti.fawe.object.mask.AdjacentAnyMask;
import com.boydti.fawe.object.mask.AdjacentMask;
import com.boydti.fawe.object.mask.AngleMask;
import com.boydti.fawe.object.mask.BiomeMask;
import com.boydti.fawe.object.mask.BlockLightMask;
import com.boydti.fawe.object.mask.BrightnessMask;
import com.boydti.fawe.object.mask.DataMask;
import com.boydti.fawe.object.mask.ExtremaMask;
import com.boydti.fawe.object.mask.IdDataMask;
import com.boydti.fawe.object.mask.IdMask;
import com.boydti.fawe.object.mask.LightMask;
import com.boydti.fawe.object.mask.OpacityMask;
import com.boydti.fawe.object.mask.ROCAngleMask;
import com.boydti.fawe.object.mask.RadiusMask;
import com.boydti.fawe.object.mask.RandomMask;
import com.boydti.fawe.object.mask.SimplexMask;
import com.boydti.fawe.object.mask.SkyLightMask;
import com.boydti.fawe.object.mask.SurfaceMask;
import com.boydti.fawe.object.mask.WallMask;
import com.boydti.fawe.object.mask.XAxisMask;
import com.boydti.fawe.object.mask.YAxisMask;
import com.boydti.fawe.object.mask.ZAxisMask;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.ExpressionMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.mask.MaskUnion;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.mask.OffsetMask;
import com.sk89q.worldedit.function.mask.RegionMask;
import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
import com.sk89q.worldedit.session.request.RequestSelection;
import com.sk89q.worldedit.world.biome.BiomeType;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.Switch;
//@Command(aliases = {"masks"},
// desc = "Help for the various masks. [More Info](https://git.io/v9r4K)",
// descFooter = "Masks determine if a block can be placed\n" +
// " - Use [brackets] for arguments\n" +
// " - Use , to OR multiple\n" +
// " - Use & to AND multiple\n" +
// "e.g. >[stone,dirt],#light[0][5],$jungle\n" +
// "More Info: https://git.io/v9r4K"
//package com.sk89q.worldedit.command;
//
//import com.boydti.fawe.object.mask.AdjacentAnyMask;
//import com.boydti.fawe.object.mask.AdjacentMask;
//import com.boydti.fawe.object.mask.AngleMask;
//import com.boydti.fawe.object.mask.BiomeMask;
//import com.boydti.fawe.object.mask.BlockLightMask;
//import com.boydti.fawe.object.mask.BrightnessMask;
//import com.boydti.fawe.object.mask.DataMask;
//import com.boydti.fawe.object.mask.ExtremaMask;
//import com.boydti.fawe.object.mask.IdDataMask;
//import com.boydti.fawe.object.mask.IdMask;
//import com.boydti.fawe.object.mask.LightMask;
//import com.boydti.fawe.object.mask.OpacityMask;
//import com.boydti.fawe.object.mask.ROCAngleMask;
//import com.boydti.fawe.object.mask.RadiusMask;
//import com.boydti.fawe.object.mask.RandomMask;
//import com.boydti.fawe.object.mask.SimplexMask;
//import com.boydti.fawe.object.mask.SkyLightMask;
//import com.boydti.fawe.object.mask.SurfaceMask;
//import com.boydti.fawe.object.mask.WallMask;
//import com.boydti.fawe.object.mask.XAxisMask;
//import com.boydti.fawe.object.mask.YAxisMask;
//import com.boydti.fawe.object.mask.ZAxisMask;
//import com.sk89q.worldedit.IncompleteRegionException;
//import com.sk89q.worldedit.LocalSession;
//import com.sk89q.worldedit.WorldEdit;
//import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
//import com.sk89q.worldedit.entity.Player;
//import com.sk89q.worldedit.extent.Extent;
//import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
//import com.sk89q.worldedit.function.mask.ExistingBlockMask;
//import com.sk89q.worldedit.function.mask.ExpressionMask;
//import com.sk89q.worldedit.function.mask.Mask;
//import com.sk89q.worldedit.function.mask.MaskIntersection;
//import com.sk89q.worldedit.function.mask.MaskUnion;
//import com.sk89q.worldedit.function.mask.Masks;
//import com.sk89q.worldedit.function.mask.OffsetMask;
//import com.sk89q.worldedit.function.mask.RegionMask;
//import com.sk89q.worldedit.function.mask.SolidBlockMask;
//import com.sk89q.worldedit.internal.expression.Expression;
//import com.sk89q.worldedit.internal.expression.ExpressionException;
//import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
//import com.sk89q.worldedit.math.BlockVector3;
//import com.sk89q.worldedit.math.Vector3;
//import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
//import com.sk89q.worldedit.session.request.RequestSelection;
//import com.sk89q.worldedit.world.biome.BiomeType;
//import org.enginehub.piston.annotation.Command;
//import org.enginehub.piston.annotation.CommandContainer;
//import org.enginehub.piston.annotation.param.Arg;
//import org.enginehub.piston.annotation.param.Switch;
//
////@Command(aliases = {"masks"},
//// desc = "Help for the various masks. [More Info](https://git.io/v9r4K)",
//// descFooter = "Masks determine if a block can be placed\n" +
//// " - Use [brackets] for arguments\n" +
//// " - Use , to OR multiple\n" +
//// " - Use & to AND multiple\n" +
//// "e.g. >[stone,dirt],#light[0][5],$jungle\n" +
//// "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"
// )
// 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);
// minInt = (minInt - 50) / 50;
// maxInt = (maxInt - 50) / 50;
// return new SimplexMask(scale, minInt, maxInt);
// }
//
// @Command(
// name = "#light",
// desc = "Restrict to specific light levels"
// )
// public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
// return new LightMask(extent, (int) minInt, (int) maxInt);
// }
//
// @Command(
// name = "#false",
// desc = "Always false"
// )
// public Mask falseMask(Extent extent) {
// return Masks.alwaysFalse();
// }
//
// @Command(
// name = "#true",
// desc = "Always true"
// )
// public Mask trueMask(Extent extent) {
// return Masks.alwaysTrue();
// }
//
// @Command(
// name = "#skylight",
// desc = "Restrict to specific sky light levels"
// )
// 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 = "#blocklight",
// aliases = {"#emittedlight"},
// 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) {
// return new BlockLightMask(extent, (int) minInt, (int) maxInt);
// }
//
// @Command(
// name = "#opacity",
// 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) {
// return new OpacityMask(extent, (int) minInt, (int) maxInt);
// }
//
// @Command(
// name = "#brightness",
// 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) {
// return new BrightnessMask(extent, (int) minInt, (int) maxInt);
// }
//
// @Command(
// name = "#offset",
// desc = "Offset a mask"
// )
// public Mask offset(double x, double y, double z, Mask mask) {
// return new OffsetMask(mask, BlockVector3.at(x, y, z));
// }
//
// @Command(
// name = "#haslight",
// desc = "Restricts to blocks with light (sky or emitted)"
// )
// public Mask haslight(Extent extent) {
// return new LightMask(extent, 1, Integer.MAX_VALUE);
// }
//
// @Command(
// name = "#nolight",
// desc = "Restrict to blocks without light (sky or emitted)"
// )
// public Mask nolight(Extent extent) {
// return new LightMask(extent, 0, 0);
// }
//
// @Command(
// name = "#existing",
// desc = "If there is a non air block"
// )
// public Mask existing(Extent extent) {
// return new ExistingBlockMask(extent);
// }
//
// @Command(
// name = "#solid",
// desc = "If there is a solid block"
// )
// public Mask solid(Extent extent) {
// return new SolidBlockMask(extent);
// }
//
// @Command(
// name = "#liquid",
// desc = "If there is a solid block"
// )
// public Mask liquid(Extent extent) {
// return new BlockMaskBuilder().addAll(b -> b.getMaterial().isLiquid()).build(extent);
// }
//
// @Command(
// name = "#dregion",
// aliases = {"#dselection", "#dsel"},
// desc = "inside the player's selection"
// )
// public Mask dregion() {
// return new RegionMask(new RequestSelection());
// }
//
// @Command(
// name = "#region",
// aliases = {"#selection", "#sel"},
// desc = "inside the provided selection"
// )
// public Mask selection(Player player, LocalSession session) throws IncompleteRegionException {
// return new RegionMask(session.getSelection(player.getWorld()).clone());
// }
//
// @Command(
// name = "#xaxis",
// desc = "Restrict to initial x axis"
// )
// public Mask xaxis() {
// return new XAxisMask();
// }
//
// @Command(
// name = "#yaxis",
// desc = "Restrict to initial y axis"
// )
// public Mask yaxis() {
// return new YAxisMask();
// }
//
// @Command(
// name = "#zaxis",
// desc = "Restrict to initial z axis"
// )
// public Mask zaxis() {
// return new ZAxisMask();
// }
//
// @Command(
// name = "#id",
// desc = "Restrict to initial id"
// )
// public Mask id(Extent extent) {
// return new IdMask(extent);
// }
//
// @Command(
// name = "#data",
// desc = "Restrict to initial data"
// )
// public Mask data(Extent extent) {
// return new DataMask(extent);
// }
//
// @Command(
// name = "#iddata",
// desc = "Restrict to initial block id and data"
// )
// public Mask iddata(Extent extent) {
// return new IdDataMask(extent);
// }
//
// @Command(
// name = "#air",
// desc = "Restrict to types of air"
// )
// public Mask air(Extent extent) {
// return new BlockMaskBuilder().addAll(b -> b.getMaterial().isAir()).build(extent);
// }
//
// @Command(
// name = "#wall",
// desc = "Restrict to walls (any block n,e,s,w of air)"
// )
// public Mask wall(Extent extent) {
// Mask blockMask = air(extent);
// return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8));
// }
//
// @Command(
// name = "#surface",
// desc = "Restrict to surfaces (any solid block touching air)"
// )
// public Mask surface(Extent extent) {
// return new SurfaceMask(extent);
// }
//
// @Command(
// name = "\\",
// aliases = {"/", "#angle", "#\\", "#/"},
// desc = "Restrict to specific terrain angle",
// descFooter = "Restrict to specific terrain angle\n" +
// "The -o flag will only overlay\n" +
// "Example: /[0d][45d]\n" +
// "Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" +
// "Example: /[3][20]\n" +
// "Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below"
//)
@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"
)
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);
minInt = (minInt - 50) / 50;
maxInt = (maxInt - 50) / 50;
return new SimplexMask(scale, minInt, maxInt);
}
@Command(
name = "#light",
desc = "Restrict to specific light levels"
)
public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
return new LightMask(extent, (int) minInt, (int) maxInt);
}
@Command(
name = "#false",
desc = "Always false"
)
public Mask falseMask(Extent extent) {
return Masks.alwaysFalse();
}
@Command(
name = "#true",
desc = "Always true"
)
public Mask trueMask(Extent extent) {
return Masks.alwaysTrue();
}
@Command(
name = "#skylight",
desc = "Restrict to specific sky light levels"
)
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 = "#blocklight",
aliases = {"#emittedlight"},
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) {
return new BlockLightMask(extent, (int) minInt, (int) maxInt);
}
@Command(
name = "#opacity",
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) {
return new OpacityMask(extent, (int) minInt, (int) maxInt);
}
@Command(
name = "#brightness",
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) {
return new BrightnessMask(extent, (int) minInt, (int) maxInt);
}
@Command(
name = "#offset",
desc = "Offset a mask"
)
public Mask offset(double x, double y, double z, Mask mask) {
return new OffsetMask(mask, BlockVector3.at(x, y, z));
}
@Command(
name = "#haslight",
desc = "Restricts to blocks with light (sky or emitted)"
)
public Mask haslight(Extent extent) {
return new LightMask(extent, 1, Integer.MAX_VALUE);
}
@Command(
name = "#nolight",
desc = "Restrict to blocks without light (sky or emitted)"
)
public Mask nolight(Extent extent) {
return new LightMask(extent, 0, 0);
}
@Command(
name = "#existing",
desc = "If there is a non air block"
)
public Mask existing(Extent extent) {
return new ExistingBlockMask(extent);
}
@Command(
name = "#solid",
desc = "If there is a solid block"
)
public Mask solid(Extent extent) {
return new SolidBlockMask(extent);
}
@Command(
name = "#liquid",
desc = "If there is a solid block"
)
public Mask liquid(Extent extent) {
return new BlockMaskBuilder().addAll(b -> b.getMaterial().isLiquid()).build(extent);
}
@Command(
name = "#dregion",
aliases = {"#dselection", "#dsel"},
desc = "inside the player's selection"
)
public Mask dregion() {
return new RegionMask(new RequestSelection());
}
@Command(
name = "#region",
aliases = {"#selection", "#sel"},
desc = "inside the provided selection"
)
public Mask selection(Player player, LocalSession session) throws IncompleteRegionException {
return new RegionMask(session.getSelection(player.getWorld()).clone());
}
@Command(
name = "#xaxis",
desc = "Restrict to initial x axis"
)
public Mask xaxis() {
return new XAxisMask();
}
@Command(
name = "#yaxis",
desc = "Restrict to initial y axis"
)
public Mask yaxis() {
return new YAxisMask();
}
@Command(
name = "#zaxis",
desc = "Restrict to initial z axis"
)
public Mask zaxis() {
return new ZAxisMask();
}
@Command(
name = "#id",
desc = "Restrict to initial id"
)
public Mask id(Extent extent) {
return new IdMask(extent);
}
@Command(
name = "#data",
desc = "Restrict to initial data"
)
public Mask data(Extent extent) {
return new DataMask(extent);
}
@Command(
name = "#iddata",
desc = "Restrict to initial block id and data"
)
public Mask iddata(Extent extent) {
return new IdDataMask(extent);
}
@Command(
name = "#air",
desc = "Restrict to types of air"
)
public Mask air(Extent extent) {
return new BlockMaskBuilder().addAll(b -> b.getMaterial().isAir()).build(extent);
}
@Command(
name = "#wall",
desc = "Restrict to walls (any block n,e,s,w of air)"
)
public Mask wall(Extent extent) {
Mask blockMask = air(extent);
return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8));
}
@Command(
name = "#surface",
desc = "Restrict to surfaces (any solid block touching air)"
)
public Mask surface(Extent extent) {
return new SurfaceMask(extent);
}
@Command(
name = "\\",
aliases = {"/", "#angle", "#\\", "#/"},
desc = "Restrict to specific terrain angle",
descFooter = "Restrict to specific terrain angle\n" +
"The -o flag will only overlay\n" +
"Example: /[0d][45d]\n" +
"Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" +
"Example: /[3][20]\n" +
"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 {
double y1, y2;
boolean override;
if (maxStr.endsWith("d")) {
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
y1 = Math.tan(y1d * (Math.PI / 180));
y2 = Math.tan(y2d * (Math.PI / 180));
} else {
y1 = Expression.compile(minStr).evaluate();
y2 = Expression.compile(maxStr).evaluate();
}
return new AngleMask(extent, y1, y2, overlay, distanceOpt);
}
@Command(
name = "(",
aliases = {")", "#roc", "#(", "#)"},
desc = "Restrict to near specific terrain slope rate of change",
descFooter = "Restrict to near specific terrain slope rate of change\n" +
"The -o flag will only overlay\n" +
"Example: ([0d][45d][5]\n" +
"Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" +
"Note: Use negatives for decreasing slope"
)
public Mask roc(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
double y1, y2;
boolean override;
if (maxStr.endsWith("d")) {
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
y1 = Math.tan(y1d * (Math.PI / 180));
y2 = Math.tan(y2d * (Math.PI / 180));
} else {
y1 = Expression.compile(minStr).evaluate();
y2 = Expression.compile(maxStr).evaluate();
}
return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt);
}
@Command(
name = "^",
aliases = {"#extrema", "#^"},
desc = "Restrict to near specific terrain extrema",
descFooter = "Restrict to near specific terrain extrema\n" +
"The -o flag will only overlay\n" +
"Example: ([0d][45d][5]\n" +
"Explanation: Restrict to near 45 degrees of local maxima\n" +
"Note: Use negatives for local minima"
)
public Mask extrema(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
double y1, y2;
boolean override;
if (maxStr.endsWith("d")) {
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
y1 = Math.tan(y1d * (Math.PI / 180));
y2 = Math.tan(y2d * (Math.PI / 180));
} else {
y1 = Expression.compile(minStr).evaluate();
y2 = Expression.compile(maxStr).evaluate();
}
return new ExtremaMask(extent, y1, y2, overlay, distanceOpt);
}
@Command(
name = "{",
aliases = {"#{"},
desc = "Restricts blocks to within a specific radius range of the initial block"
)
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 = {"#|", "#side"},
desc = "sides with a specific number of other blocks"
)
public Mask wall(Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
return new WallMask(mask, (int) minInt, (int) maxInt);
}
@Command(
name = "~",
aliases = {"#~", "#adjacent"},
desc = "Adjacent to a specific number of other blocks"
)
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 {
if (min == -1 && max == -1) {
min = 1;
max = 8;
} else if (max == -1) max = min;
if (max >= 8 && min == 1) {
return new AdjacentAnyMask(mask);
}
return new AdjacentMask(mask, (int) min, (int) max);
}
@Command(
name = "<",
aliases = {"#<", "#below"},
desc = "below a specific block"
)
public Mask below(Mask mask) throws ExpressionException {
OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0));
return new MaskIntersection(offsetMask, Masks.negate(mask));
}
@Command(
name = ">",
aliases = {"#>", "#above"},
desc = "above a specific block"
)
public Mask above(Mask mask) throws ExpressionException {
OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0));
return new MaskIntersection(offsetMask, Masks.negate(mask));
}
@Command(
name = "$",
aliases = {"#biome", "#$"},
desc = "in a specific biome",
descFooter = "in a specific biome. For a list of biomes use //biomelist"
)
public Mask biome(Extent extent, BiomeType biome) throws ExpressionException {
return new BiomeMask(extent, biome);
}
@Command(
name = "%",
aliases = {"#%", "#percent"},
desc = "percentage chance"
)
public Mask random(double chance) throws ExpressionException {
chance = chance / 100;
return new RandomMask(chance);
}
@Command(
name = "=",
aliases = {"#=", "#expression"},
desc = "expression mask"
)
public Mask expression(Extent extent, String input) throws ExpressionException {
Expression exp = Expression.compile(input, "x", "y", "z");
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);
}
}
// public Mask angle(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) throws ExpressionException {
// double y1, y2;
// boolean override;
// if (maxStr.endsWith("d")) {
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
// y1 = Math.tan(y1d * (Math.PI / 180));
// y2 = Math.tan(y2d * (Math.PI / 180));
// } else {
// y1 = Expression.compile(minStr).evaluate();
// y2 = Expression.compile(maxStr).evaluate();
// }
// return new AngleMask(extent, y1, y2, overlay, distanceOpt);
// }
//
// @Command(
// name = "(",
// aliases = {")", "#roc", "#(", "#)"},
// desc = "Restrict to near specific terrain slope rate of change",
// descFooter = "Restrict to near specific terrain slope rate of change\n" +
// "The -o flag will only overlay\n" +
// "Example: ([0d][45d][5]\n" +
// "Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" +
// "Note: Use negatives for decreasing slope"
//)
// public Mask roc(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
// double y1, y2;
// boolean override;
// if (maxStr.endsWith("d")) {
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
// y1 = Math.tan(y1d * (Math.PI / 180));
// y2 = Math.tan(y2d * (Math.PI / 180));
// } else {
// y1 = Expression.compile(minStr).evaluate();
// y2 = Expression.compile(maxStr).evaluate();
// }
// return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt);
// }
//
// @Command(
// name = "^",
// aliases = {"#extrema", "#^"},
// desc = "Restrict to near specific terrain extrema",
// descFooter = "Restrict to near specific terrain extrema\n" +
// "The -o flag will only overlay\n" +
// "Example: ([0d][45d][5]\n" +
// "Explanation: Restrict to near 45 degrees of local maxima\n" +
// "Note: Use negatives for local minima"
//)
// public Mask extrema(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
// double y1, y2;
// boolean override;
// if (maxStr.endsWith("d")) {
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
// y1 = Math.tan(y1d * (Math.PI / 180));
// y2 = Math.tan(y2d * (Math.PI / 180));
// } else {
// y1 = Expression.compile(minStr).evaluate();
// y2 = Expression.compile(maxStr).evaluate();
// }
// return new ExtremaMask(extent, y1, y2, overlay, distanceOpt);
// }
//
// @Command(
// name = "{",
// aliases = {"#{"},
// desc = "Restricts blocks to within a specific radius range of the initial block"
//)
// 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 = {"#|", "#side"},
// desc = "sides with a specific number of other blocks"
//)
// public Mask wall(Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
// return new WallMask(mask, (int) minInt, (int) maxInt);
// }
//
// @Command(
// name = "~",
// aliases = {"#~", "#adjacent"},
// desc = "Adjacent to a specific number of other blocks"
//)
// 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 {
// if (min == -1 && max == -1) {
// min = 1;
// max = 8;
// } else if (max == -1) max = min;
// if (max >= 8 && min == 1) {
// return new AdjacentAnyMask(mask);
// }
// return new AdjacentMask(mask, (int) min, (int) max);
// }
//
// @Command(
// name = "<",
// aliases = {"#<", "#below"},
// desc = "below a specific block"
//)
// public Mask below(Mask mask) throws ExpressionException {
// OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0));
// return new MaskIntersection(offsetMask, Masks.negate(mask));
// }
//
// @Command(
// name = ">",
// aliases = {"#>", "#above"},
// desc = "above a specific block"
//)
// public Mask above(Mask mask) throws ExpressionException {
// OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0));
// return new MaskIntersection(offsetMask, Masks.negate(mask));
// }
//
// @Command(
// name = "$",
// aliases = {"#biome", "#$"},
// desc = "in a specific biome",
// descFooter = "in a specific biome. For a list of biomes use //biomelist"
//)
// public Mask biome(Extent extent, BiomeType biome) throws ExpressionException {
// return new BiomeMask(extent, biome);
// }
//
// @Command(
// name = "%",
// aliases = {"#%", "#percent"},
// desc = "percentage chance"
//)
// public Mask random(double chance) throws ExpressionException {
// chance = chance / 100;
// return new RandomMask(chance);
// }
//
// @Command(
// name = "=",
// aliases = {"#=", "#expression"},
// desc = "expression mask"
//)
// public Mask expression(Extent extent, String input) throws ExpressionException {
// Expression exp = Expression.compile(input, "x", "y", "z");
// 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;
import com.boydti.fawe.object.DataAnglePattern;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.boydti.fawe.object.collection.RandomCollection;
import com.boydti.fawe.object.pattern.AngleColorPattern;
import com.boydti.fawe.object.pattern.AverageColorPattern;
import com.boydti.fawe.object.pattern.BiomePattern;
import com.boydti.fawe.object.pattern.BufferedPattern;
import com.boydti.fawe.object.pattern.BufferedPattern2D;
import com.boydti.fawe.object.pattern.DataPattern;
import com.boydti.fawe.object.pattern.DesaturatePattern;
import com.boydti.fawe.object.pattern.ExistingPattern;
import com.boydti.fawe.object.pattern.ExpressionPattern;
import com.boydti.fawe.object.pattern.FullClipboardPattern;
import com.boydti.fawe.object.pattern.IdDataMaskPattern;
import com.boydti.fawe.object.pattern.IdPattern;
import com.boydti.fawe.object.pattern.Linear2DBlockPattern;
import com.boydti.fawe.object.pattern.Linear3DBlockPattern;
import com.boydti.fawe.object.pattern.LinearBlockPattern;
import com.boydti.fawe.object.pattern.MaskedPattern;
import com.boydti.fawe.object.pattern.NoXPattern;
import com.boydti.fawe.object.pattern.NoYPattern;
import com.boydti.fawe.object.pattern.NoZPattern;
import com.boydti.fawe.object.pattern.OffsetPattern;
import com.boydti.fawe.object.pattern.PropertyPattern;
import com.boydti.fawe.object.pattern.RandomFullClipboardPattern;
import com.boydti.fawe.object.pattern.RandomOffsetPattern;
import com.boydti.fawe.object.pattern.RelativePattern;
import com.boydti.fawe.object.pattern.SaturatePattern;
import com.boydti.fawe.object.pattern.ShadePattern;
import com.boydti.fawe.object.pattern.SolidRandomOffsetPattern;
import com.boydti.fawe.object.pattern.SurfaceRandomOffsetPattern;
import com.boydti.fawe.object.random.SimplexRandom;
import com.boydti.fawe.util.ColorUtil;
import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.ClipboardPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.RandomPattern;
import com.sk89q.worldedit.internal.annotation.Range;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.biome.BiomeType;
import java.awt.Color;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
//@Command(aliases = {"patterns"},
// desc = "Help for the various patterns. [More Info](https://git.io/vSPmA)",
// descFooter = "Patterns determine what blocks are placed\n" +
// " - Use [brackets] for arguments\n" +
// " - Use , to OR multiple\n" +
// "e.g. #surfacespread[10][#existing],andesite\n" +
// "More Info: https://git.io/vSPmA"
//package com.sk89q.worldedit.command;
//
//import com.boydti.fawe.object.DataAnglePattern;
//import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
//import com.boydti.fawe.object.collection.RandomCollection;
//import com.boydti.fawe.object.pattern.AngleColorPattern;
//import com.boydti.fawe.object.pattern.AverageColorPattern;
//import com.boydti.fawe.object.pattern.BiomePattern;
//import com.boydti.fawe.object.pattern.BufferedPattern;
//import com.boydti.fawe.object.pattern.BufferedPattern2D;
//import com.boydti.fawe.object.pattern.DataPattern;
//import com.boydti.fawe.object.pattern.DesaturatePattern;
//import com.boydti.fawe.object.pattern.ExistingPattern;
//import com.boydti.fawe.object.pattern.ExpressionPattern;
//import com.boydti.fawe.object.pattern.FullClipboardPattern;
//import com.boydti.fawe.object.pattern.IdDataMaskPattern;
//import com.boydti.fawe.object.pattern.IdPattern;
//import com.boydti.fawe.object.pattern.Linear2DBlockPattern;
//import com.boydti.fawe.object.pattern.Linear3DBlockPattern;
//import com.boydti.fawe.object.pattern.LinearBlockPattern;
//import com.boydti.fawe.object.pattern.MaskedPattern;
//import com.boydti.fawe.object.pattern.NoXPattern;
//import com.boydti.fawe.object.pattern.NoYPattern;
//import com.boydti.fawe.object.pattern.NoZPattern;
//import com.boydti.fawe.object.pattern.OffsetPattern;
//import com.boydti.fawe.object.pattern.PropertyPattern;
//import com.boydti.fawe.object.pattern.RandomFullClipboardPattern;
//import com.boydti.fawe.object.pattern.RandomOffsetPattern;
//import com.boydti.fawe.object.pattern.RelativePattern;
//import com.boydti.fawe.object.pattern.SaturatePattern;
//import com.boydti.fawe.object.pattern.ShadePattern;
//import com.boydti.fawe.object.pattern.SolidRandomOffsetPattern;
//import com.boydti.fawe.object.pattern.SurfaceRandomOffsetPattern;
//import com.boydti.fawe.object.random.SimplexRandom;
//import com.boydti.fawe.util.ColorUtil;
//import com.boydti.fawe.util.TextureUtil;
//import com.sk89q.worldedit.EmptyClipboardException;
//import com.sk89q.worldedit.LocalSession;
//import com.sk89q.worldedit.entity.Player;
//import com.sk89q.worldedit.extension.input.InputParseException;
//import com.sk89q.worldedit.extension.platform.Actor;
//import com.sk89q.worldedit.extent.Extent;
//import com.sk89q.worldedit.extent.clipboard.Clipboard;
//import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
//import com.sk89q.worldedit.function.mask.Mask;
//import com.sk89q.worldedit.function.pattern.ClipboardPattern;
//import com.sk89q.worldedit.function.pattern.Pattern;
//import com.sk89q.worldedit.function.pattern.RandomPattern;
//import com.sk89q.worldedit.internal.annotation.Range;
//import com.sk89q.worldedit.internal.expression.Expression;
//import com.sk89q.worldedit.internal.expression.ExpressionException;
//import com.sk89q.worldedit.math.Vector3;
//import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
//import com.sk89q.worldedit.session.ClipboardHolder;
//import com.sk89q.worldedit.world.biome.BiomeType;
//import java.awt.Color;
//import java.io.IOException;
//import java.util.Collections;
//import java.util.List;
//import java.util.Set;
//import org.enginehub.piston.annotation.Command;
//import org.enginehub.piston.annotation.CommandContainer;
//import org.enginehub.piston.annotation.param.Arg;
//
////@Command(aliases = {"patterns"},
//// desc = "Help for the various patterns. [More Info](https://git.io/vSPmA)",
//// descFooter = "Patterns determine what blocks are placed\n" +
//// " - Use [brackets] for arguments\n" +
//// " - Use , to OR multiple\n" +
//// "e.g. #surfacespread[10][#existing],andesite\n" +
//// "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"
// )
// public Pattern existing(Extent extent, @Arg(name = "properties", desc = "String", def = "") String properties) { // TODO FIXME , @Arg(name = "properties", desc = "String", def = "") String properties
// if (properties == null) return new ExistingPattern(extent);
// return new PropertyPattern(extent).addRegex(".*[" + properties + "]");
// }
//
// @Command(
// name = "#clipboard",
// aliases = {"#copy"},
// desc = "Use the blocks in your clipboard as the pattern")
// public Pattern clipboard(LocalSession session) throws EmptyClipboardException {
// ClipboardHolder holder = session.getClipboard();
// Clipboard clipboard = holder.getClipboard();
// return new ClipboardPattern(clipboard);
// }
//
// @Command(
// name = "#simplex",
// desc = "Use simplex noise to randomize blocks. Tutorial: https://imgur.com/a/rwVAE"
//)
@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class PatternCommands {
@Command(
name = "#existing",
aliases = {"#*", "*", ".*"},
desc = "Use the block that is already there"
)
public Pattern existing(Extent extent, @Arg(name = "properties", desc = "String", def = "") String properties) { // TODO FIXME , @Arg(name = "properties", desc = "String", def = "") String properties
if (properties == null) return new ExistingPattern(extent);
return new PropertyPattern(extent).addRegex(".*[" + properties + "]");
}
@Command(
name = "#clipboard",
aliases = {"#copy"},
desc = "Use the blocks in your clipboard as the pattern")
public Pattern clipboard(LocalSession session) throws EmptyClipboardException {
ClipboardHolder holder = session.getClipboard();
Clipboard clipboard = holder.getClipboard();
return new ClipboardPattern(clipboard);
}
@Command(
name = "#simplex",
desc = "Use simplex noise to randomize blocks. Tutorial: https://imgur.com/a/rwVAE"
)
public Pattern simplex(@Arg(desc = "scale factor") double scale, Pattern other) {
if (other instanceof RandomPattern) {
scale = (1d / Math.max(1, scale));
RandomCollection<Pattern> collection = ((RandomPattern) other).getCollection();
collection.setRandom(new SimplexRandom(scale));
}
return other;
}
@Command(
name = "#color",
desc = "Use the block closest to a specific color"
)
public Pattern color(TextureUtil textureUtil, String color) {
Color colorObj = ColorUtil.parseColor(color);
return textureUtil.getNearestBlock(colorObj.getRGB()).getDefaultState();
}
@Command(
name = "#anglecolor",
desc = "A darker block based on the existing terrain angle"
)
public Pattern anglecolor(Extent extent, LocalSession session, @Arg(name = "randomize", desc = "boolean", def = "true") boolean randomize, @Arg(name = "maxcomplexity", desc = "double", def = "100") double maxComplexity, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) {
return new AngleColorPattern(extent, session, distanceOpt);
}
@Command(
name = "#angledata",
desc = "Block data based on the existing terrain angle"
)
public Pattern angledata(Extent extent, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) {
return new DataAnglePattern(extent, distanceOpt);
}
@Command(
name = "#saturate",
desc = "Saturate the existing block with a color"
)
public Pattern saturate(Extent extent, LocalSession session, String colorStr) {
Color color = ColorUtil.parseColor(colorStr);
return new SaturatePattern(extent, color.getRGB(), session);
}
@Command(
name = "#averagecolor",
desc = "Average between the existing block and a color"
)
public Pattern averagecolor(Extent extent, LocalSession session, String colorStr) {
Color color = ColorUtil.parseColor(colorStr);
return new AverageColorPattern(extent, color.getRGB(), session);
}
@Command(
name = "#desaturate",
desc = "Desaturated color of the existing block"
)
public Pattern desaturate(Extent extent, LocalSession session, @Arg(name = "percent", desc = "double", def = "100") double percent) {
return new DesaturatePattern(extent, percent / 100d, session);
}
@Command(
name = "#lighten",
desc = "Lighten the existing block"
)
public Pattern lighten(Extent extent, TextureUtil util) {
return new ShadePattern(extent, false, util);
}
@Command(
name = "#darken",
desc = "Darken the existing block"
)
public Pattern darken(Extent extent, TextureUtil util) {
return new ShadePattern(extent, true, util);
}
@Command(
name = "#fullcopy",
desc = "Places your full clipboard at each block"
)
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;
switch (location.toLowerCase()) {
case "#copy":
case "#clipboard":
ClipboardHolder clipboard = session.getExistingClipboard();
if (clipboard == null) {
throw new InputParseException("To use #fullcopy, please first copy something to your clipboard");
}
if (!rotate && !flip) {
return new FullClipboardPattern(extent, clipboard.getClipboard());
}
clipboards = Collections.singletonList(clipboard);
break;
default:
MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(player, location, null, true);
clipboards = multi != null ? multi.getHolders() : null;
break;
}
if (clipboards == null) {
throw new InputParseException("#fullcopy:<source>");
}
return new RandomFullClipboardPattern(extent, clipboards, rotate, flip);
}
@Command(
name = "#buffer",
desc = "Only place a block once while a pattern is in use",
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"
)
public Pattern buffer(Actor actor, Pattern pattern) {
return new BufferedPattern(actor, pattern);
}
@Command(
name = "#buffer2d",
desc = "Only place a block once in a column while a pattern is in use"
)
public Pattern buffer2d(Actor actor, Pattern pattern) {
return new BufferedPattern2D(actor, pattern);
}
@Command(
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" +
" - Use to replace slabs or where the data values needs to be shifted instead of set"
)
public Pattern iddatamask(Actor actor, LocalSession session, Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) {
return new IdDataMaskPattern(extent, pattern, bitmask);
}
@Command(
name = "#id",
desc = "Only change the block id"
)
public Pattern id(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new IdPattern(extent, pattern);
}
@Command(
name = "#data",
desc = "Only change the block data"
)
public Pattern data(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new DataPattern(extent, pattern);
}
@Command(
name = "#biome",
aliases = {"$"},
desc = "Set the biome"
)
public Pattern biome(Actor actor, LocalSession session, Extent extent, BiomeType biome) {
return new BiomePattern(extent, biome);
}
@Command(
name = "#relative",
aliases = {"#~", "#r", "#rel"},
desc = "Offset the pattern to where you click"
)
public Pattern relative(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new RelativePattern(pattern);
}
@Command(
name = "#!x",
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" +
"Example: #!x[#!z[#~[#l3d[pattern]]]]"
)
public Pattern nox(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new NoXPattern(pattern);
}
@Command(
name = "#!y",
aliases = {"#ny", "#noy"},
desc = "The pattern will not be provided the y axis info"
)
public Pattern noy(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new NoYPattern(pattern);
}
@Command(
name = "#!z",
aliases = {"#nz", "#noz"},
desc = "The pattern will not be provided the z axis info"
)
public Pattern noz(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new NoZPattern(pattern);
}
@Command(
name = "#mask",
desc = "Apply a pattern depending on a mask"
)
public Pattern mask(Actor actor, LocalSession session, Mask mask, Pattern pass, Pattern fail) {
return new MaskedPattern(mask, pass, fail);
}
@Command(
name = "#offset",
desc = "Offset a pattern"
)
public Pattern offset(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
}
@Command(
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 surfacespread(Actor actor, LocalSession session, double distance, Pattern pattern) {
return new SurfaceRandomOffsetPattern(pattern, (int) distance);
}
@Command(
name = "#solidspread",
desc = "Randomly spread solid blocks"
)
public Pattern solidspread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
}
@Command(
name = "#spread",
aliases = {"#randomoffset"},
desc = "Randomly spread blocks"
)
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 = "#linear",
aliases = {"#l"},
desc = "Sequentially set blocks from a list of patterns"
)
public Pattern linear(Actor actor, LocalSession session, Pattern other) {
if (other instanceof RandomPattern) {
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
}
return other;
}
@Command(
name = "#linear3d",
aliases = {"#l3d"},
desc = "Use the x,y,z coordinate to pick a block from the list"
)
public Pattern linear3d(Actor actor, LocalSession session, Pattern other) {
if (other instanceof RandomPattern) {
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
}
return other;
}
@Command(
name = "#linear2d",
aliases = {"#l2d"},
desc = "Use the x,z coordinate to pick a block from the list"
)
public Pattern linear2d(Actor actor, LocalSession session, Pattern other) {
if (other instanceof RandomPattern) {
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
}
return other;
}
@Command(
name = "=",
aliases = {"#=", "#expression"},
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);
}
}
// public Pattern simplex(@Arg(desc = "scale factor") double scale, Pattern other) {
// if (other instanceof RandomPattern) {
// scale = (1d / Math.max(1, scale));
// RandomCollection<Pattern> collection = ((RandomPattern) other).getCollection();
// collection.setRandom(new SimplexRandom(scale));
// }
// return other;
// }
//
// @Command(
// name = "#color",
// desc = "Use the block closest to a specific color"
//)
// public Pattern color(TextureUtil textureUtil, String color) {
// Color colorObj = ColorUtil.parseColor(color);
// return textureUtil.getNearestBlock(colorObj.getRGB()).getDefaultState();
// }
//
// @Command(
// name = "#anglecolor",
// desc = "A darker block based on the existing terrain angle"
//)
// public Pattern anglecolor(Extent extent, LocalSession session, @Arg(name = "randomize", desc = "boolean", def = "true") boolean randomize, @Arg(name = "maxcomplexity", desc = "double", def = "100") double maxComplexity, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) {
// return new AngleColorPattern(extent, session, distanceOpt);
// }
//
// @Command(
// name = "#angledata",
// desc = "Block data based on the existing terrain angle"
// )
// public Pattern angledata(Extent extent, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) {
// return new DataAnglePattern(extent, distanceOpt);
// }
//
// @Command(
// name = "#saturate",
// desc = "Saturate the existing block with a color"
//)
// public Pattern saturate(Extent extent, LocalSession session, String colorStr) {
// Color color = ColorUtil.parseColor(colorStr);
// return new SaturatePattern(extent, color.getRGB(), session);
// }
//
// @Command(
// name = "#averagecolor",
// desc = "Average between the existing block and a color"
//)
// public Pattern averagecolor(Extent extent, LocalSession session, String colorStr) {
// Color color = ColorUtil.parseColor(colorStr);
// return new AverageColorPattern(extent, color.getRGB(), session);
// }
//
// @Command(
// name = "#desaturate",
// desc = "Desaturated color of the existing block"
//)
// public Pattern desaturate(Extent extent, LocalSession session, @Arg(name = "percent", desc = "double", def = "100") double percent) {
// return new DesaturatePattern(extent, percent / 100d, session);
// }
//
// @Command(
// name = "#lighten",
// desc = "Lighten the existing block"
//)
// public Pattern lighten(Extent extent, TextureUtil util) {
// return new ShadePattern(extent, false, util);
// }
//
// @Command(
// name = "#darken",
// desc = "Darken the existing block"
//)
// public Pattern darken(Extent extent, TextureUtil util) {
// return new ShadePattern(extent, true, util);
// }
//
// @Command(
// name = "#fullcopy",
// desc = "Places your full clipboard at each block"
//)
// 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;
// switch (location.toLowerCase()) {
// case "#copy":
// case "#clipboard":
// ClipboardHolder clipboard = session.getExistingClipboard();
// if (clipboard == null) {
// throw new InputParseException("To use #fullcopy, please first copy something to your clipboard");
// }
// if (!rotate && !flip) {
// return new FullClipboardPattern(extent, clipboard.getClipboard());
// }
// clipboards = Collections.singletonList(clipboard);
// break;
// default:
// MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(player, location, null, true);
// clipboards = multi != null ? multi.getHolders() : null;
// break;
// }
// if (clipboards == null) {
// throw new InputParseException("#fullcopy:<source>");
// }
// return new RandomFullClipboardPattern(extent, clipboards, rotate, flip);
// }
//
// @Command(
// name = "#buffer",
// desc = "Only place a block once while a pattern is in use",
// 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"
//)
// public Pattern buffer(Actor actor, Pattern pattern) {
// return new BufferedPattern(actor, pattern);
// }
//
// @Command(
// name = "#buffer2d",
// desc = "Only place a block once in a column while a pattern is in use"
//)
// public Pattern buffer2d(Actor actor, Pattern pattern) {
// return new BufferedPattern2D(actor, pattern);
// }
//
// @Command(
// 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" +
// " - Use to replace slabs or where the data values needs to be shifted instead of set"
//)
// public Pattern iddatamask(Actor actor, LocalSession session, Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) {
//
// return new IdDataMaskPattern(extent, pattern, bitmask);
// }
//
// @Command(
// name = "#id",
// desc = "Only change the block id"
//)
// public Pattern id(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
//
// return new IdPattern(extent, pattern);
// }
//
// @Command(
// name = "#data",
// desc = "Only change the block data"
//)
// public Pattern data(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
//
// return new DataPattern(extent, pattern);
// }
//
// @Command(
// name = "#biome",
// aliases = {"$"},
// desc = "Set the biome"
//)
// public Pattern biome(Actor actor, LocalSession session, Extent extent, BiomeType biome) {
//
// return new BiomePattern(extent, biome);
// }
//
// @Command(
// name = "#relative",
// aliases = {"#~", "#r", "#rel"},
// desc = "Offset the pattern to where you click"
//)
// public Pattern relative(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
//
// return new RelativePattern(pattern);
// }
//
// @Command(
// name = "#!x",
// 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" +
// "Example: #!x[#!z[#~[#l3d[pattern]]]]"
//)
// public Pattern nox(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
//
// return new NoXPattern(pattern);
// }
//
// @Command(
// name = "#!y",
// aliases = {"#ny", "#noy"},
// desc = "The pattern will not be provided the y axis info"
//)
// public Pattern noy(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
//
// return new NoYPattern(pattern);
// }
//
// @Command(
// name = "#!z",
// aliases = {"#nz", "#noz"},
// desc = "The pattern will not be provided the z axis info"
//)
// public Pattern noz(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
//
// return new NoZPattern(pattern);
// }
//
// @Command(
// name = "#mask",
// desc = "Apply a pattern depending on a mask"
//)
// public Pattern mask(Actor actor, LocalSession session, Mask mask, Pattern pass, Pattern fail) {
// return new MaskedPattern(mask, pass, fail);
// }
//
// @Command(
// name = "#offset",
// desc = "Offset a pattern"
//)
// public Pattern offset(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
//
// return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
// }
//
// @Command(
// 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 surfacespread(Actor actor, LocalSession session, double distance, Pattern pattern) {
//
// return new SurfaceRandomOffsetPattern(pattern, (int) distance);
// }
//
// @Command(
// name = "#solidspread",
// desc = "Randomly spread solid blocks"
//)
// public Pattern solidspread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
//
// return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
// }
//
// @Command(
// name = "#spread",
// aliases = {"#randomoffset"},
// desc = "Randomly spread blocks"
//)
// 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 = "#linear",
// aliases = {"#l"},
// desc = "Sequentially set blocks from a list of patterns"
//)
// public Pattern linear(Actor actor, LocalSession session, Pattern other) {
//
// if (other instanceof RandomPattern) {
// Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
// return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
// }
// return other;
// }
//
// @Command(
// name = "#linear3d",
// aliases = {"#l3d"},
// desc = "Use the x,y,z coordinate to pick a block from the list"
//)
// public Pattern linear3d(Actor actor, LocalSession session, Pattern other) {
//
// if (other instanceof RandomPattern) {
// Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
// return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
// }
// return other;
// }
//
// @Command(
// name = "#linear2d",
// aliases = {"#l2d"},
// desc = "Use the x,z coordinate to pick a block from the list"
//)
// public Pattern linear2d(Actor actor, LocalSession session, Pattern other) {
//
// if (other instanceof RandomPattern) {
// Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
// return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
// }
// return other;
// }
//
// @Command(
// name = "=",
// aliases = {"#=", "#expression"},
// 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");
} else {
session.setTool(itemType, new SelectionWand());
BBC.SELECTION_WAND.send(player);
player.print(BBC.SELECTION_WAND.s());
}
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);
@ -360,7 +360,7 @@ public class SelectionCommands {
session.getRegionSelector(world).explainRegionAdjust(actor, session);
BBC.SELECTION_SHIFT.send(actor);
actor.print(BBC.SELECTION_SHIFT.s());
} catch (RegionOperationException e) {
actor.printError(e.getMessage());
}
@ -383,7 +383,7 @@ public class SelectionCommands {
region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session);
BBC.SELECTION_OUTSET.send(actor);
actor.print(BBC.SELECTION_OUTSET.s());
}
@Command(
@ -560,7 +560,7 @@ public class SelectionCommands {
if (selector == null) {
session.getRegionSelector(world).clear();
session.dispatchCUISelection(actor);
BBC.SELECTION_CLEARED.send(actor);
actor.print(BBC.SELECTION_CLEARED.s());
return;
}

View File

@ -44,6 +44,7 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
import com.sk89q.worldedit.internal.command.CommandUtil;
import com.sk89q.worldedit.command.ToolCommandsRegistration;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.formatting.text.TextComponent;

View File

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

View File

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

View File

@ -61,7 +61,7 @@ public class DelegateCommandManager implements CommandManager {
}
@Override
public Object execute(InjectedValueAccess context, List<String> args) {
public int execute(InjectedValueAccess context, List<String> 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.HistoryCommands;
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.NavigationCommandsRegistration;
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.RegionCommandsRegistration;
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.ToolUtilCommands;
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.UtilityCommandsRegistration;
import com.sk89q.worldedit.command.WorldEditCommands;
@ -201,7 +195,6 @@ public final class PlatformCommandManager {
checkNotNull(worldEdit);
checkNotNull(platformManager);
INSTANCE = this;
this.worldEdit = worldEdit;
this.platformManager = platformManager;
this.exceptionConverter = new WorldEditExceptionConverter(worldEdit);
@ -291,8 +284,7 @@ public final class PlatformCommandManager {
return (World) ((Locatable) actor).getExtent();
} else {
throw new MissingWorldException();
}
}
} catch (MissingWorldException e) {
exceptionConverter.convert(e);
throw new AssertionError("Should have thrown a new exception.", e);
@ -302,15 +294,15 @@ public final class PlatformCommandManager {
}
private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
CommandManager commandManager,
Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance) {
CommandManager commandManager,
Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance) {
registerSubCommands(name, aliases, desc, commandManager, handlerInstance, m -> {});
}
private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
CommandManager commandManager,
Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance,
Consumer<CommandManager> additionalConfig) {
CommandManager commandManager,
Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance,
Consumer<CommandManager> additionalConfig) {
commandManager.register(name, cmd -> {
cmd.aliases(aliases);
cmd.description(TextComponent.of(desc));
@ -320,17 +312,18 @@ public final class PlatformCommandManager {
handlerInstance.accept((handler, instance) ->
this.registration.register(
manager,
handler,
instance
manager,
handler,
instance
));
additionalConfig.accept(manager);
final List<Command> subCommands = manager.getAllCommands().collect(Collectors.toList());
cmd.addPart(SubCommandPart.builder(TranslatableComponent.of("worldedit.argument.action"),
TextComponent.of("Sub-command to run."))
.withCommands(subCommands)
.required()
.build());
TextComponent.of("Sub-command to run."))
.withCommands(subCommands)
.required()
.build());
cmd.condition(new SubCommandPermissionCondition.Generator(subCommands).build());
});
@ -343,27 +336,27 @@ public final class PlatformCommandManager {
public void registerAllCommands() {
if (Settings.IMP.ENABLED_COMPONENTS.COMMANDS) {
registerSubCommands(
"patterns",
ImmutableList.of(),
"Patterns determine what blocks are placed",
PatternCommandsRegistration.builder(),
new PatternCommands()
);
registerSubCommands(
"masks",
ImmutableList.of(),
"Masks determine which blocks are placed",
MaskCommandsRegistration.builder(),
new MaskCommands(worldEdit)
);
registerSubCommands(
"transforms",
ImmutableList.of(),
"Transforms modify how a block is placed",
TransformCommandsRegistration.builder(),
new TransformCommands()
);
// registerSubCommands(
// "patterns",
// ImmutableList.of(),
// "Patterns determine what blocks are placed",
// PatternCommandsRegistration.builder(),
// new PatternCommands()
// );
// registerSubCommands(
// "masks",
// ImmutableList.of(),
// "Masks determine which blocks are placed",
// MaskCommandsRegistration.builder(),
// new MaskCommands(worldEdit)
// );
// registerSubCommands(
// "transforms",
// ImmutableList.of(),
// "Transforms modify how a block is placed",
// TransformCommandsRegistration.builder(),
// new TransformCommands()
// );
registerSubCommands(
"schematic",
ImmutableList.of("schem", "/schematic", "/schem"),
@ -476,11 +469,7 @@ public final class PlatformCommandManager {
SnapshotUtilCommandsRegistration.builder(),
new SnapshotUtilCommands(worldEdit)
);
this.registration.register(
commandManager,
ToolCommandsRegistration.builder(),
new ToolCommands(worldEdit)
);
ToolCommands.register(registration, commandManager, commandManagerService, worldEdit);
this.registration.register(
commandManager,
ToolUtilCommandsRegistration.builder(),
@ -505,13 +494,6 @@ public final class PlatformCommandManager {
void registerCommandsWith(Platform platform) {
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();
boolean logging = config.logCommands;
String path = config.logFile;
@ -536,7 +518,6 @@ public final class PlatformCommandManager {
}
platform.registerCommands(commandManager);
// commandManager.getCommand("pattern").get()
}
void removeCommands() {
@ -544,7 +525,7 @@ public final class PlatformCommandManager {
}
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) {