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

@ -23,7 +23,6 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
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.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
@ -48,7 +47,7 @@ public class BlockArrayClipboard implements Clipboard {
private final Region region;
private Vector origin = new Vector();
private final BaseBlock[][][] blocks;
private final List<ClipboardEntity> entities = new ArrayList<ClipboardEntity>();
private final List<ClipboardEntity> entities = new ArrayList<>();
/**
* Create a new instance.
@ -98,7 +97,7 @@ public class BlockArrayClipboard implements Clipboard {
@Override
public List<? extends Entity> getEntities(Region region) {
List<Entity> filtered = new ArrayList<Entity>();
List<Entity> filtered = new ArrayList<>();
for (Entity entity : entities) {
if (region.contains(entity.getLocation().toVector())) {
filtered.add(entity);

View File

@ -65,9 +65,7 @@ public enum ClipboardFormat {
@Override
public boolean isFormat(File file) {
DataInputStream str = null;
try {
str = new DataInputStream(new GZIPInputStream(new FileInputStream(file)));
try (DataInputStream str = new DataInputStream(new GZIPInputStream(new FileInputStream(file)))) {
if ((str.readByte() & 0xFF) != NBTConstants.TYPE_COMPOUND) {
return false;
}
@ -77,18 +75,11 @@ public enum ClipboardFormat {
return name.equals("Schematic");
} catch (IOException e) {
return false;
} finally {
if (str != null) {
try {
str.close();
} catch (IOException ignored) {
}
}
}
}
};
private static final Map<String, ClipboardFormat> aliasMap = new HashMap<String, ClipboardFormat>();
private static final Map<String, ClipboardFormat> aliasMap = new HashMap<>();
private final String[] aliases;
@ -107,7 +98,7 @@ public enum ClipboardFormat {
* @return a set of aliases
*/
public Set<String> getAliases() {
return Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(aliases)));
return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(aliases)));
}
/**

View File

@ -160,7 +160,7 @@ public class SchematicReader implements ClipboardReader {
// Need to pull out tile entities
List<Tag> tileEntities = requireTag(schematic, "TileEntities", ListTag.class).getValue();
Map<BlockVector, Map<String, Tag>> tileEntitiesMap = new HashMap<BlockVector, Map<String, Tag>>();
Map<BlockVector, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
for (Tag tag : tileEntities) {
if (!(tag instanceof CompoundTag)) continue;
@ -170,21 +170,25 @@ public class SchematicReader implements ClipboardReader {
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")) {
if (entry.getValue() instanceof IntTag) {
x = ((IntTag) entry.getValue()).getValue();
}
} else if (entry.getKey().equals("y")) {
if (entry.getValue() instanceof IntTag) {
y = ((IntTag) entry.getValue()).getValue();
}
} else if (entry.getKey().equals("z")) {
if (entry.getValue() instanceof IntTag) {
z = ((IntTag) entry.getValue()).getValue();
}
switch (entry.getKey()) {
case "x":
if (entry.getValue() instanceof IntTag) {
x = ((IntTag) entry.getValue()).getValue();
}
break;
case "y":
if (entry.getValue() instanceof IntTag) {
y = ((IntTag) entry.getValue()).getValue();
}
break;
case "z":
if (entry.getValue() instanceof IntTag) {
z = ((IntTag) entry.getValue()).getValue();
}
break;
}
values.put(entry.getKey(), entry.getValue());

View File

@ -89,7 +89,7 @@ public class SchematicWriter implements ClipboardWriter {
// Metadata
// ====================================================================
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));
@ -108,7 +108,7 @@ public class SchematicWriter implements ClipboardWriter {
byte[] blocks = new byte[width * height * length];
byte[] addBlocks = null;
byte[] blockData = new byte[width * height * length];
List<Tag> tileEntities = new ArrayList<Tag>();
List<Tag> tileEntities = new ArrayList<>();
for (Vector point : region) {
Vector relative = point.subtract(min);
@ -136,7 +136,7 @@ public class SchematicWriter implements ClipboardWriter {
// Store TileEntity data
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());
}
@ -163,12 +163,12 @@ public class SchematicWriter implements ClipboardWriter {
// Entities
// ====================================================================
List<Tag> entities = new ArrayList<Tag>();
List<Tag> entities = new ArrayList<>();
for (Entity entity : clipboard.getEntities()) {
BaseEntity state = entity.getState();
if (state != null) {
Map<String, Tag> values = new HashMap<String, Tag>();
Map<String, Tag> values = new HashMap<>();
// Put NBT provided data
CompoundTag rawTag = state.getNbtData();
@ -197,7 +197,7 @@ public class SchematicWriter implements ClipboardWriter {
}
private Tag writeVector(Vector vector, String name) {
List<DoubleTag> list = new ArrayList<DoubleTag>();
List<DoubleTag> list = new ArrayList<>();
list.add(new DoubleTag(vector.getX()));
list.add(new DoubleTag(vector.getY()));
list.add(new DoubleTag(vector.getZ()));
@ -205,7 +205,7 @@ public class SchematicWriter implements ClipboardWriter {
}
private Tag writeRotation(Location location, String name) {
List<FloatTag> list = new ArrayList<FloatTag>();
List<FloatTag> list = new ArrayList<>();
list.add(new FloatTag(location.getYaw()));
list.add(new FloatTag(location.getPitch()));
return new ListTag(FloatTag.class, list);

View File

@ -27,7 +27,6 @@ import com.google.gson.JsonSyntaxException;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import java.util.Map;