mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Remove a tonne of code from WorldEdit. This breaks backwards compatibility. More will be removed. Sorry :)
This commit is contained in:
@ -22,6 +22,7 @@ package com.sk89q.worldedit;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||
@ -49,7 +50,7 @@ import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
|
||||
import com.sk89q.worldedit.function.mask.*;
|
||||
import com.sk89q.worldedit.function.operation.*;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.util.RegionOffset;
|
||||
import com.sk89q.worldedit.function.visitor.*;
|
||||
import com.sk89q.worldedit.history.UndoContext;
|
||||
@ -65,8 +66,6 @@ import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
|
||||
import com.sk89q.worldedit.math.interpolation.Node;
|
||||
import com.sk89q.worldedit.math.noise.RandomNoise;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
||||
import com.sk89q.worldedit.regions.*;
|
||||
import com.sk89q.worldedit.regions.shape.ArbitraryBiomeShape;
|
||||
import com.sk89q.worldedit.regions.shape.ArbitraryShape;
|
||||
@ -96,7 +95,7 @@ import static com.sk89q.worldedit.regions.Regions.*;
|
||||
* {@link Extent}s that are chained together. For example, history is logged
|
||||
* using the {@link ChangeSetExtent}.</p>
|
||||
*/
|
||||
@SuppressWarnings({"FieldCanBeLocal", "deprecation"})
|
||||
@SuppressWarnings({"FieldCanBeLocal"})
|
||||
public class EditSession implements Extent {
|
||||
|
||||
private static final Logger log = Logger.getLogger(EditSession.class.getCanonicalName());
|
||||
@ -131,7 +130,6 @@ public class EditSession implements Extent {
|
||||
private final Extent bypassHistory;
|
||||
private final Extent bypassNone;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private Mask oldMask;
|
||||
|
||||
/**
|
||||
@ -141,7 +139,6 @@ public class EditSession implements Extent {
|
||||
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
|
||||
* @deprecated use {@link WorldEdit#getEditSessionFactory()} to create {@link EditSession}s
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public EditSession(LocalWorld world, int maxBlocks) {
|
||||
this(world, maxBlocks, null);
|
||||
@ -308,21 +305,6 @@ public class EditSession implements Extent {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mask.
|
||||
*
|
||||
* @param mask the mask
|
||||
* @deprecated Use {@link #setMask(Mask)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMask(com.sk89q.worldedit.masks.Mask mask) {
|
||||
if (mask == null) {
|
||||
setMask((Mask) null);
|
||||
} else {
|
||||
setMask(Masks.wrap(mask));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link SurvivalModeExtent}.
|
||||
*
|
||||
@ -560,9 +542,8 @@ public class EditSession implements Extent {
|
||||
* @return Whether the block changed -- not entirely dependable
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean setBlock(Vector position, Pattern pattern) throws MaxChangedBlocksException {
|
||||
return setBlock(position, pattern.next(position));
|
||||
return setBlock(position, pattern.apply(position));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -574,7 +555,6 @@ public class EditSession implements Extent {
|
||||
* @return the number of changed blocks
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private int setBlocks(Set<Vector> vset, Pattern pattern) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
for (Vector v : vset) {
|
||||
@ -593,7 +573,6 @@ public class EditSession implements Extent {
|
||||
* @return whether a block was changed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean setChanceBlockIfAir(Vector position, BaseBlock block, double probability)
|
||||
throws MaxChangedBlocksException {
|
||||
return Math.random() <= probability && setBlockIfAir(position, block);
|
||||
@ -705,7 +684,7 @@ public class EditSession implements Extent {
|
||||
* @return the number of found blocks
|
||||
*/
|
||||
public int countBlock(Region region, Set<Integer> searchIDs) {
|
||||
Set<BaseBlock> passOn = new HashSet<BaseBlock>();
|
||||
Set<BaseBlock> passOn = new HashSet<>();
|
||||
for (Integer i : searchIDs) {
|
||||
passOn.add(new BaseBlock(i, -1));
|
||||
}
|
||||
@ -739,10 +718,8 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int fillXZ(Vector origin, BaseBlock block, double radius, int depth, boolean recursive)
|
||||
throws MaxChangedBlocksException {
|
||||
return fillXZ(origin, new SingleBlockPattern(block), radius, depth, recursive);
|
||||
public int fillXZ(Vector origin, BaseBlock block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
||||
return fillXZ(origin, new BlockPattern(block), radius, depth, recursive);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -756,7 +733,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int fillXZ(Vector origin, Pattern pattern, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
||||
checkNotNull(origin);
|
||||
checkNotNull(pattern);
|
||||
@ -771,7 +747,7 @@ public class EditSession implements Extent {
|
||||
Masks.negate(new ExistingBlockMask(this)));
|
||||
|
||||
// Want to replace blocks
|
||||
BlockReplace replace = new BlockReplace(this, Patterns.wrap(pattern));
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
|
||||
// Pick how we're going to visit blocks
|
||||
RecursiveVisitor visitor;
|
||||
@ -799,7 +775,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int removeAbove(Vector position, int apothem, int height) throws MaxChangedBlocksException {
|
||||
checkNotNull(position);
|
||||
checkArgument(apothem >= 1, "apothem >= 1");
|
||||
@ -809,7 +784,7 @@ public class EditSession implements Extent {
|
||||
getWorld(), // Causes clamping of Y range
|
||||
position.add(-apothem + 1, 0, -apothem + 1),
|
||||
position.add(apothem - 1, height - 1, apothem - 1));
|
||||
Pattern pattern = new SingleBlockPattern(new BaseBlock(BlockID.AIR));
|
||||
Pattern pattern = new BlockPattern(new BaseBlock(BlockTypes.AIR));
|
||||
return setBlocks(region, pattern);
|
||||
}
|
||||
|
||||
@ -822,7 +797,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int removeBelow(Vector position, int apothem, int height) throws MaxChangedBlocksException {
|
||||
checkNotNull(position);
|
||||
checkArgument(apothem >= 1, "apothem >= 1");
|
||||
@ -832,7 +806,7 @@ public class EditSession implements Extent {
|
||||
getWorld(), // Causes clamping of Y range
|
||||
position.add(-apothem + 1, 0, -apothem + 1),
|
||||
position.add(apothem - 1, -height + 1, apothem - 1));
|
||||
Pattern pattern = new SingleBlockPattern(new BaseBlock(BlockID.AIR));
|
||||
Pattern pattern = new BlockPattern(new BaseBlock(BlockTypes.AIR));
|
||||
return setBlocks(region, pattern);
|
||||
}
|
||||
|
||||
@ -845,7 +819,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int removeNear(Vector position, int blockType, int apothem) throws MaxChangedBlocksException {
|
||||
checkNotNull(position);
|
||||
checkArgument(apothem >= 1, "apothem >= 1");
|
||||
@ -856,7 +829,7 @@ public class EditSession implements Extent {
|
||||
getWorld(), // Causes clamping of Y range
|
||||
position.add(adjustment.multiply(-1)),
|
||||
position.add(adjustment));
|
||||
Pattern pattern = new SingleBlockPattern(new BaseBlock(BlockID.AIR));
|
||||
Pattern pattern = new BlockPattern(new BaseBlock(BlockTypes.AIR));
|
||||
return replaceBlocks(region, mask, pattern);
|
||||
}
|
||||
|
||||
@ -868,9 +841,8 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int setBlocks(Region region, BaseBlock block) throws MaxChangedBlocksException {
|
||||
return setBlocks(region, new SingleBlockPattern(block));
|
||||
return setBlocks(region, new BlockPattern(block));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -881,12 +853,11 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
|
||||
BlockReplace replace = new BlockReplace(this, Patterns.wrap(pattern));
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
RegionVisitor visitor = new RegionVisitor(region, replace);
|
||||
Operations.completeLegacy(visitor);
|
||||
return visitor.getAffected();
|
||||
@ -897,14 +868,13 @@ public class EditSession implements Extent {
|
||||
* returned by a given pattern.
|
||||
*
|
||||
* @param region the region to replace the blocks within
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.masks.ExistingBlockMask}
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
|
||||
* @param replacement the replacement block
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int replaceBlocks(Region region, Set<BaseBlock> filter, BaseBlock replacement) throws MaxChangedBlocksException {
|
||||
return replaceBlocks(region, filter, new SingleBlockPattern(replacement));
|
||||
return replaceBlocks(region, filter, new BlockPattern(replacement));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -912,12 +882,11 @@ public class EditSession implements Extent {
|
||||
* returned by a given pattern.
|
||||
*
|
||||
* @param region the region to replace the blocks within
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.masks.ExistingBlockMask}
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
|
||||
* @param pattern the pattern that provides the new blocks
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
|
||||
Mask mask = filter == null ? new ExistingBlockMask(this) : new FuzzyBlockMask(this, filter);
|
||||
return replaceBlocks(region, mask, pattern);
|
||||
@ -933,13 +902,12 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(mask);
|
||||
checkNotNull(pattern);
|
||||
|
||||
BlockReplace replace = new BlockReplace(this, Patterns.wrap(pattern));
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
RegionMaskingFilter filter = new RegionMaskingFilter(mask, replace);
|
||||
RegionVisitor visitor = new RegionVisitor(region, filter);
|
||||
Operations.completeLegacy(visitor);
|
||||
@ -956,7 +924,6 @@ public class EditSession implements Extent {
|
||||
* @return the number of blocks placed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int center(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
@ -978,9 +945,8 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int makeCuboidFaces(Region region, BaseBlock block) throws MaxChangedBlocksException {
|
||||
return makeCuboidFaces(region, new SingleBlockPattern(block));
|
||||
return makeCuboidFaces(region, new BlockPattern(block));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -991,7 +957,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int makeCuboidFaces(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
@ -1011,7 +976,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int makeFaces(final Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
@ -1033,9 +997,8 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int makeCuboidWalls(Region region, BaseBlock block) throws MaxChangedBlocksException {
|
||||
return makeCuboidWalls(region, new SingleBlockPattern(block));
|
||||
return makeCuboidWalls(region, new BlockPattern(block));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1047,7 +1010,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int makeCuboidWalls(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
@ -1067,7 +1029,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int makeWalls(final Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
@ -1101,11 +1062,10 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int overlayCuboidBlocks(Region region, BaseBlock block) throws MaxChangedBlocksException {
|
||||
checkNotNull(block);
|
||||
|
||||
return overlayCuboidBlocks(region, new SingleBlockPattern(block));
|
||||
return overlayCuboidBlocks(region, new BlockPattern(block));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1117,12 +1077,11 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int overlayCuboidBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
|
||||
BlockReplace replace = new BlockReplace(this, Patterns.wrap(pattern));
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
RegionOffset offset = new RegionOffset(new Vector(0, 1, 0), replace);
|
||||
GroundFunction ground = new GroundFunction(new ExistingBlockMask(this), offset);
|
||||
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
||||
@ -1835,8 +1794,8 @@ public class EditSession implements Extent {
|
||||
* @return the results
|
||||
*/
|
||||
public List<Countable<Integer>> getBlockDistribution(Region region) {
|
||||
List<Countable<Integer>> distribution = new ArrayList<Countable<Integer>>();
|
||||
Map<Integer, Countable<Integer>> map = new HashMap<Integer, Countable<Integer>>();
|
||||
List<Countable<Integer>> distribution = new ArrayList<>();
|
||||
Map<Integer, Countable<Integer>> map = new HashMap<>();
|
||||
|
||||
if (region instanceof CuboidRegion) {
|
||||
// Doing this for speed
|
||||
@ -1860,7 +1819,7 @@ public class EditSession implements Extent {
|
||||
if (map.containsKey(id)) {
|
||||
map.get(id).increment();
|
||||
} else {
|
||||
Countable<Integer> c = new Countable<Integer>(id, 1);
|
||||
Countable<Integer> c = new Countable<>(id, 1);
|
||||
map.put(id, c);
|
||||
distribution.add(c);
|
||||
}
|
||||
@ -1874,7 +1833,7 @@ public class EditSession implements Extent {
|
||||
if (map.containsKey(id)) {
|
||||
map.get(id).increment();
|
||||
} else {
|
||||
Countable<Integer> c = new Countable<Integer>(id, 1);
|
||||
Countable<Integer> c = new Countable<>(id, 1);
|
||||
map.put(id, c);
|
||||
}
|
||||
}
|
||||
@ -1894,8 +1853,8 @@ public class EditSession implements Extent {
|
||||
*/
|
||||
// TODO reduce code duplication - probably during ops-redux
|
||||
public List<Countable<BaseBlock>> getBlockDistributionWithData(Region region) {
|
||||
List<Countable<BaseBlock>> distribution = new ArrayList<Countable<BaseBlock>>();
|
||||
Map<BaseBlock, Countable<BaseBlock>> map = new HashMap<BaseBlock, Countable<BaseBlock>>();
|
||||
List<Countable<BaseBlock>> distribution = new ArrayList<>();
|
||||
Map<BaseBlock, Countable<BaseBlock>> map = new HashMap<>();
|
||||
|
||||
if (region instanceof CuboidRegion) {
|
||||
// Doing this for speed
|
||||
@ -1919,7 +1878,7 @@ public class EditSession implements Extent {
|
||||
if (map.containsKey(blk)) {
|
||||
map.get(blk).increment();
|
||||
} else {
|
||||
Countable<BaseBlock> c = new Countable<BaseBlock>(blk, 1);
|
||||
Countable<BaseBlock> c = new Countable<>(blk, 1);
|
||||
map.put(blk, c);
|
||||
distribution.add(c);
|
||||
}
|
||||
@ -1933,7 +1892,7 @@ public class EditSession implements Extent {
|
||||
if (map.containsKey(blk)) {
|
||||
map.get(blk).increment();
|
||||
} else {
|
||||
Countable<BaseBlock> c = new Countable<BaseBlock>(blk, 1);
|
||||
Countable<BaseBlock> c = new Countable<>(blk, 1);
|
||||
map.put(blk, c);
|
||||
}
|
||||
}
|
||||
@ -1989,7 +1948,7 @@ public class EditSession implements Extent {
|
||||
final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero);
|
||||
expression.setEnvironment(environment);
|
||||
|
||||
final DoubleArrayList<BlockVector, BaseBlock> queue = new DoubleArrayList<BlockVector, BaseBlock>(false);
|
||||
final DoubleArrayList<BlockVector, BaseBlock> queue = new DoubleArrayList<>(false);
|
||||
|
||||
for (BlockVector position : region) {
|
||||
// offset, scale
|
||||
@ -2035,7 +1994,7 @@ public class EditSession implements Extent {
|
||||
public int hollowOutRegion(Region region, int thickness, Pattern pattern) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
final Set<BlockVector> outside = new HashSet<BlockVector>();
|
||||
final Set<BlockVector> outside = new HashSet<>();
|
||||
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
@ -2069,7 +2028,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
for (int i = 1; i < thickness; ++i) {
|
||||
final Set<BlockVector> newOutside = new HashSet<BlockVector>();
|
||||
final Set<BlockVector> newOutside = new HashSet<>();
|
||||
outer: for (BlockVector position : region) {
|
||||
for (Vector recurseDirection: recurseDirections) {
|
||||
BlockVector neighbor = position.add(recurseDirection).toBlockVector();
|
||||
@ -2093,7 +2052,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
}
|
||||
|
||||
if (setBlock(position, pattern.next(position))) {
|
||||
if (setBlock(position, pattern.apply(position))) {
|
||||
++affected;
|
||||
}
|
||||
}
|
||||
@ -2116,7 +2075,7 @@ public class EditSession implements Extent {
|
||||
public int drawLine(Pattern pattern, Vector pos1, Vector pos2, double radius, boolean filled)
|
||||
throws MaxChangedBlocksException {
|
||||
|
||||
Set<Vector> vset = new HashSet<Vector>();
|
||||
Set<Vector> vset = new HashSet<>();
|
||||
boolean notdrawn = true;
|
||||
|
||||
int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ();
|
||||
@ -2187,8 +2146,8 @@ public class EditSession implements Extent {
|
||||
public int drawSpline(Pattern pattern, List<Vector> nodevectors, double tension, double bias, double continuity, double quality, double radius, boolean filled)
|
||||
throws MaxChangedBlocksException {
|
||||
|
||||
Set<Vector> vset = new HashSet<Vector>();
|
||||
List<Node> nodes = new ArrayList<Node>(nodevectors.size());
|
||||
Set<Vector> vset = new HashSet<>();
|
||||
List<Node> nodes = new ArrayList<>(nodevectors.size());
|
||||
|
||||
Interpolation interpol = new KochanekBartelsInterpolation();
|
||||
|
||||
@ -2227,7 +2186,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
private static Set<Vector> getBallooned(Set<Vector> vset, double radius) {
|
||||
Set<Vector> returnset = new HashSet<Vector>();
|
||||
Set<Vector> returnset = new HashSet<>();
|
||||
int ceilrad = (int) Math.ceil(radius);
|
||||
|
||||
for (Vector v : vset) {
|
||||
@ -2247,7 +2206,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
private static Set<Vector> getHollowed(Set<Vector> vset) {
|
||||
Set<Vector> returnset = new HashSet<Vector>();
|
||||
Set<Vector> returnset = new HashSet<>();
|
||||
for (Vector v : vset) {
|
||||
double x = v.getX(), y = v.getY(), z = v.getZ();
|
||||
if (!(vset.contains(new Vector(x + 1, y, z)) &&
|
||||
@ -2263,7 +2222,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
private void recurseHollow(Region region, BlockVector origin, Set<BlockVector> outside) {
|
||||
final LinkedList<BlockVector> queue = new LinkedList<BlockVector>();
|
||||
final LinkedList<BlockVector> queue = new LinkedList<>();
|
||||
queue.addLast(origin);
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
|
@ -917,14 +917,4 @@ public class LocalSession {
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a mask.
|
||||
*
|
||||
* @param mask mask or null
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setMask(com.sk89q.worldedit.masks.Mask mask) {
|
||||
setMask(mask != null ? Masks.wrap(mask) : null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,10 +37,6 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
import com.sk89q.worldedit.masks.Mask;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.scripting.CraftScriptContext;
|
||||
import com.sk89q.worldedit.scripting.CraftScriptEngine;
|
||||
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
|
||||
@ -313,32 +309,6 @@ public class WorldEdit {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getPatternFactory()} and {@link BlockFactory#parseFromInput(String, ParserContext)}
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public Pattern getBlockPattern(Player player, String input) throws WorldEditException {
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(getSession(player));
|
||||
return Patterns.wrap(getPatternFactory().parseFromInput(input, context));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getMaskFactory()} ()} and {@link MaskFactory#parseFromInput(String, ParserContext)}
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public Mask getBlockMask(Player player, LocalSession session, String input) throws WorldEditException {
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(session);
|
||||
return Masks.wrap(getMaskFactory().parseFromInput(input, context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path to a file. This method will check to see if the filename
|
||||
* has valid characters and has an extension. It also prevents directory
|
||||
|
@ -25,7 +25,6 @@ import com.sk89q.worldedit.world.World;
|
||||
/**
|
||||
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public class WorldVector extends Vector {
|
||||
|
||||
@ -127,7 +126,7 @@ public class WorldVector extends Vector {
|
||||
|
||||
/**
|
||||
* Gets a BlockVector version.
|
||||
*
|
||||
*
|
||||
* @return BlockWorldVector
|
||||
*/
|
||||
public BlockWorldVector toWorldBlockVector() {
|
||||
|
@ -22,7 +22,6 @@ package com.sk89q.worldedit;
|
||||
/**
|
||||
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public class WorldVectorFace extends WorldVector {
|
||||
|
||||
|
@ -25,7 +25,6 @@ import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.CuboidClipboard.FlipDirection;
|
||||
import com.sk89q.worldedit.blocks.type.BlockType;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.foundation.Block;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
import com.sk89q.worldedit.world.registry.state.State;
|
||||
@ -54,8 +53,7 @@ import javax.annotation.Nullable;
|
||||
* as a "wildcard" block value, even though a {@link Mask} would be
|
||||
* more appropriate.</p>
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BaseBlock extends Block implements TileEntityBlock {
|
||||
public class BaseBlock implements TileEntityBlock {
|
||||
|
||||
// Instances of this class should be _as small as possible_ because there will
|
||||
// be millions of instances of this object.
|
||||
@ -158,7 +156,6 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
||||
*
|
||||
* @return legacy numerical ID
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getId() {
|
||||
return this.blockType.getLegacyId();
|
||||
@ -182,7 +179,6 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
||||
*
|
||||
* @param id block id
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setId(int id) {
|
||||
internalSetId(id);
|
||||
@ -210,7 +206,6 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
||||
*
|
||||
* @return data value (0-15)
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getData() {
|
||||
return 0;
|
||||
@ -268,7 +263,6 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
||||
*
|
||||
* @param data block data value
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setData(int data) {
|
||||
internalSetData(data);
|
||||
@ -282,7 +276,6 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
||||
* @see #setId(int)
|
||||
* @see #setData(int)
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setIdAndData(int id, int data) {
|
||||
setId(id);
|
||||
@ -294,7 +287,6 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
||||
*
|
||||
* @return true if there are no matched states
|
||||
*/
|
||||
@Override
|
||||
public boolean hasWildcardData() {
|
||||
return getStates().isEmpty();
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -117,7 +116,7 @@ public class GenerationCommands {
|
||||
worldEdit.checkMaxRadius(height);
|
||||
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
int affected = editSession.makeCylinder(pos, Patterns.wrap(pattern), radiusX, radiusZ, height, !hollow);
|
||||
int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow);
|
||||
player.print(affected + " block(s) have been created.");
|
||||
}
|
||||
|
||||
@ -182,7 +181,7 @@ public class GenerationCommands {
|
||||
pos = pos.add(0, radiusY, 0);
|
||||
}
|
||||
|
||||
int affected = editSession.makeSphere(pos, Patterns.wrap(pattern), radiusX, radiusY, radiusZ, !hollow);
|
||||
int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
}
|
||||
@ -243,7 +242,7 @@ public class GenerationCommands {
|
||||
public void pyramid(Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow) throws WorldEditException {
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
worldEdit.checkMaxRadius(size);
|
||||
int affected = editSession.makePyramid(pos, Patterns.wrap(pattern), size, !hollow);
|
||||
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
}
|
||||
@ -306,7 +305,7 @@ public class GenerationCommands {
|
||||
}
|
||||
|
||||
try {
|
||||
final int affected = editSession.makeShape(region, zero, unit, Patterns.wrap(pattern), expression, hollow);
|
||||
final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
} catch (ExpressionException e) {
|
||||
|
@ -33,7 +33,6 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
@ -106,7 +105,7 @@ public class RegionCommands {
|
||||
CuboidRegion cuboidregion = (CuboidRegion) region;
|
||||
Vector pos1 = cuboidregion.getPos1();
|
||||
Vector pos2 = cuboidregion.getPos2();
|
||||
int blocksChanged = editSession.drawLine(Patterns.wrap(pattern), pos1, pos2, thickness, !shell);
|
||||
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
|
||||
|
||||
player.print(blocksChanged + " block(s) have been changed.");
|
||||
}
|
||||
@ -137,9 +136,9 @@ public class RegionCommands {
|
||||
}
|
||||
|
||||
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
|
||||
List<Vector> vectors = new ArrayList<Vector>(cpregion.getVertices());
|
||||
List<Vector> vectors = new ArrayList<>(cpregion.getVertices());
|
||||
|
||||
int blocksChanged = editSession.drawSpline(Patterns.wrap(pattern), vectors, 0, 0, 0, 10, thickness, !shell);
|
||||
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
|
||||
|
||||
player.print(blocksChanged + " block(s) have been changed.");
|
||||
}
|
||||
@ -158,7 +157,7 @@ public class RegionCommands {
|
||||
if (from == null) {
|
||||
from = new ExistingBlockMask(editSession);
|
||||
}
|
||||
int affected = editSession.replaceBlocks(region, from, Patterns.wrap(to));
|
||||
int affected = editSession.replaceBlocks(region, from, to);
|
||||
player.print(affected + " block(s) have been replaced.");
|
||||
}
|
||||
|
||||
@ -172,7 +171,7 @@ public class RegionCommands {
|
||||
@CommandPermissions("worldedit.region.overlay")
|
||||
@Logging(REGION)
|
||||
public void overlay(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.overlayCuboidBlocks(region, Patterns.wrap(pattern));
|
||||
int affected = editSession.overlayCuboidBlocks(region, pattern);
|
||||
player.print(affected + " block(s) have been overlaid.");
|
||||
}
|
||||
|
||||
@ -186,7 +185,7 @@ public class RegionCommands {
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.region.center")
|
||||
public void center(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.center(region, Patterns.wrap(pattern));
|
||||
int affected = editSession.center(region, pattern);
|
||||
player.print("Center set ("+ affected + " blocks changed)");
|
||||
}
|
||||
|
||||
@ -214,7 +213,7 @@ public class RegionCommands {
|
||||
@CommandPermissions("worldedit.region.walls")
|
||||
@Logging(REGION)
|
||||
public void walls(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.makeCuboidWalls(region, Patterns.wrap(pattern));
|
||||
int affected = editSession.makeCuboidWalls(region, pattern);
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
}
|
||||
|
||||
@ -228,7 +227,7 @@ public class RegionCommands {
|
||||
@CommandPermissions("worldedit.region.faces")
|
||||
@Logging(REGION)
|
||||
public void faces(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.makeCuboidFaces(region, Patterns.wrap(pattern));
|
||||
int affected = editSession.makeCuboidFaces(region, pattern);
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
}
|
||||
|
||||
@ -422,7 +421,7 @@ public class RegionCommands {
|
||||
@Optional("0") @Range(min = 0) int thickness,
|
||||
@Optional("air") Pattern pattern) throws WorldEditException {
|
||||
|
||||
int affected = editSession.hollowOutRegion(region, thickness, Patterns.wrap(pattern));
|
||||
int affected = editSession.hollowOutRegion(region, thickness, pattern);
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,9 @@ import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.ItemType;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.command.tool.*;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
|
||||
public class ToolCommands {
|
||||
@ -139,7 +140,12 @@ public class ToolCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
session.setTool(player.getItemInHand(), new FloodFillTool(range, pattern));
|
||||
player.print("Block flood fill tool bound to "
|
||||
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
@ -87,7 +87,7 @@ public class FloodFillTool implements BlockTool {
|
||||
visited.add(pos);
|
||||
|
||||
if (editSession.getBlock(pos).getType().getLegacyId() == initialType) {
|
||||
editSession.setBlock(pos, pattern.next(pos));
|
||||
editSession.setBlock(pos, pattern.apply(pos));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -23,11 +23,9 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
|
||||
public class CylinderBrush implements Brush {
|
||||
|
||||
@ -42,7 +40,7 @@ public class CylinderBrush implements Brush {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(new BaseBlock(BlockTypes.COBBLESTONE));
|
||||
}
|
||||
editSession.makeCylinder(position, Patterns.wrap(pattern), size, size, height, true);
|
||||
editSession.makeCylinder(position, pattern, size, size, height, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,11 +23,9 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
|
||||
public class HollowCylinderBrush implements Brush {
|
||||
|
||||
@ -42,7 +40,7 @@ public class HollowCylinderBrush implements Brush {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(new BaseBlock(BlockTypes.COBBLESTONE));
|
||||
}
|
||||
editSession.makeCylinder(position, Patterns.wrap(pattern), size, size, height, false);
|
||||
editSession.makeCylinder(position, pattern, size, size, height, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,11 +23,9 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
|
||||
public class HollowSphereBrush implements Brush {
|
||||
|
||||
@ -36,6 +34,6 @@ public class HollowSphereBrush implements Brush {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(new BaseBlock(BlockTypes.COBBLESTONE));
|
||||
}
|
||||
editSession.makeSphere(position, Patterns.wrap(pattern), size, size, size, false);
|
||||
editSession.makeSphere(position, pattern, size, size, size, false);
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,9 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
|
||||
public class SphereBrush implements Brush {
|
||||
|
||||
@ -36,6 +34,6 @@ public class SphereBrush implements Brush {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(new BaseBlock(BlockTypes.COBBLESTONE));
|
||||
}
|
||||
editSession.makeSphere(position, Patterns.wrap(pattern), size, size, size, true);
|
||||
editSession.makeSphere(position, pattern, size, size, size, true);
|
||||
}
|
||||
}
|
||||
|
@ -19,14 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.LayerFunction;
|
||||
import com.sk89q.worldedit.masks.BlockMask;
|
||||
import com.sk89q.worldedit.masks.Mask;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -37,11 +38,12 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class Naturalizer implements LayerFunction {
|
||||
|
||||
private static final BaseBlock grass = new BaseBlock(BlockTypes.GRASS_BLOCK);
|
||||
private static final BaseBlock dirt = new BaseBlock(BlockTypes.DIRT);
|
||||
private static final BaseBlock stone = new BaseBlock(BlockTypes.STONE);
|
||||
|
||||
private final EditSession editSession;
|
||||
private final BaseBlock grass = new BaseBlock(BlockTypes.GRASS_BLOCK);
|
||||
private final BaseBlock dirt = new BaseBlock(BlockTypes.DIRT);
|
||||
private final BaseBlock stone = new BaseBlock(BlockTypes.STONE);
|
||||
private final Mask mask = new BlockMask(grass, dirt, stone);
|
||||
private final Mask mask;
|
||||
private int affected = 0;
|
||||
|
||||
/**
|
||||
@ -52,6 +54,7 @@ public class Naturalizer implements LayerFunction {
|
||||
public Naturalizer(EditSession editSession) {
|
||||
checkNotNull(editSession);
|
||||
this.editSession = editSession;
|
||||
this.mask = new BlockMask(editSession, Sets.newHashSet(grass, dirt, stone));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,12 +68,12 @@ public class Naturalizer implements LayerFunction {
|
||||
|
||||
@Override
|
||||
public boolean isGround(Vector position) {
|
||||
return mask.matches(editSession, position);
|
||||
return mask.test(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position, int depth) throws WorldEditException {
|
||||
if (mask.matches(editSession, position)) {
|
||||
if (mask.test(position)) {
|
||||
affected++;
|
||||
switch (depth) {
|
||||
case 0:
|
||||
|
@ -131,82 +131,6 @@ public final class Masks {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap an old-style mask and convert it to a new mask.
|
||||
*
|
||||
* <p>Note, however, that this is strongly not recommended because
|
||||
* {@link com.sk89q.worldedit.masks.Mask#prepare(LocalSession, LocalPlayer, Vector)}
|
||||
* is not called.</p>
|
||||
*
|
||||
* @param mask the old-style mask
|
||||
* @param editSession the edit session to bind to
|
||||
* @return a new-style mask
|
||||
* @deprecated Please avoid if possible
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Mask wrap(final com.sk89q.worldedit.masks.Mask mask, final EditSession editSession) {
|
||||
checkNotNull(mask);
|
||||
return new AbstractMask() {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
return mask.matches(editSession, vector);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap an old-style mask and convert it to a new mask.
|
||||
*
|
||||
* <p>As an {@link EditSession} is not provided in this case, one will be
|
||||
* taken from the {@link Request}, if possible. If not possible, then the
|
||||
* mask will return false.</p>
|
||||
*
|
||||
* @param mask the old-style mask
|
||||
* @return a new-style mask
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Mask wrap(final com.sk89q.worldedit.masks.Mask mask) {
|
||||
checkNotNull(mask);
|
||||
return new AbstractMask() {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
EditSession editSession = Request.request().getEditSession();
|
||||
return editSession != null && mask.matches(editSession, vector);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a new-style mask to an old-style mask.
|
||||
*
|
||||
* @param mask the new-style mask
|
||||
* @return an old-style mask
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static com.sk89q.worldedit.masks.Mask wrap(final Mask mask) {
|
||||
checkNotNull(mask);
|
||||
return new com.sk89q.worldedit.masks.AbstractMask() {
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
Request.request().setEditSession(editSession);
|
||||
return mask.test(position);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static class AlwaysTrue implements Mask, Mask2D {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* 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.function.pattern;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Utility methods related to {@link Pattern}s.
|
||||
*/
|
||||
public final class Patterns {
|
||||
|
||||
private Patterns() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap an old-style pattern and return a new pattern.
|
||||
*
|
||||
* @param pattern the pattern
|
||||
* @return a new-style pattern
|
||||
*/
|
||||
public static Pattern wrap(final com.sk89q.worldedit.patterns.Pattern pattern) {
|
||||
checkNotNull(pattern);
|
||||
return new Pattern() {
|
||||
@Override
|
||||
public BaseBlock apply(Vector position) {
|
||||
return pattern.next(position);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a new-style pattern and return an old-style pattern.
|
||||
*
|
||||
* @param pattern the pattern
|
||||
* @return an old-style pattern
|
||||
*/
|
||||
public static com.sk89q.worldedit.patterns.Pattern wrap(final Pattern pattern) {
|
||||
checkNotNull(pattern);
|
||||
return new com.sk89q.worldedit.patterns.Pattern() {
|
||||
@Override
|
||||
public BaseBlock next(Vector position) {
|
||||
return pattern.apply(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock next(int x, int y, int z) {
|
||||
return next(new Vector(x, y, z));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -48,14 +48,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
this(null, pos1, pos2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated cast {@code world} to {@link World}
|
||||
*/
|
||||
@Deprecated
|
||||
public CuboidRegion(LocalWorld world, Vector pos1, Vector pos2) {
|
||||
this((World) world, pos1, pos2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance of this cuboid using two corners of the cuboid.
|
||||
*
|
||||
|
@ -48,7 +48,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Creates a {@code ConvexPolyhedralRegion} from a user's selections.
|
||||
*/
|
||||
public class ConvexPolyhedralRegionSelector extends com.sk89q.worldedit.regions.ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
private final transient ConvexPolyhedralRegion region;
|
||||
private transient BlockVector pos1;
|
||||
|
@ -38,7 +38,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Creates a {@code CuboidRegion} from a user's selections.
|
||||
*/
|
||||
public class CuboidRegionSelector extends com.sk89q.worldedit.regions.CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
protected transient BlockVector position1;
|
||||
protected transient BlockVector position2;
|
||||
|
@ -38,7 +38,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Creates a {@code CylinderRegionSelector} from a user's selections.
|
||||
*/
|
||||
public class CylinderRegionSelector extends com.sk89q.worldedit.regions.CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
protected static transient final NumberFormat NUMBER_FORMAT;
|
||||
protected transient CylinderRegion region;
|
||||
|
@ -39,7 +39,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Creates a {@code EllipsoidRegionSelector} from a user's selections.
|
||||
*/
|
||||
public class EllipsoidRegionSelector extends com.sk89q.worldedit.regions.EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
protected transient EllipsoidRegion region;
|
||||
protected transient boolean started = false;
|
||||
|
@ -41,7 +41,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Creates a {@code Polygonal2DRegion} from a user's selections.
|
||||
*/
|
||||
public class Polygonal2DRegionSelector extends com.sk89q.worldedit.regions.Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
private transient BlockVector pos1;
|
||||
private transient Polygonal2DRegion region;
|
||||
@ -248,7 +248,6 @@ public class Polygonal2DRegionSelector extends com.sk89q.worldedit.regions.Polyg
|
||||
*
|
||||
* @return the number of points
|
||||
*/
|
||||
@Override
|
||||
public int getPointCount() {
|
||||
return region.getPoints().size();
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
/**
|
||||
@ -92,7 +92,7 @@ public abstract class ArbitraryShape {
|
||||
switch (cacheEntry) {
|
||||
case 0:
|
||||
// unknown, fetch material
|
||||
final BaseBlock material = getMaterial(x, y, z, pattern.next(new BlockVector(x, y, z)));
|
||||
final BaseBlock material = getMaterial(x, y, z, pattern.apply(new BlockVector(x, y, z)));
|
||||
if (material == null) {
|
||||
// outside
|
||||
cache[index] = -1;
|
||||
@ -156,7 +156,7 @@ public abstract class ArbitraryShape {
|
||||
int z = position.getBlockZ();
|
||||
|
||||
if (!hollow) {
|
||||
final BaseBlock material = getMaterial(x, y, z, pattern.next(position));
|
||||
final BaseBlock material = getMaterial(x, y, z, pattern.apply(position));
|
||||
if (material != null && editSession.setBlock(position, material)) {
|
||||
++affected;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.CuboidClipboard;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.data.DataException;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
@ -138,7 +138,7 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
List<Tag> tileEntities = getChildTag(schematic, "TileEntities", ListTag.class)
|
||||
.getValue();
|
||||
Map<BlockVector, Map<String, Tag>> tileEntitiesMap =
|
||||
new HashMap<BlockVector, Map<String, Tag>>();
|
||||
new HashMap<>();
|
||||
|
||||
for (Tag tag : tileEntities) {
|
||||
if (!(tag instanceof CompoundTag)) continue;
|
||||
@ -148,7 +148,7 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, Tag> entry : t.getValue().entrySet()) {
|
||||
if (entry.getKey().equals("x")) {
|
||||
@ -216,7 +216,7 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
throw new DataException("Length of region too large for a .schematic");
|
||||
}
|
||||
|
||||
HashMap<String, Tag> schematic = new HashMap<String, Tag>();
|
||||
HashMap<String, Tag> schematic = new HashMap<>();
|
||||
schematic.put("Width", new ShortTag((short) width));
|
||||
schematic.put("Length", new ShortTag((short) length));
|
||||
schematic.put("Height", new ShortTag((short) height));
|
||||
@ -232,7 +232,7 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
byte[] blocks = new byte[width * height * length];
|
||||
byte[] addBlocks = null;
|
||||
byte[] blockData = new byte[width * height * length];
|
||||
ArrayList<Tag> tileEntities = new ArrayList<Tag>();
|
||||
ArrayList<Tag> tileEntities = new ArrayList<>();
|
||||
|
||||
for (int x = 0; x < width; ++x) {
|
||||
for (int y = 0; y < height; ++y) {
|
||||
@ -257,7 +257,7 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
// Get the list of key/values from the block
|
||||
CompoundTag rawTag = block.getNbtData();
|
||||
if (rawTag != null) {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
for (Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ package com.sk89q.worldedit.schematic;
|
||||
|
||||
import com.sk89q.worldedit.CuboidClipboard;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.data.DataException;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -29,13 +30,13 @@ import java.util.*;
|
||||
|
||||
public abstract class SchematicFormat {
|
||||
|
||||
private static final Map<String, SchematicFormat> SCHEMATIC_FORMATS = new HashMap<String, SchematicFormat>();
|
||||
private static final Map<String, SchematicFormat> SCHEMATIC_FORMATS = new HashMap<>();
|
||||
|
||||
// Built-in schematic formats
|
||||
public static final SchematicFormat MCEDIT = new MCEditSchematicFormat();
|
||||
|
||||
public static Set<SchematicFormat> getFormats() {
|
||||
return Collections.unmodifiableSet(new HashSet<SchematicFormat>(SCHEMATIC_FORMATS.values()));
|
||||
return Collections.unmodifiableSet(new HashSet<>(SCHEMATIC_FORMATS.values()));
|
||||
}
|
||||
|
||||
public static SchematicFormat getFormat(String lookupName) {
|
||||
@ -60,7 +61,7 @@ public abstract class SchematicFormat {
|
||||
|
||||
protected SchematicFormat(String name, String... lookupNames) {
|
||||
this.name = name;
|
||||
List<String> registeredLookupNames = new ArrayList<String>(lookupNames.length);
|
||||
List<String> registeredLookupNames = new ArrayList<>(lookupNames.length);
|
||||
for (int i = 0; i < lookupNames.length; ++i) {
|
||||
if (i == 0 || !SCHEMATIC_FORMATS.containsKey(lookupNames[i].toLowerCase())) {
|
||||
SCHEMATIC_FORMATS.put(lookupNames[i].toLowerCase(), this);
|
||||
|
@ -23,8 +23,9 @@ import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.command.InsufficientArgumentsException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||
|
||||
import java.io.File;
|
||||
@ -36,10 +37,9 @@ import java.util.Set;
|
||||
/**
|
||||
* The context given to scripts.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
|
||||
private List<EditSession> editSessions = new ArrayList<EditSession>();
|
||||
private List<EditSession> editSessions = new ArrayList<>();
|
||||
private String[] args;
|
||||
|
||||
public CraftScriptContext(WorldEdit controller,
|
||||
@ -176,7 +176,11 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
* @throws DisallowedItemException
|
||||
*/
|
||||
public Pattern getBlockPattern(String list) throws WorldEditException {
|
||||
return controller.getBlockPattern(player, list);
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(session);
|
||||
return controller.getPatternFactory().parseFromInput(list, context);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user