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

@@ -141,7 +141,7 @@ public class BiomeCommands {
qualifier = "at line of sight point";
} else if (args.hasFlag('p')) {
BaseBiome biome = player.getWorld().getBiome(player.getPosition().toVector().toVector2D());
BaseBiome biome = player.getWorld().getBiome(player.getLocation().toVector().toVector2D());
biomes.add(biome);
qualifier = "at your position";
@@ -192,7 +192,7 @@ public class BiomeCommands {
Mask2D mask2d = mask != null ? mask.toMask2D() : null;
if (atPosition) {
region = new CuboidRegion(player.getPosition().toVector(), player.getPosition().toVector());
region = new CuboidRegion(player.getLocation().toVector(), player.getLocation().toVector());
} else {
region = session.getSelection(world);
}

View File

@@ -29,7 +29,6 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
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.command.tool.BrushTool;
import com.sk89q.worldedit.command.tool.brush.ButcherBrush;

View File

@@ -195,7 +195,6 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.forest")
@Logging(POSITION)
@SuppressWarnings("deprecation")
public void forestGen(Player player, LocalSession session, EditSession editSession, @Optional("10") int size, @Optional("tree") TreeType type, @Optional("5") double density) throws WorldEditException {
density = density / 100;
int affected = editSession.makeForest(session.getPlacementPosition(player), size, density, new TreeGenerator(type));

View File

@@ -60,7 +60,7 @@ public class HistoryCommands {
undone = session.undo(session.getBlockBag(player), player);
} else {
player.checkPermission("worldedit.history.undo.other");
LocalSession sess = worldEdit.getSession(args.getString(1));
LocalSession sess = worldEdit.getSessionManager().findByName(args.getString(1));
if (sess == null) {
player.printError("Unable to find session for " + args.getString(1));
break;
@@ -95,7 +95,7 @@ public class HistoryCommands {
redone = session.redo(session.getBlockBag(player), player);
} else {
player.checkPermission("worldedit.history.redo.other");
LocalSession sess = worldEdit.getSession(args.getString(1));
LocalSession sess = worldEdit.getSessionManager().findByName(args.getString(1));
if (sess == null) {
player.printError("Unable to find session for " + args.getString(1));
break;

View File

@@ -19,6 +19,8 @@
package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException;
@@ -52,14 +54,11 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Commands that work with schematic files.
*/
@@ -107,8 +106,7 @@ public class SchematicCommands {
return;
}
Closer closer = Closer.create();
try {
try (Closer closer = Closer.create()) {
FileInputStream fis = closer.register(new FileInputStream(f));
BufferedInputStream bis = closer.register(new BufferedInputStream(fis));
ClipboardReader reader = format.getReader(bis);
@@ -122,11 +120,6 @@ public class SchematicCommands {
} catch (IOException e) {
player.printError("Schematic could not read or it does not exist: " + e.getMessage());
log.log(Level.WARNING, "Failed to load a saved clipboard", e);
} finally {
try {
closer.close();
} catch (IOException ignored) {
}
}
}
@@ -165,8 +158,7 @@ public class SchematicCommands {
target = clipboard;
}
Closer closer = Closer.create();
try {
try (Closer closer = Closer.create()) {
// Create parent directories
File parent = f.getParentFile();
if (parent != null && !parent.exists()) {
@@ -184,11 +176,6 @@ public class SchematicCommands {
} catch (IOException e) {
player.printError("Schematic could not written: " + e.getMessage());
log.log(Level.WARNING, "Failed to write a saved clipboard", e);
} finally {
try {
closer.close();
} catch (IOException ignored) {
}
}
}
@@ -283,24 +270,21 @@ public class SchematicCommands {
final int sortType = args.hasFlag('d') ? -1 : args.hasFlag('n') ? 1 : 0;
// cleanup file list
Arrays.sort(files, new Comparator<File>(){
@Override
public int compare(File f1, File f2) {
// http://stackoverflow.com/questions/203030/best-way-to-list-files-in-java-sorted-by-date-modified
int res;
if (sortType == 0) { // use name by default
int p = f1.getParent().compareTo(f2.getParent());
if (p == 0) { // same parent, compare names
res = f1.getName().compareTo(f2.getName());
} else { // different parent, sort by that
res = p;
}
} else {
res = Long.valueOf(f1.lastModified()).compareTo(f2.lastModified()); // use date if there is a flag
if (sortType == 1) res = -res; // flip date for newest first instead of oldest first
Arrays.sort(files, (f1, f2) -> {
// http://stackoverflow.com/questions/203030/best-way-to-list-files-in-java-sorted-by-date-modified
int res;
if (sortType == 0) { // use name by default
int p = f1.getParent().compareTo(f2.getParent());
if (p == 0) { // same parent, compare names
res = f1.getName().compareTo(f2.getName());
} else { // different parent, sort by that
res = p;
}
return res;
} else {
res = Long.compare(f1.lastModified(), f2.lastModified()); // use date if there is a flag
if (sortType == 1) res = -res; // flip date for newest first instead of oldest first
}
return res;
});
List<String> schematics = listFiles(worldEdit.getConfiguration().saveDir, files);
@@ -322,7 +306,7 @@ public class SchematicCommands {
private List<File> allFiles(File root) {
File[] files = root.listFiles();
if (files == null) return null;
List<File> fileList = new ArrayList<File>();
List<File> fileList = new ArrayList<>();
for (File f : files) {
if (f.isDirectory()) {
List<File> subFiles = allFiles(f);
@@ -337,7 +321,7 @@ public class SchematicCommands {
private List<String> listFiles(String prefix, File[] files) {
if (prefix == null) prefix = "";
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
for (File file : files) {
StringBuilder build = new StringBuilder();

View File

@@ -19,7 +19,9 @@
package com.sk89q.worldedit.command;
import com.google.common.base.Optional;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException;
@@ -59,11 +61,9 @@ import com.sk89q.worldedit.world.storage.ChunkStore;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
/**
* Selection commands.
*/
@@ -332,7 +332,7 @@ public class SelectionCommands {
return;
}
List<Vector> dirs = new ArrayList<Vector>();
List<Vector> dirs = new ArrayList<>();
int change = args.getInteger(0);
int reverseChange = 0;
@@ -405,7 +405,7 @@ public class SelectionCommands {
@CommandPermissions("worldedit.selection.contract")
public void contract(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
List<Vector> dirs = new ArrayList<Vector>();
List<Vector> dirs = new ArrayList<>();
int change = args.getInteger(0);
int reverseChange = 0;
@@ -480,7 +480,7 @@ public class SelectionCommands {
@CommandPermissions("worldedit.selection.shift")
public void shift(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
List<Vector> dirs = new ArrayList<Vector>();
List<Vector> dirs = new ArrayList<>();
int change = args.getInteger(0);
if (args.argsLength() == 2) {
if (args.getString(1).contains(",")) {
@@ -558,7 +558,7 @@ public class SelectionCommands {
}
private Vector[] getChangesForEachDir(CommandContext args) {
List<Vector> changes = new ArrayList<Vector>(6);
List<Vector> changes = new ArrayList<>(6);
int change = args.getInteger(0);
if (!args.hasFlag('h')) {
@@ -739,9 +739,7 @@ public class SelectionCommands {
selector = new Polygonal2DRegionSelector(oldSelector);
player.print("2D polygon selector: Left/right click to add a point.");
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolygonVertexLimit();
if (limit.isPresent()) {
player.print(limit.get() + " points maximum.");
}
limit.ifPresent(integer -> player.print(integer + " points maximum."));
} else if (typeName.equalsIgnoreCase("ellipsoid")) {
selector = new EllipsoidRegionSelector(oldSelector);
player.print("Ellipsoid selector: left click=center, right click to extend");
@@ -755,9 +753,7 @@ public class SelectionCommands {
selector = new ConvexPolyhedralRegionSelector(oldSelector);
player.print("Convex polyhedral selector: Left click=First vertex, right click to add more.");
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit();
if (limit.isPresent()) {
player.print(limit.get() + " points maximum.");
}
limit.ifPresent(integer -> player.print(integer + " points maximum."));
} else {
CommandListBox box = new CommandListBox("Selection modes");
StyledFragment contents = box.getContents();

View File

@@ -115,10 +115,7 @@ public class SnapshotUtilCommands {
try {
chunkStore = snapshot.getChunkStore();
player.print("Snapshot '" + snapshot.getName() + "' loaded; now restoring...");
} catch (DataException e) {
player.printError("Failed to load snapshot: " + e.getMessage());
return;
} catch (IOException e) {
} catch (DataException | IOException e) {
player.printError("Failed to load snapshot: " + e.getMessage());
return;
}

View File

@@ -74,7 +74,6 @@ public class ToolCommands {
max = 1
)
@CommandPermissions("worldedit.tool.tree")
@SuppressWarnings("deprecation")
public void tree(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
TreeGenerator.TreeType type = args.argsLength() > 0 ?

View File

@@ -426,7 +426,7 @@ public class UtilityCommands {
CreatureButcher flags = new CreatureButcher(actor);
flags.fromCommand(args);
List<EntityVisitor> visitors = new ArrayList<EntityVisitor>();
List<EntityVisitor> visitors = new ArrayList<>();
LocalSession session = null;
EditSession editSession = null;
@@ -486,7 +486,7 @@ public class UtilityCommands {
EntityRemover remover = new EntityRemover();
remover.fromString(typeStr);
List<EntityVisitor> visitors = new ArrayList<EntityVisitor>();
List<EntityVisitor> visitors = new ArrayList<>();
LocalSession session = null;
EditSession editSession = null;
@@ -606,7 +606,7 @@ public class UtilityCommands {
}
boolean isRootLevel = true;
List<String> visited = new ArrayList<String>();
List<String> visited = new ArrayList<>();
// Drill down to the command
for (int i = 0; i < effectiveLength; i++) {
@@ -646,8 +646,8 @@ public class UtilityCommands {
Dispatcher dispatcher = (Dispatcher) callable;
// Get a list of aliases
List<CommandMapping> aliases = new ArrayList<CommandMapping>(dispatcher.getCommands());
Collections.sort(aliases, new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
List<CommandMapping> aliases = new ArrayList<>(dispatcher.getCommands());
aliases.sort(new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
// Calculate pagination
int offset = perPage * page;

View File

@@ -61,8 +61,6 @@ public class PatternParser extends SimpleCommand<Pattern> {
try {
return WorldEdit.getInstance().getPatternFactory().parseFromInput(patternString, parserContext);
} catch (NoMatchException e) {
throw new CommandException(e.getMessage(), e);
} catch (InputParseException e) {
throw new CommandException(e.getMessage(), e);
}

View File

@@ -40,14 +40,17 @@ public class RegionFactoryParser implements CommandExecutor<RegionFactory> {
try {
String type = args.next();
if (type.equals("cuboid")) {
return new CuboidRegionFactory();
} else if (type.equals("sphere")) {
return new SphereRegionFactory();
} else if (type.equals("cyl") || type.equals("cylinder")) {
return new CylinderRegionFactory(1); // TODO: Adjustable height
} else {
throw new CommandException("Unknown shape type: " + type + " (try one of " + getUsage() + ")");
switch (type) {
case "cuboid":
return new CuboidRegionFactory();
case "sphere":
return new SphereRegionFactory();
case "cyl":
case "cylinder":
return new CylinderRegionFactory(1); // TODO: Adjustable height
default:
throw new CommandException("Unknown shape type: " + type + " (try one of " + getUsage() + ")");
}
} catch (MissingArgumentException e) {
throw new CommandException("Missing shape type (try one of " + getUsage() + ")");

View File

@@ -74,9 +74,7 @@ public class ShapedBrushCommand extends SimpleCommand<Object> {
BrushTool tool = session.getBrushTool(player.getItemInHand());
tool.setSize(radius);
tool.setBrush(new OperationFactoryBrush(factory, regionFactory), permission);
} catch (MaxBrushRadiusException e) {
WorldEdit.getInstance().getPlatformManager().getCommandManager().getExceptionConverter().convert(e);
} catch (InvalidToolBindException e) {
} catch (MaxBrushRadiusException | InvalidToolBindException e) {
WorldEdit.getInstance().getPlatformManager().getCommandManager().getExceptionConverter().convert(e);
}

View File

@@ -46,8 +46,9 @@ public class BlockDataCyler implements DoubleActionBlockTool {
World world = (World) clicked.getExtent();
int type = world.getBlockType(clicked.toVector());
int data = world.getBlockData(clicked.toVector());
BaseBlock block = world.getLazyBlock(clicked.toVector());
int type = block.getId();
int data = block.getData();
if (!config.allowedDataCycleBlocks.isEmpty()
&& !player.hasPermission("worldedit.override.data-cycler")
@@ -57,14 +58,14 @@ public class BlockDataCyler implements DoubleActionBlockTool {
}
int increment = forward ? 1 : -1;
BaseBlock block = new BaseBlock(type, BlockData.cycle(type, data, increment));
BaseBlock newBlock = new BaseBlock(type, BlockData.cycle(type, data, increment));
EditSession editSession = session.createEditSession(player);
if (block.getData() < 0) {
if (newBlock.getData() < 0) {
player.printError("That block's data cannot be cycled!");
} else {
try {
editSession.setBlock(clicked.toVector(), block);
editSession.setBlock(clicked.toVector(), newBlock);
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {

View File

@@ -56,7 +56,7 @@ public class FloatingTreeRemover implements BlockTool {
final World world = (World) clicked.getExtent();
switch (world.getBlockType(clicked.toVector())) {
switch (world.getLazyBlock(clicked.toVector()).getId()) {
case BlockID.LOG:
case BlockID.LOG2:
case BlockID.LEAVES:
@@ -119,8 +119,8 @@ public class FloatingTreeRemover implements BlockTool {
* @return a set containing all blocks in the tree/shroom or null if this is not a floating tree/shroom.
*/
private Set<Vector> bfs(World world, Vector origin) throws MaxChangedBlocksException {
final Set<Vector> visited = new HashSet<Vector>();
final LinkedList<Vector> queue = new LinkedList<Vector>();
final Set<Vector> visited = new HashSet<>();
final LinkedList<Vector> queue = new LinkedList<>();
queue.addLast(origin);
visited.add(origin);
@@ -135,7 +135,7 @@ public class FloatingTreeRemover implements BlockTool {
}
if (visited.add(next)) {
switch (world.getBlockType(next)) {
switch (world.getLazyBlock(next).getId()) {
case BlockID.AIR:
case BlockID.SNOW:
// we hit air or snow => stop walking this route
@@ -154,7 +154,7 @@ public class FloatingTreeRemover implements BlockTool {
default:
// we hit something solid - evaluate where we came from
final int curId = world.getBlockType(current);
final int curId = world.getLazyBlock(current).getId();
if (curId == BlockID.LEAVES || curId == BlockID.LEAVES2
|| curId == BlockID.VINE) {
// leaves touching a wall/the ground => stop walking this route

View File

@@ -20,7 +20,8 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.type.BlockType;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
@@ -53,13 +54,13 @@ public class FloodFillTool implements BlockTool {
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
World world = (World) clicked.getExtent();
int initialType = world.getBlockType(clicked.toVector());
BlockType initialType = world.getLazyBlock(clicked.toVector()).getType();
if (initialType == BlockID.AIR) {
if (initialType == BlockTypes.AIR) {
return true;
}
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
if (initialType == BlockTypes.BEDROCK && !player.canDestroyBedrock()) {
return true;
}
@@ -67,7 +68,7 @@ public class FloodFillTool implements BlockTool {
try {
recurse(server, editSession, world, clicked.toVector().toBlockVector(),
clicked.toVector(), range, initialType, new HashSet<BlockVector>());
clicked.toVector(), range, initialType.getLegacyId(), new HashSet<>());
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {

View File

@@ -21,7 +21,6 @@ package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
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.entity.Player;
@@ -69,7 +68,7 @@ public class RecursivePickaxe implements BlockTool {
try {
recurse(server, editSession, world, clicked.toVector().toBlockVector(),
clicked.toVector(), range, initialType, new HashSet<BlockVector>());
clicked.toVector(), range, initialType, new HashSet<>());
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {

View File

@@ -25,6 +25,7 @@ import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
@@ -43,7 +44,7 @@ public class SinglePickaxe implements BlockTool {
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
World world = (World) clicked.getExtent();
final int blockType = world.getBlockType(clicked.toVector());
final int blockType = world.getLazyBlock(clicked.toVector()).getId();
if (blockType == BlockID.BEDROCK
&& !player.canDestroyBedrock()) {
return true;
@@ -53,7 +54,7 @@ public class SinglePickaxe implements BlockTool {
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
try {
editSession.setBlock(clicked.toVector(), new BaseBlock(BlockID.AIR));
editSession.setBlock(clicked.toVector(), new BaseBlock(BlockTypes.AIR));
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {

View File

@@ -24,7 +24,6 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.util.*;
import com.sk89q.worldedit.util.Location;
/**
* Plants a tree.

View File

@@ -23,7 +23,6 @@ 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.Pattern;
@@ -44,7 +43,7 @@ public class GravityBrush implements Brush {
for (double x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
for (double z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
double y = startY;
final List<BaseBlock> blockTypes = new ArrayList<BaseBlock>();
final List<BaseBlock> blockTypes = new ArrayList<>();
for (; y > position.getBlockY() - size; --y) {
final Vector pt = new Vector(x, y, z);
final BaseBlock block = editSession.getBlock(pt);

View File

@@ -81,62 +81,59 @@ public class CreatureButcher {
}
public EntityFunction createFunction(final EntityRegistry entityRegistry) {
return new EntityFunction() {
@Override
public boolean apply(Entity entity) throws WorldEditException {
boolean killPets = (flags & Flags.PETS) != 0;
boolean killNPCs = (flags & Flags.NPCS) != 0;
boolean killAnimals = (flags & Flags.ANIMALS) != 0;
boolean killGolems = (flags & Flags.GOLEMS) != 0;
boolean killAmbient = (flags & Flags.AMBIENT) != 0;
boolean killTagged = (flags & Flags.TAGGED) != 0;
boolean killArmorStands = (flags & Flags.ARMOR_STAND) != 0;
return entity -> {
boolean killPets = (flags & Flags.PETS) != 0;
boolean killNPCs = (flags & Flags.NPCS) != 0;
boolean killAnimals = (flags & Flags.ANIMALS) != 0;
boolean killGolems = (flags & Flags.GOLEMS) != 0;
boolean killAmbient = (flags & Flags.AMBIENT) != 0;
boolean killTagged = (flags & Flags.TAGGED) != 0;
boolean killArmorStands = (flags & Flags.ARMOR_STAND) != 0;
EntityType type = entity.getFacet(EntityType.class);
EntityType type = entity.getFacet(EntityType.class);
if (type == null) {
return false;
}
if (type.isPlayerDerived()) {
return false;
}
if (!type.isLiving()) {
return false;
}
if (!killAnimals && type.isAnimal()) {
return false;
}
if (!killPets && type.isTamed()) {
return false;
}
if (!killGolems && type.isGolem()) {
return false;
}
if (!killNPCs && type.isNPC()) {
return false;
}
if (!killAmbient && type.isAmbient()) {
return false;
}
if (!killTagged && type.isTagged()) {
return false;
}
if (!killArmorStands && type.isArmorStand()) {
return false;
}
entity.remove();
return true;
if (type == null) {
return false;
}
if (type.isPlayerDerived()) {
return false;
}
if (!type.isLiving()) {
return false;
}
if (!killAnimals && type.isAnimal()) {
return false;
}
if (!killPets && type.isTamed()) {
return false;
}
if (!killGolems && type.isGolem()) {
return false;
}
if (!killNPCs && type.isNPC()) {
return false;
}
if (!killAmbient && type.isAmbient()) {
return false;
}
if (!killTagged && type.isTagged()) {
return false;
}
if (!killArmorStands && type.isArmorStand()) {
return false;
}
entity.remove();
return true;
};
}

View File

@@ -140,20 +140,17 @@ public class EntityRemover {
public EntityFunction createFunction(final EntityRegistry entityRegistry) {
final Type type = this.type;
checkNotNull("type can't be null", type);
return new EntityFunction() {
@Override
public boolean apply(Entity entity) throws WorldEditException {
EntityType registryType = entity.getFacet(EntityType.class);
if (registryType != null) {
if (type.matches(registryType)) {
entity.remove();
return true;
}
checkNotNull(type, "type can't be null");
return entity -> {
EntityType registryType = entity.getFacet(EntityType.class);
if (registryType != null) {
if (type.matches(registryType)) {
entity.remove();
return true;
}
return false;
}
return false;
};
}