3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 18:10:08 +01:00

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

Dieser Commit ist enthalten in:
MattBDev 2019-10-07 15:09:52 -04:00
Ursprung 7ac29d6173
Commit 11d30d2f94
15 geänderte Dateien mit 1044 neuen und 1034 gelöschten Zeilen

Datei anzeigen

@ -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")
} }
} }
} }

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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);
} }

Datei anzeigen

@ -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;
} }

Datei anzeigen

@ -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"
// )
// 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 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 {
public class MaskCommands { // double y1, y2;
private final WorldEdit worldEdit; // boolean override;
// if (maxStr.endsWith("d")) {
public MaskCommands(WorldEdit worldEdit) { // double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
this.worldEdit = worldEdit; // 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));
@Command( // } else {
name = "#simplex", // y1 = Expression.compile(minStr).evaluate();
desc = "Use simplex noise as the mask" // y2 = Expression.compile(maxStr).evaluate();
) // }
public Mask simplex(double scale, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { // return new AngleMask(extent, y1, y2, overlay, distanceOpt);
scale = 1d / Math.max(1, scale); // }
minInt = (minInt - 50) / 50; //
maxInt = (maxInt - 50) / 50; // @Command(
return new SimplexMask(scale, minInt, maxInt); // name = "(",
} // aliases = {")", "#roc", "#(", "#)"},
// desc = "Restrict to near specific terrain slope rate of change",
@Command( // descFooter = "Restrict to near specific terrain slope rate of change\n" +
name = "#light", // "The -o flag will only overlay\n" +
desc = "Restrict to specific light levels" // "Example: ([0d][45d][5]\n" +
) // "Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" +
public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { // "Note: Use negatives for decreasing slope"
return new LightMask(extent, (int) minInt, (int) maxInt); //)
} // 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 = "#false", // if (maxStr.endsWith("d")) {
desc = "Always false" // double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
) // double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
public Mask falseMask(Extent extent) { // y1 = Math.tan(y1d * (Math.PI / 180));
return Masks.alwaysFalse(); // y2 = Math.tan(y2d * (Math.PI / 180));
} // } else {
// y1 = Expression.compile(minStr).evaluate();
@Command( // y2 = Expression.compile(maxStr).evaluate();
name = "#true", // }
desc = "Always true" // return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt);
) // }
public Mask trueMask(Extent extent) { //
return Masks.alwaysTrue(); // @Command(
} // name = "^",
// aliases = {"#extrema", "#^"},
@Command( // desc = "Restrict to near specific terrain extrema",
name = "#skylight", // descFooter = "Restrict to near specific terrain extrema\n" +
desc = "Restrict to specific sky light levels" // "The -o flag will only overlay\n" +
) // "Example: ([0d][45d][5]\n" +
public Mask skylight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { // "Explanation: Restrict to near 45 degrees of local maxima\n" +
return new SkyLightMask(extent, (int) minInt, (int) maxInt); // "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 {
@Command( // double y1, y2;
name = "#blocklight", // boolean override;
aliases = {"#emittedlight"}, // if (maxStr.endsWith("d")) {
desc = "Restrict to specific block light levels" // double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
) // double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
public Mask blocklight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) { // y1 = Math.tan(y1d * (Math.PI / 180));
return new BlockLightMask(extent, (int) minInt, (int) maxInt); // y2 = Math.tan(y2d * (Math.PI / 180));
} // } else {
// y1 = Expression.compile(minStr).evaluate();
@Command( // y2 = Expression.compile(maxStr).evaluate();
name = "#opacity", // }
desc = "Restrict to specific opacity levels" // return new ExtremaMask(extent, y1, y2, overlay, distanceOpt);
) // }
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 = "{",
// aliases = {"#{"},
@Command( // desc = "Restricts blocks to within a specific radius range of the initial block"
name = "#brightness", //)
desc = "Restrict to specific block brightness" // 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);
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 = "|",
@Command( // aliases = {"#|", "#side"},
name = "#offset", // desc = "sides with a specific number of other blocks"
desc = "Offset a mask" //)
) // public Mask wall(Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
public Mask offset(double x, double y, double z, Mask mask) { // return new WallMask(mask, (int) minInt, (int) maxInt);
return new OffsetMask(mask, BlockVector3.at(x, y, z)); // }
} //
// @Command(
@Command( // name = "~",
name = "#haslight", // aliases = {"#~", "#adjacent"},
desc = "Restricts to blocks with light (sky or emitted)" // desc = "Adjacent to a specific number of other blocks"
) //)
public Mask haslight(Extent extent) { // 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 {
return new LightMask(extent, 1, Integer.MAX_VALUE); // if (min == -1 && max == -1) {
} // min = 1;
// max = 8;
@Command( // } else if (max == -1) max = min;
name = "#nolight", // if (max >= 8 && min == 1) {
desc = "Restrict to blocks without light (sky or emitted)" // return new AdjacentAnyMask(mask);
) // }
public Mask nolight(Extent extent) { // return new AdjacentMask(mask, (int) min, (int) max);
return new LightMask(extent, 0, 0); // }
} //
// @Command(
@Command( // name = "<",
name = "#existing", // aliases = {"#<", "#below"},
desc = "If there is a non air block" // desc = "below a specific block"
) //)
public Mask existing(Extent extent) { // public Mask below(Mask mask) throws ExpressionException {
return new ExistingBlockMask(extent); // OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0));
} // return new MaskIntersection(offsetMask, Masks.negate(mask));
// }
@Command( //
name = "#solid", // @Command(
desc = "If there is a solid block" // name = ">",
) // aliases = {"#>", "#above"},
public Mask solid(Extent extent) { // desc = "above a specific block"
return new SolidBlockMask(extent); //)
} // public Mask above(Mask mask) throws ExpressionException {
// OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0));
@Command( // return new MaskIntersection(offsetMask, Masks.negate(mask));
name = "#liquid", // }
desc = "If there is a solid block" //
) // @Command(
public Mask liquid(Extent extent) { // name = "$",
return new BlockMaskBuilder().addAll(b -> b.getMaterial().isLiquid()).build(extent); // aliases = {"#biome", "#$"},
} // desc = "in a specific biome",
// descFooter = "in a specific biome. For a list of biomes use //biomelist"
@Command( //)
name = "#dregion", // public Mask biome(Extent extent, BiomeType biome) throws ExpressionException {
aliases = {"#dselection", "#dsel"}, // return new BiomeMask(extent, biome);
desc = "inside the player's selection" // }
) //
public Mask dregion() { // @Command(
return new RegionMask(new RequestSelection()); // name = "%",
} // aliases = {"#%", "#percent"},
// desc = "percentage chance"
@Command( //)
name = "#region", // public Mask random(double chance) throws ExpressionException {
aliases = {"#selection", "#sel"}, // chance = chance / 100;
desc = "inside the provided selection" // return new RandomMask(chance);
) // }
public Mask selection(Player player, LocalSession session) throws IncompleteRegionException { //
return new RegionMask(session.getSelection(player.getWorld()).clone()); // @Command(
} // name = "=",
// aliases = {"#=", "#expression"},
@Command( // desc = "expression mask"
name = "#xaxis", //)
desc = "Restrict to initial x axis" // public Mask expression(Extent extent, String input) throws ExpressionException {
) // Expression exp = Expression.compile(input, "x", "y", "z");
public Mask xaxis() { // ExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
return new XAxisMask(); // exp.setEnvironment(env);
} // return new ExpressionMask(exp);
// }
@Command( //
name = "#yaxis", // @Command(
desc = "Restrict to initial y axis" // name = "!",
) // aliases = {"#not", "#negate", "#!"},
public Mask yaxis() { // desc = "Negate another mask"
return new YAxisMask(); //)
} // public Mask expression(Mask mask) throws ExpressionException {
// return Masks.negate(mask);
@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);
}
}

Datei anzeigen

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

Datei anzeigen

@ -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;
} }

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;
} // }
} //}

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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);
} }

Datei anzeigen

@ -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
}

Datei anzeigen

@ -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);
@ -291,8 +284,7 @@ public final class PlatformCommandManager {
return (World) ((Locatable) actor).getExtent(); return (World) ((Locatable) actor).getExtent();
} 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);
@ -302,15 +294,15 @@ public final class PlatformCommandManager {
} }
private <CI> void registerSubCommands(String name, List<String> aliases, String desc, private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
CommandManager commandManager, CommandManager commandManager,
Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance) { Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance) {
registerSubCommands(name, aliases, desc, commandManager, handlerInstance, m -> {}); registerSubCommands(name, aliases, desc, commandManager, handlerInstance, m -> {});
} }
private <CI> void registerSubCommands(String name, List<String> aliases, String desc, private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
CommandManager commandManager, CommandManager commandManager,
Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance, Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance,
Consumer<CommandManager> additionalConfig) { Consumer<CommandManager> additionalConfig) {
commandManager.register(name, cmd -> { commandManager.register(name, cmd -> {
cmd.aliases(aliases); cmd.aliases(aliases);
cmd.description(TextComponent.of(desc)); cmd.description(TextComponent.of(desc));
@ -320,17 +312,18 @@ public final class PlatformCommandManager {
handlerInstance.accept((handler, instance) -> handlerInstance.accept((handler, instance) ->
this.registration.register( this.registration.register(
manager, manager,
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"),
TextComponent.of("Sub-command to run.")) TextComponent.of("Sub-command to run."))
.withCommands(subCommands) .withCommands(subCommands)
.required() .required()
.build()); .build());
cmd.condition(new SubCommandPermissionCondition.Generator(subCommands).build()); cmd.condition(new SubCommandPermissionCondition.Generator(subCommands).build());
}); });
@ -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) {