More deprecation removal

This commit is contained in:
Matthew Miller
2018-06-16 16:36:55 +10:00
parent 20bf6e079b
commit aaaf2d5678
152 changed files with 701 additions and 1150 deletions

View File

@ -31,7 +31,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class CombinedRegionFunction implements RegionFunction {
private final List<RegionFunction> functions = new ArrayList<RegionFunction>();
private final List<RegionFunction> functions = new ArrayList<>();
/**
* Create a combined region function.

View File

@ -23,7 +23,6 @@ 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.BlockID;
import com.sk89q.worldedit.blocks.type.BlockType;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.function.RegionFunction;

View File

@ -24,7 +24,6 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.pattern.BlockPattern;
@ -98,7 +97,7 @@ public class GardenPatchGenerator implements RegionFunction {
}
}
editSession.setBlockIfAir(pos, new BaseBlock(BlockTypes.OAK_LEAVES));
setBlockIfAir(editSession, pos, new BaseBlock(BlockTypes.OAK_LEAVES));
affected++;
int t = random.nextInt(4);
@ -113,10 +112,10 @@ public class GardenPatchGenerator implements RegionFunction {
placeVine(basePos, pos.add(1, 0, 0));
}
if (random.nextBoolean()) {
editSession.setBlockIfAir(pos.add(1, h, -1), log);
setBlockIfAir(editSession, pos.add(1, h, -1), log);
affected++;
}
editSession.setBlockIfAir(p = pos.add(0, 0, -1), plant.apply(p));
setBlockIfAir(editSession, p = pos.add(0, 0, -1), plant.apply(p));
affected++;
break;
@ -125,10 +124,10 @@ public class GardenPatchGenerator implements RegionFunction {
placeVine(basePos, pos.add(0, 0, 1));
}
if (random.nextBoolean()) {
editSession.setBlockIfAir(pos.add(1, h, 0), log);
setBlockIfAir(editSession, pos.add(1, h, 0), log);
affected++;
}
editSession.setBlockIfAir(p = pos.add(1, 0, 1), plant.apply(p));
setBlockIfAir(editSession, p = pos.add(1, 0, 1), plant.apply(p));
affected++;
break;
@ -137,10 +136,10 @@ public class GardenPatchGenerator implements RegionFunction {
placeVine(basePos, pos.add(0, 0, -1));
}
if (random.nextBoolean()) {
editSession.setBlockIfAir(pos.add(-1, h, 0), log);
setBlockIfAir(editSession, pos.add(-1, h, 0), log);
affected++;
}
editSession.setBlockIfAir(p = pos.add(-1, 0, 1), plant.apply(p));
setBlockIfAir(editSession, p = pos.add(-1, 0, 1), plant.apply(p));
affected++;
break;
@ -149,10 +148,10 @@ public class GardenPatchGenerator implements RegionFunction {
placeVine(basePos, pos.add(-1, 0, 0));
}
if (random.nextBoolean()) {
editSession.setBlockIfAir(pos.add(-1, h, -1), log);
setBlockIfAir(editSession, pos.add(-1, h, -1), log);
affected++;
}
editSession.setBlockIfAir(p = pos.add(-1, 0, -1), plant.apply(p));
setBlockIfAir(editSession, p = pos.add(-1, 0, -1), plant.apply(p));
affected++;
break;
}
@ -195,6 +194,18 @@ public class GardenPatchGenerator implements RegionFunction {
return pattern;
}
/**
* Set a block only if there's no block already there.
*
* @param position the position
* @param block the block to set
* @return if block was changed
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
private static boolean setBlockIfAir(EditSession session, Vector position, BaseBlock block) throws MaxChangedBlocksException {
return session.getBlock(position).isAir() && session.setBlock(position, block);
}
/**
* Get a pattern that creates melons.
*

View File

@ -36,7 +36,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
public class BiomeMask2D extends AbstractMask2D {
private final Extent extent;
private final Set<BaseBiome> biomes = new HashSet<BaseBiome>();
private final Set<BaseBiome> biomes = new HashSet<>();
/**
* Create a new biome mask.

View File

@ -40,7 +40,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class BlockMask extends AbstractExtentMask {
private final Set<BaseBlock> blocks = new HashSet<BaseBlock>();
private final Set<BaseBlock> blocks = new HashSet<>();
/**
* Create a new block mask.

View File

@ -21,7 +21,6 @@ package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockID;
import javax.annotation.Nullable;

View File

@ -38,7 +38,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class MaskIntersection extends AbstractMask {
private final Set<Mask> masks = new HashSet<Mask>();
private final Set<Mask> masks = new HashSet<>();
/**
* Create a new intersection.
@ -105,7 +105,7 @@ public class MaskIntersection extends AbstractMask {
@Nullable
@Override
public Mask2D toMask2D() {
List<Mask2D> mask2dList = new ArrayList<Mask2D>();
List<Mask2D> mask2dList = new ArrayList<>();
for (Mask mask : masks) {
Mask2D mask2d = mask.toMask2D();
if (mask2d != null) {

View File

@ -33,7 +33,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class MaskIntersection2D implements Mask2D {
private final Set<Mask2D> masks = new HashSet<Mask2D>();
private final Set<Mask2D> masks = new HashSet<>();
/**
* Create a new intersection.

View File

@ -67,7 +67,7 @@ public class MaskUnion extends MaskIntersection {
@Nullable
@Override
public Mask2D toMask2D() {
List<Mask2D> mask2dList = new ArrayList<Mask2D>();
List<Mask2D> mask2dList = new ArrayList<>();
for (Mask mask : getMasks()) {
Mask2D mask2d = mask.toMask2D();
if (mask2d != null) {

View File

@ -20,7 +20,6 @@
package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.session.request.Request;
import javax.annotation.Nullable;

View File

@ -35,7 +35,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
public class OperationQueue implements Operation {
private final List<Operation> operations = Lists.newArrayList();
private final Deque<Operation> queue = new ArrayDeque<Operation>();
private final Deque<Operation> queue = new ArrayDeque<>();
private Operation current;
/**

View File

@ -34,7 +34,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
public class RandomPattern extends AbstractPattern {
private final Random random = new Random();
private List<Chance> patterns = new ArrayList<Chance>();
private List<Chance> patterns = new ArrayList<>();
private double max = 0;
/**

View File

@ -44,9 +44,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
public abstract class BreadthFirstSearch implements Operation {
private final RegionFunction function;
private final Queue<BlockVector> queue = new ArrayDeque<BlockVector>();
private final Set<BlockVector> visited = new HashSet<BlockVector>();
private final List<Vector> directions = new ArrayList<Vector>();
private final Queue<BlockVector> queue = new ArrayDeque<>();
private final Set<BlockVector> visited = new HashSet<>();
private final List<Vector> directions = new ArrayList<>();
private int affected = 0;
/**