Remove a tonne of code from WorldEdit. This breaks backwards compatibility. More will be removed. Sorry :)

This commit is contained in:
Matthew Miller
2018-06-15 15:41:37 +10:00
parent b292a39765
commit c537a2e948
67 changed files with 139 additions and 2615 deletions

View File

@ -36,17 +36,18 @@ import com.sk89q.worldedit.command.util.CreatureButcher;
import com.sk89q.worldedit.command.util.EntityRemover;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.CommandManager;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.EntityVisitor;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.patterns.SingleBlockPattern;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.CylinderRegion;
import com.sk89q.worldedit.regions.Region;
@ -92,17 +93,20 @@ public class UtilityCommands {
@Logging(PLACEMENT)
public void fill(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
Pattern pattern = we.getBlockPattern(player, args.getString(0));
ParserContext context = new ParserContext();
context.setActor(player);
context.setWorld(player.getWorld());
context.setSession(session);
Pattern pattern = we.getPatternFactory().parseFromInput(args.getString(0), context);
double radius = Math.max(1, args.getDouble(1));
we.checkMaxRadius(radius);
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : 1;
Vector pos = session.getPlacementPosition(player);
int affected = 0;
if (pattern instanceof SingleBlockPattern) {
affected = editSession.fillXZ(pos,
((SingleBlockPattern) pattern).getBlock(),
radius, depth, false);
int affected;
if (pattern instanceof BlockPattern) {
affected = editSession.fillXZ(pos, ((BlockPattern) pattern).getBlock(), radius, depth, false);
} else {
affected = editSession.fillXZ(pos, pattern, radius, depth, false);
}
@ -120,17 +124,20 @@ public class UtilityCommands {
@Logging(PLACEMENT)
public void fillr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
Pattern pattern = we.getBlockPattern(player, args.getString(0));
ParserContext context = new ParserContext();
context.setActor(player);
context.setWorld(player.getWorld());
context.setSession(session);
Pattern pattern = we.getPatternFactory().parseFromInput(args.getString(0), context);
double radius = Math.max(1, args.getDouble(1));
we.checkMaxRadius(radius);
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : Integer.MAX_VALUE;
Vector pos = session.getPlacementPosition(player);
int affected = 0;
if (pattern instanceof SingleBlockPattern) {
affected = editSession.fillXZ(pos,
((SingleBlockPattern) pattern).getBlock(),
radius, depth, true);
if (pattern instanceof BlockPattern) {
affected = editSession.fillXZ(pos, ((BlockPattern) pattern).getBlock(), radius, depth, true);
} else {
affected = editSession.fillXZ(pos, pattern, radius, depth, true);
}
@ -267,12 +274,20 @@ public class UtilityCommands {
int affected;
Set<BaseBlock> from;
Pattern to;
ParserContext context = new ParserContext();
context.setActor(player);
context.setWorld(player.getWorld());
context.setSession(session);
context.setRestricted(false);
context.setPreferringWildcard(!args.hasFlag('f'));
if (args.argsLength() == 2) {
from = null;
to = we.getBlockPattern(player, args.getString(1));
to = we.getPatternFactory().parseFromInput(args.getString(1), context);
} else {
from = we.getBlocks(player, args.getString(1), true, !args.hasFlag('f'));
to = we.getBlockPattern(player, args.getString(2));
from = we.getBlockFactory().parseFromListInput(args.getString(1), context);
to = we.getPatternFactory().parseFromInput(args.getString(2), context);
}
Vector base = session.getPlacementPosition(player);
@ -280,8 +295,8 @@ public class UtilityCommands {
Vector max = base.add(size, size, size);
Region region = new CuboidRegion(player.getWorld(), min, max);
if (to instanceof SingleBlockPattern) {
affected = editSession.replaceBlocks(region, from, ((SingleBlockPattern) to).getBlock());
if (to instanceof BlockPattern) {
affected = editSession.replaceBlocks(region, from, ((BlockPattern) to).getBlock());
} else {
affected = editSession.replaceBlocks(region, from, to);
}