Code cleaning

Most notable change: Remove redundant type parameters and replaced with <>. This is a small step to bring us closer to upstream parity.
This commit is contained in:
matt
2019-02-15 21:46:10 -05:00
parent 3236bdd78e
commit 85bfd16d7c
82 changed files with 1417 additions and 1406 deletions

View File

@ -118,7 +118,7 @@ public class MobSpawnerBlock extends BaseBlock {
@Override
public CompoundTag getNbtData() {
Map<String, Tag> values = new HashMap<String, Tag>();
Map<String, Tag> values = new HashMap<>();
values.put("EntityId", new StringTag(mobType));
values.put("Delay", new ShortTag(delay));
values.put("SpawnCount", new ShortTag(spawnCount));

View File

@ -92,7 +92,7 @@ public class SignBlock extends BaseBlock {
@Override
public CompoundTag getNbtData() {
Map<String, Tag> values = new HashMap<String, Tag>();
Map<String, Tag> values = new HashMap<>();
values.put("Text1", new StringTag(text[0]));
values.put("Text2", new StringTag(text[1]));
values.put("Text3", new StringTag(text[2]));

View File

@ -378,7 +378,7 @@ public class FaweAPI {
});
RegionWrapper bounds = new RegionWrapper(origin.x - radius, origin.x + radius, origin.z - radius, origin.z + radius);
RegionWrapper boundsPlus = new RegionWrapper(bounds.minX - 64, bounds.maxX + 512, bounds.minZ - 64, bounds.maxZ + 512);
HashSet<RegionWrapper> regionSet = new HashSet<RegionWrapper>(Arrays.asList(bounds));
HashSet<RegionWrapper> regionSet = new HashSet<>(Arrays.asList(bounds));
ArrayList<DiskStorageHistory> result = new ArrayList<>();
for (File file : files) {
UUID uuid = UUID.fromString(file.getParentFile().getName());

View File

@ -76,7 +76,7 @@ public class FaweCache {
}
public static Map<String, Object> asMap(Object... pairs) {
HashMap<String, Object> map = new HashMap<String, Object>(pairs.length >> 1);
HashMap<String, Object> map = new HashMap<>(pairs.length >> 1);
for (int i = 0; i < pairs.length; i += 2) {
String key = (String) pairs[i];
Object value = pairs[i + 1];

View File

@ -33,9 +33,9 @@ public final class TypeDescription {
public TypeDescription(Class<? extends Object> clazz, Tag tag) {
this.type = clazz;
this.tag = tag;
listProperties = new HashMap<String, Class<? extends Object>>();
keyProperties = new HashMap<String, Class<? extends Object>>();
valueProperties = new HashMap<String, Class<? extends Object>>();
listProperties = new HashMap<>();
keyProperties = new HashMap<>();
valueProperties = new HashMap<>();
}
public TypeDescription(Class<? extends Object> clazz, String tag) {

View File

@ -175,7 +175,7 @@ public class Yaml {
* @return YAML String
*/
public String dump(Object data) {
List<Object> list = new ArrayList<Object>(1);
List<Object> list = new ArrayList<>(1);
list.add(data);
return dumpAll(list.iterator());
}
@ -215,7 +215,7 @@ public class Yaml {
* stream to write to
*/
public void dump(Object data, Writer output) {
List<Object> list = new ArrayList<Object>(1);
List<Object> list = new ArrayList<>(1);
list.add(data);
dumpAll(list.iterator(), output, null);
}
@ -292,7 +292,7 @@ public class Yaml {
if (flowStyle != null) {
representer.setDefaultFlowStyle(flowStyle);
}
List<Object> list = new ArrayList<Object>(1);
List<Object> list = new ArrayList<>(1);
list.add(data);
StringWriter buffer = new StringWriter();
dumpAll(list.iterator(), buffer, rootTag);
@ -345,7 +345,7 @@ public class Yaml {
}
private static class SilentEmitter implements Emitable {
private List<Event> events = new ArrayList<Event>(100);
private List<Event> events = new ArrayList<>(100);
public List<Event> getEvents() {
return events;

View File

@ -16,7 +16,7 @@ public class ConfigurationSerialization {
public static final String SERIALIZED_TYPE_KEY = "==";
private static final Map<String, Class<? extends ConfigurationSerializable>> aliases =
new HashMap<String, Class<? extends ConfigurationSerializable>>();
new HashMap<>();
private final Class<? extends ConfigurationSerializable> clazz;
protected ConfigurationSerialization(Class<? extends ConfigurationSerializable> clazz) {

View File

@ -163,7 +163,7 @@ public abstract class IntFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
@Override
public Map<Short, CompoundTag> getTiles() {
return tiles == null ? new HashMap<Short, CompoundTag>() : tiles;
return tiles == null ? new HashMap<>() : tiles;
}
@Override
@ -189,7 +189,7 @@ public abstract class IntFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
@Override
public HashSet<UUID> getEntityRemoves() {
return entityRemoves == null ? new HashSet<UUID>() : entityRemoves;
return entityRemoves == null ? new HashSet<>() : entityRemoves;
}
@Override

View File

@ -123,7 +123,7 @@ public class WeakFaweQueueMap implements IFaweQueueMap {
@Override
public void add(FaweChunk chunk) {
long pair = MathMan.pairInt(chunk.getX(), chunk.getZ());
Reference<FaweChunk> previous = this.blocks.put(pair, new SoftReference<FaweChunk>(chunk));
Reference<FaweChunk> previous = this.blocks.put(pair, new SoftReference<>(chunk));
if (previous != null) {
FaweChunk previousChunk = previous.get();
if (previousChunk != null) {

View File

@ -406,7 +406,7 @@ public class JSON2NBT {
}
public Tag parse() throws NBTException {
HashMap<String, Tag> map = new HashMap<String, Tag>();
HashMap<String, Tag> map = new HashMap<>();
Iterator var2 = this.tagList.iterator();
while (var2.hasNext()) {

View File

@ -102,12 +102,13 @@ public class MCAChunk extends FaweChunk<Void> {
if (entities.isEmpty()) {
out.writeNamedEmptyList("Entities");
} else {
out.writeNamedTag("Entities", new ListTag(CompoundTag.class, new ArrayList<CompoundTag>(entities.values())));
out.writeNamedTag("Entities", new ListTag(CompoundTag.class, new ArrayList<>(entities.values())));
}
if (tiles.isEmpty()) {
out.writeNamedEmptyList("TileEntities");
} else {
out.writeNamedTag("TileEntities", new ListTag(CompoundTag.class, new ArrayList<CompoundTag>(tiles.values())));
out.writeNamedTag("TileEntities", new ListTag(CompoundTag.class,
new ArrayList<>(tiles.values())));
}
out.writeNamedTag("InhabitedTime", inhabitedTime);
out.writeNamedTag("LastUpdate", lastUpdate);
@ -422,9 +423,9 @@ public class MCAChunk extends FaweChunk<Void> {
return null;
}
// e.g. by precalculating the length
HashMap<String, Object> level = new HashMap<String, Object>();
level.put("Entities", new ListTag(CompoundTag.class, new ArrayList<CompoundTag>(entities.values())));
level.put("TileEntities", new ListTag(CompoundTag.class, new ArrayList<CompoundTag>(tiles.values())));
HashMap<String, Object> level = new HashMap<>();
level.put("Entities", new ListTag(CompoundTag.class, new ArrayList<>(entities.values())));
level.put("TileEntities", new ListTag(CompoundTag.class, new ArrayList<>(tiles.values())));
level.put("InhabitedTime", inhabitedTime);
level.put("LastUpdate", lastUpdate);
level.put("LightPopulated", (byte) 0);
@ -442,7 +443,7 @@ public class MCAChunk extends FaweChunk<Void> {
if (idLayer == null) {
continue;
}
HashMap<String, Object> map = new HashMap<String, Object>();
HashMap<String, Object> map = new HashMap<>();
map.put("Y", (byte) layer);
map.put("BlockLight", blockLight[layer]);
map.put("SkyLight", skyLight[layer]);
@ -499,7 +500,7 @@ public class MCAChunk extends FaweChunk<Void> {
@Override
public void accept(Integer index, CompoundTag entityTag) {
if (entities == null) {
entities = new HashMap<UUID, CompoundTag>();
entities = new HashMap<>();
}
long least = entityTag.getLong("UUIDLeast");
long most = entityTag.getLong("UUIDMost");
@ -635,7 +636,7 @@ public class MCAChunk extends FaweChunk<Void> {
@Override
public Map<Short, CompoundTag> getTiles() {
return tiles == null ? new HashMap<Short, CompoundTag>() : tiles;
return tiles == null ? new HashMap<>() : tiles;
}
@Override

View File

@ -21,7 +21,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
private int x, z;
public static int HEIGHT = 256;
private final ArrayDeque<Runnable> tasks = new ArrayDeque<Runnable>(0);
private final ArrayDeque<Runnable> tasks = new ArrayDeque<>(0);
/**
* A FaweSections object represents a chunk and the blocks that you wish to change in it.

View File

@ -97,7 +97,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
}
private List<? extends Entity> wrapEntities(final List<? extends Entity> entities) {
final List<Entity> newList = new ArrayList<Entity>(entities.size());
final List<Entity> newList = new ArrayList<>(entities.size());
for (final Entity entity : entities) {
newList.add(new TrackedEntity(entity));
}

View File

@ -121,7 +121,7 @@ public class SplineBrush implements Brush, ResettableTool {
double continuity = 0;
double quality = 10;
final List<Node> nodes = new ArrayList<Node>(centroids.size());
final List<Node> nodes = new ArrayList<>(centroids.size());
for (final Vector3 nodevector : centroids) {
final Node n = new Node(nodevector);

View File

@ -491,7 +491,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
public Map<Integer, Double> getPercents() {
Map<Integer, Integer> map = getBlocks();
int count = getSize();
Int2ObjectOpenHashMap<Double> newMap = new Int2ObjectOpenHashMap<Double>();
Int2ObjectOpenHashMap<Double> newMap = new Int2ObjectOpenHashMap<>();
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
int id = entry.getKey();
int changes = entry.getValue();

View File

@ -12,7 +12,7 @@ import java.util.concurrent.ConcurrentLinkedDeque;
public abstract class IterableThreadLocal<T> extends ThreadLocal<T> implements Iterable<T> {
private ThreadLocal<T> flag;
private ConcurrentLinkedDeque<T> allValues = new ConcurrentLinkedDeque<T>();
private ConcurrentLinkedDeque<T> allValues = new ConcurrentLinkedDeque<>();
public IterableThreadLocal() {
}

View File

@ -7,7 +7,7 @@ import java.util.TreeMap;
public class SimpleRandomCollection<E> extends RandomCollection<E> {
private final NavigableMap<Double, E> map = new TreeMap<Double, E>();
private final NavigableMap<Double, E> map = new TreeMap<>();
private double total = 0;
public SimpleRandomCollection(Map<E, Double> weights, SimpleRandom random) {

View File

@ -93,10 +93,10 @@ public class SoftHashMap<K, V> implements Map<K, V> {
public SoftHashMap(int retentionSize) {
super();
RETENTION_SIZE = Math.max(0, retentionSize);
queue = new ReferenceQueue<V>();
queue = new ReferenceQueue<>();
strongReferencesLock = new ReentrantLock();
map = new ConcurrentHashMap<K, SoftValue<V, K>>();
strongReferences = new ConcurrentLinkedQueue<V>();
map = new ConcurrentHashMap<>();
strongReferences = new ConcurrentLinkedQueue<>();
}
/**
@ -223,7 +223,7 @@ public class SoftHashMap<K, V> implements Map<K, V> {
//noinspection unchecked
return Collections.EMPTY_SET;
}
Collection<V> values = new ArrayList<V>(keys.size());
Collection<V> values = new ArrayList<>(keys.size());
for (K key : keys) {
V v = get(key);
if (v != null) {
@ -238,7 +238,7 @@ public class SoftHashMap<K, V> implements Map<K, V> {
*/
public V put(K key, V value) {
processQueue(); // throw out garbage collected values first
SoftValue<V, K> sv = new SoftValue<V, K>(value, key, queue);
SoftValue<V, K> sv = new SoftValue<>(value, key, queue);
SoftValue<V, K> previous = map.put(key, sv);
addToStrongReferences(value);
return previous != null ? previous.get() : null;
@ -274,7 +274,7 @@ public class SoftHashMap<K, V> implements Map<K, V> {
return Collections.EMPTY_SET;
}
Map<K, V> kvPairs = new HashMap<K, V>(keys.size());
Map<K, V> kvPairs = new HashMap<>(keys.size());
for (K key : keys) {
V v = get(key);
if (v != null) {
@ -307,4 +307,4 @@ public class SoftHashMap<K, V> implements Map<K, V> {
}
}
}
}

View File

@ -39,7 +39,7 @@ public class PGZIPOutputStream extends FilterOutputStream {
// todo: remove after block guessing is implemented
// array list that contains the block sizes
ArrayList<Integer> blockSizes = new ArrayList<Integer>();
ArrayList<Integer> blockSizes = new ArrayList<>();
private int level = Deflater.DEFAULT_COMPRESSION;
private int strategy = Deflater.DEFAULT_STRATEGY;
@ -80,7 +80,7 @@ public class PGZIPOutputStream extends FilterOutputStream {
super(out);
this.executor = executor;
this.nthreads = nthreads;
this.emitQueue = new ArrayBlockingQueue<Future<byte[]>>(nthreads);
this.emitQueue = new ArrayBlockingQueue<>(nthreads);
writeHeader();
}
@ -246,4 +246,4 @@ public class PGZIPOutputStream extends FilterOutputStream {
// LOG.warn("Already closed.");
}
}
}
}

View File

@ -38,17 +38,17 @@ public class PolyhedralRegion extends AbstractRegion {
/**
* Vertices that are contained in the convex hull.
*/
private final Set<BlockVector3> vertices = new LinkedHashSet<BlockVector3>();
private final Set<BlockVector3> vertices = new LinkedHashSet<>();
/**
* Triangles that form the convex hull.
*/
private final List<Triangle> triangles = new ArrayList<Triangle>();
private final List<Triangle> triangles = new ArrayList<>();
/**
* Vertices that are coplanar to the first 3 vertices.
*/
private final Set<BlockVector3> vertexBacklog = new LinkedHashSet<BlockVector3>();
private final Set<BlockVector3> vertexBacklog = new LinkedHashSet<>();
/**
* Minimum point of the axis-aligned bounding box.
@ -165,7 +165,7 @@ public class PolyhedralRegion extends AbstractRegion {
triangles.add((new Triangle(v[0], v[size - 1], v[size - 2])));
return true;
}
final Set<Edge> borderEdges = new LinkedHashSet<Edge>();
final Set<Edge> borderEdges = new LinkedHashSet<>();
for (Iterator<Triangle> it = triangles.iterator(); it.hasNext(); ) {
final Triangle triangle = it.next();
@ -200,7 +200,7 @@ public class PolyhedralRegion extends AbstractRegion {
vertices.remove(vertex);
// Clone, clear and work through the backlog
final List<BlockVector3> vertexBacklog2 = new ArrayList<BlockVector3>(vertexBacklog);
final List<BlockVector3> vertexBacklog2 = new ArrayList<>(vertexBacklog);
vertexBacklog.clear();
for (BlockVector3 vertex2 : vertexBacklog2) {
addVertex(vertex2);
@ -261,7 +261,7 @@ public class PolyhedralRegion extends AbstractRegion {
}
private static void shiftCollection(Collection<BlockVector3> collection, BlockVector3 change) {
final List<BlockVector3> tmp = new ArrayList<BlockVector3>(collection);
final List<BlockVector3> tmp = new ArrayList<>(collection);
collection.clear();
for (BlockVector3 vertex : tmp) {
collection.add(change.add(vertex));
@ -308,7 +308,7 @@ public class PolyhedralRegion extends AbstractRegion {
return vertices;
}
final List<BlockVector3> ret = new ArrayList<BlockVector3>(vertices);
final List<BlockVector3> ret = new ArrayList<>(vertices);
ret.addAll(vertexBacklog);
return ret;
@ -322,4 +322,4 @@ public class PolyhedralRegion extends AbstractRegion {
public AbstractRegion clone() {
return new PolyhedralRegion(this);
}
}
}

View File

@ -152,7 +152,7 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio
@Override
public List<String> getInformationLines() {
final List<String> lines = new ArrayList<String>();
final List<String> lines = new ArrayList<>();
for (int i = 0; i < positions.size(); i++) {
lines.add("Position " + i + ": " + positions.get(i));
}

View File

@ -146,7 +146,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion {
@Override
public List<String> getInformationLines() {
List<String> ret = new ArrayList<String>();
List<String> ret = new ArrayList<>();
ret.add("Vertices: " + region.getVertices().size());
ret.add("Triangles: " + region.getTriangles().size());
@ -202,7 +202,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion {
Collection<BlockVector3> vertices = region.getVertices();
Collection<Triangle> triangles = region.getTriangles();
Map<BlockVector3, Integer> vertexIds = new HashMap<BlockVector3, Integer>(vertices.size());
Map<BlockVector3, Integer> vertexIds = new HashMap<>(vertices.size());
int lastVertexId = -1;
for (BlockVector3 vertex : vertices) {
vertexIds.put(vertex, ++lastVertexId);

View File

@ -228,7 +228,7 @@ public class SetQueue {
}
public Collection<FaweQueue> getAllQueues() {
ArrayList<FaweQueue> list = new ArrayList<FaweQueue>(activeQueues.size() + inactiveQueues.size());
ArrayList<FaweQueue> list = new ArrayList<>(activeQueues.size() + inactiveQueues.size());
list.addAll(inactiveQueues);
list.addAll(activeQueues);
return list;

View File

@ -167,7 +167,7 @@ public class ShapeInterpolator {
bezierCoordinates[0] = curX = movX = coordinates[0];
bezierCoordinates[1] = curY = movY = coordinates[1];
float newX, newY;
final Vector<Point2D.Float> savedPathEndPoints = new Vector<Point2D.Float>();
final Vector<Point2D.Float> savedPathEndPoints = new Vector<>();
numCoordinates = 2;
while (!pi.isDone()) {
switch (pi.currentSegment(coordinates)) {
@ -735,4 +735,4 @@ public class ShapeInterpolator {
return res;
}
}
}
}

View File

@ -148,7 +148,7 @@ public class StringMan {
}
public static List<String> split(String input, char delim) {
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
int start = 0;
int bracket = 0;
boolean inQuotes = false;

View File

@ -583,7 +583,7 @@ public class TextureUtil implements TextureHolder{
// Get all the groups in the current jar
// The vanilla textures are in `assets/minecraft`
// A jar may contain textures for multiple mods
Set<String> mods = new HashSet<String>();
Set<String> mods = new HashSet<>();
{
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {

View File

@ -57,7 +57,7 @@ public class UsageMessage extends Message {
text(BBC.HELP_HEADER_SUBCOMMANDS.f());
String prefix = !commandString.isEmpty() ? commandString + " " : "";
List<CommandMapping> list = new ArrayList<CommandMapping>(dispatcher.getCommands());
List<CommandMapping> list = new ArrayList<>(dispatcher.getCommands());
Collections.sort(list, new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
for (CommandMapping mapping : list) {

View File

@ -308,7 +308,7 @@ public class TaskBuilder extends Metadatable {
continue;
case SYNC_PARALLEL:
case ASYNC_PARALLEL:
final ArrayList<RunnableTask> parallel = new ArrayList<RunnableTask>();
final ArrayList<RunnableTask> parallel = new ArrayList<>();
parallel.add(task);
RunnableTask next = tasks.peek();
while (next != null && next.type == task.type) {
@ -571,4 +571,4 @@ public class TaskBuilder extends Metadatable {
DELAY,
ABORT
}
}
}

View File

@ -1,447 +1,447 @@
/*
* 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.jnbt;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The {@code TAG_Compound} tag.
*/
public final class CompoundTag extends Tag {
private final Map<String, Tag> value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public CompoundTag(Map<String, Tag> value) {
super();
this.value = value;
}
@Override
public Map<String, Object> getRaw() {
HashMap<String, Object> raw = new HashMap<>();
for (Map.Entry<String, Tag> entry : value.entrySet()) {
raw.put(entry.getKey(), entry.getValue().getRaw());
}
return raw;
}
/**
* Returns whether this compound tag contains the given key.
*
* @param key the given key
* @return true if the tag contains the given key
*/
public boolean containsKey(String key) {
return value.containsKey(key);
}
@Override
public Map<String, Tag> getValue() {
return value;
}
/**
* Return a new compound tag with the given values.
*
* @param value the value
* @return the new compound tag
*/
public CompoundTag setValue(Map<String, Tag> value) {
return new CompoundTag(value);
}
/**
* Create a compound tag builder.
*
* @return the builder
*/
public CompoundTagBuilder createBuilder() {
return new CompoundTagBuilder(new HashMap<String, Tag>(value));
}
/**
* Get a byte array named with the given key.
*
* <p>If the key does not exist or its value is not a byte array tag,
* then an empty byte array will be returned.</p>
*
* @param key the key
* @return a byte array
*/
public byte[] getByteArray(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteArrayTag) {
return ((ByteArrayTag) tag).getValue();
} else {
return new byte[0];
}
}
/**
* Get a byte named with the given key.
*
* <p>If the key does not exist or its value is not a byte tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a byte
*/
public byte getByte(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else {
return (byte) 0;
}
}
/**
* Get a double named with the given key.
*
* <p>If the key does not exist or its value is not a double tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a double
*/
public double getDouble(String key) {
Tag tag = value.get(key);
if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a double named with the given key, even if it's another
* type of number.
*
* <p>If the key does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a double
*/
public double asDouble(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a float named with the given key.
*
* <p>If the key does not exist or its value is not a float tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a float
*/
public float getFloat(String key) {
Tag tag = value.get(key);
if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a {@code int[]} named with the given key.
*
* <p>If the key does not exist or its value is not an int array tag,
* then an empty array will be returned.</p>
*
* @param key the key
* @return an int array
*/
public int[] getIntArray(String key) {
Tag tag = value.get(key);
if (tag instanceof IntArrayTag) {
return ((IntArrayTag) tag).getValue();
} else {
return new int[0];
}
}
/**
* Get an int named with the given key.
*
* <p>If the key does not exist or its value is not an int tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return an int
*/
public int getInt(String key) {
Tag tag = value.get(key);
if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get an int named with the given key, even if it's another
* type of number.
*
* <p>If the key does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return an int
*/
public int asInt(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().intValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().intValue();
} else {
return 0;
}
}
/**
* Get a list of tags named with the given key.
*
* <p>If the key does not exist or its value is not a list tag,
* then an empty list will be returned.</p>
*
* @param key the key
* @return a list of tags
*/
public List<Tag> getList(String key) {
Tag tag = value.get(key);
if (tag instanceof ListTag) {
return ((ListTag) tag).getValue();
} else {
return Collections.emptyList();
}
}
/**
* Get a {@code TagList} named with the given key.
*
* <p>If the key does not exist or its value is not a list tag,
* then an empty tag list will be returned.</p>
*
* @param key the key
* @return a tag list instance
*/
public ListTag getListTag(String key) {
Tag tag = value.get(key);
if (tag instanceof ListTag) {
return (ListTag) tag;
} else {
return new ListTag(StringTag.class, Collections.<Tag>emptyList());
}
}
/**
* Get a list of tags named with the given key.
*
* <p>If the key does not exist or its value is not a list tag,
* then an empty list will be returned. If the given key references
* a list but the list of of a different type, then an empty
* list will also be returned.</p>
*
* @param key the key
* @param listType the class of the contained type
* @return a list of tags
* @param <T> the type of list
*/
@SuppressWarnings("unchecked")
public <T extends Tag> List<T> getList(String key, Class<T> listType) {
Tag tag = value.get(key);
if (tag instanceof ListTag) {
ListTag listTag = (ListTag) tag;
if (listTag.getType().equals(listType)) {
return (List<T>) listTag.getValue();
} else {
return Collections.emptyList();
}
} else {
return Collections.emptyList();
}
}
/**
* Get a {@code long[]} named with the given key.
*
* <p>If the key does not exist or its value is not an long array tag,
* then an empty array will be returned.</p>
*
* @param key the key
* @return an int array
*/
public long[] getLongArray(String key) {
Tag tag = value.get(key);
if (tag instanceof LongArrayTag) {
return ((LongArrayTag) tag).getValue();
} else {
return new long[0];
}
}
/**
* Get a long named with the given key.
*
* <p>If the key does not exist or its value is not a long tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a long
*/
public long getLong(String key) {
Tag tag = value.get(key);
if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else {
return 0L;
}
}
/**
* Get a long named with the given key, even if it's another
* type of number.
*
* <p>If the key does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a long
*/
public long asLong(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().longValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().longValue();
} else {
return 0L;
}
}
/**
* Get a short named with the given key.
*
* <p>If the key does not exist or its value is not a short tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a short
*/
public short getShort(String key) {
Tag tag = value.get(key);
if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a string named with the given key.
*
* <p>If the key does not exist or its value is not a string tag,
* then {@code ""} will be returned.</p>
*
* @param key the key
* @return a string
*/
public String getString(String key) {
Tag tag = value.get(key);
if (tag instanceof StringTag) {
return ((StringTag) tag).getValue();
} else {
return "";
}
}
@Override
public String toString() {
StringBuilder bldr = new StringBuilder();
bldr.append("TAG_Compound").append(": ").append(value.size()).append(" entries\r\n{\r\n");
for (Map.Entry<String, Tag> entry : value.entrySet()) {
bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
}
bldr.append("}");
return bldr.toString();
}
}
/*
* 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.jnbt;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The {@code TAG_Compound} tag.
*/
public final class CompoundTag extends Tag {
private final Map<String, Tag> value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public CompoundTag(Map<String, Tag> value) {
super();
this.value = value;
}
@Override
public Map<String, Object> getRaw() {
HashMap<String, Object> raw = new HashMap<>();
for (Map.Entry<String, Tag> entry : value.entrySet()) {
raw.put(entry.getKey(), entry.getValue().getRaw());
}
return raw;
}
/**
* Returns whether this compound tag contains the given key.
*
* @param key the given key
* @return true if the tag contains the given key
*/
public boolean containsKey(String key) {
return value.containsKey(key);
}
@Override
public Map<String, Tag> getValue() {
return value;
}
/**
* Return a new compound tag with the given values.
*
* @param value the value
* @return the new compound tag
*/
public CompoundTag setValue(Map<String, Tag> value) {
return new CompoundTag(value);
}
/**
* Create a compound tag builder.
*
* @return the builder
*/
public CompoundTagBuilder createBuilder() {
return new CompoundTagBuilder(new HashMap<>(value));
}
/**
* Get a byte array named with the given key.
*
* <p>If the key does not exist or its value is not a byte array tag,
* then an empty byte array will be returned.</p>
*
* @param key the key
* @return a byte array
*/
public byte[] getByteArray(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteArrayTag) {
return ((ByteArrayTag) tag).getValue();
} else {
return new byte[0];
}
}
/**
* Get a byte named with the given key.
*
* <p>If the key does not exist or its value is not a byte tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a byte
*/
public byte getByte(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else {
return (byte) 0;
}
}
/**
* Get a double named with the given key.
*
* <p>If the key does not exist or its value is not a double tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a double
*/
public double getDouble(String key) {
Tag tag = value.get(key);
if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a double named with the given key, even if it's another
* type of number.
*
* <p>If the key does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a double
*/
public double asDouble(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a float named with the given key.
*
* <p>If the key does not exist or its value is not a float tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a float
*/
public float getFloat(String key) {
Tag tag = value.get(key);
if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a {@code int[]} named with the given key.
*
* <p>If the key does not exist or its value is not an int array tag,
* then an empty array will be returned.</p>
*
* @param key the key
* @return an int array
*/
public int[] getIntArray(String key) {
Tag tag = value.get(key);
if (tag instanceof IntArrayTag) {
return ((IntArrayTag) tag).getValue();
} else {
return new int[0];
}
}
/**
* Get an int named with the given key.
*
* <p>If the key does not exist or its value is not an int tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return an int
*/
public int getInt(String key) {
Tag tag = value.get(key);
if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get an int named with the given key, even if it's another
* type of number.
*
* <p>If the key does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return an int
*/
public int asInt(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().intValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().intValue();
} else {
return 0;
}
}
/**
* Get a list of tags named with the given key.
*
* <p>If the key does not exist or its value is not a list tag,
* then an empty list will be returned.</p>
*
* @param key the key
* @return a list of tags
*/
public List<Tag> getList(String key) {
Tag tag = value.get(key);
if (tag instanceof ListTag) {
return ((ListTag) tag).getValue();
} else {
return Collections.emptyList();
}
}
/**
* Get a {@code TagList} named with the given key.
*
* <p>If the key does not exist or its value is not a list tag,
* then an empty tag list will be returned.</p>
*
* @param key the key
* @return a tag list instance
*/
public ListTag getListTag(String key) {
Tag tag = value.get(key);
if (tag instanceof ListTag) {
return (ListTag) tag;
} else {
return new ListTag(StringTag.class, Collections.<Tag>emptyList());
}
}
/**
* Get a list of tags named with the given key.
*
* <p>If the key does not exist or its value is not a list tag,
* then an empty list will be returned. If the given key references
* a list but the list of of a different type, then an empty
* list will also be returned.</p>
*
* @param key the key
* @param listType the class of the contained type
* @return a list of tags
* @param <T> the type of list
*/
@SuppressWarnings("unchecked")
public <T extends Tag> List<T> getList(String key, Class<T> listType) {
Tag tag = value.get(key);
if (tag instanceof ListTag) {
ListTag listTag = (ListTag) tag;
if (listTag.getType().equals(listType)) {
return (List<T>) listTag.getValue();
} else {
return Collections.emptyList();
}
} else {
return Collections.emptyList();
}
}
/**
* Get a {@code long[]} named with the given key.
*
* <p>If the key does not exist or its value is not an long array tag,
* then an empty array will be returned.</p>
*
* @param key the key
* @return an int array
*/
public long[] getLongArray(String key) {
Tag tag = value.get(key);
if (tag instanceof LongArrayTag) {
return ((LongArrayTag) tag).getValue();
} else {
return new long[0];
}
}
/**
* Get a long named with the given key.
*
* <p>If the key does not exist or its value is not a long tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a long
*/
public long getLong(String key) {
Tag tag = value.get(key);
if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else {
return 0L;
}
}
/**
* Get a long named with the given key, even if it's another
* type of number.
*
* <p>If the key does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a long
*/
public long asLong(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().longValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().longValue();
} else {
return 0L;
}
}
/**
* Get a short named with the given key.
*
* <p>If the key does not exist or its value is not a short tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a short
*/
public short getShort(String key) {
Tag tag = value.get(key);
if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a string named with the given key.
*
* <p>If the key does not exist or its value is not a string tag,
* then {@code ""} will be returned.</p>
*
* @param key the key
* @return a string
*/
public String getString(String key) {
Tag tag = value.get(key);
if (tag instanceof StringTag) {
return ((StringTag) tag).getValue();
} else {
return "";
}
}
@Override
public String toString() {
StringBuilder bldr = new StringBuilder();
bldr.append("TAG_Compound").append(": ").append(value.size()).append(" entries\r\n{\r\n");
for (Map.Entry<String, Tag> entry : value.entrySet()) {
bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
}
bldr.append("}");
return bldr.toString();
}
}

View File

@ -35,7 +35,7 @@ public class CompoundTagBuilder {
* Create a new instance.
*/
public CompoundTagBuilder() {
this.entries = new HashMap<String, Tag>();
this.entries = new HashMap<>();
}
/**
@ -201,7 +201,7 @@ public class CompoundTagBuilder {
* @return the new compound tag
*/
public CompoundTag build() {
return new CompoundTag(new HashMap<String, Tag>(entries));
return new CompoundTag(new HashMap<>(entries));
}
/**
@ -213,4 +213,4 @@ public class CompoundTagBuilder {
return new CompoundTagBuilder();
}
}
}

View File

@ -375,7 +375,7 @@ public final class NBTInputStream implements Closeable {
childType = NBTConstants.TYPE_COMPOUND;
}
length = is.readInt();
List<Tag> tagList = new ArrayList<Tag>();
List<Tag> tagList = new ArrayList<>();
for (int i = 0; i < length; ++i) {
Tag tag = readTagPayload(childType, depth + 1);
if (tag instanceof EndTag) {
@ -385,7 +385,7 @@ public final class NBTInputStream implements Closeable {
}
return (tagList);
case NBTConstants.TYPE_COMPOUND:
Map<String, Tag> tagMap = new HashMap<String, Tag>();
Map<String, Tag> tagMap = new HashMap<>();
while (true) {
NamedTag namedTag = readNamedTag(depth + 1);
Tag tag = namedTag.getTag();
@ -562,7 +562,7 @@ public final class NBTInputStream implements Closeable {
childType = NBTConstants.TYPE_COMPOUND;
}
length = is.readInt();
List<Tag> tagList = new ArrayList<Tag>();
List<Tag> tagList = new ArrayList<>();
for (int i = 0; i < length; ++i) {
Tag tag = readTagPayload(childType, depth + 1);
if (tag instanceof EndTag) {
@ -573,7 +573,7 @@ public final class NBTInputStream implements Closeable {
return new ListTag(NBTUtils.getTypeClass(childType), tagList);
case NBTConstants.TYPE_COMPOUND:
Map<String, Tag> tagMap = new HashMap<String, Tag>();
Map<String, Tag> tagMap = new HashMap<>();
while (true) {
NamedTag namedTag = readNamedTag(depth + 1);
Tag tag = namedTag.getTag();

View File

@ -3172,7 +3172,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
*/
public int drawSpline(final Pattern pattern, final List<BlockVector3> nodevectors, final double tension, final double bias, final double continuity, final double quality, final double radius, final boolean filled) throws WorldEditException {
LocalBlockVectorSet vset = new LocalBlockVectorSet();
final List<Node> nodes = new ArrayList<Node>(nodevectors.size());
final List<Node> nodes = new ArrayList<>(nodevectors.size());
final KochanekBartelsInterpolation interpol = new KochanekBartelsInterpolation();
for (BlockVector3 nodevector : nodevectors) {
@ -3278,7 +3278,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
public void recurseHollow(final Region region, final BlockVector3 origin, final Set<BlockVector3> outside) {
//TODO FIXME Optimize - avoid vector creation
final ArrayDeque<BlockVector3> queue = new ArrayDeque<BlockVector3>();
final ArrayDeque<BlockVector3> queue = new ArrayDeque<>();
queue.addLast(origin);
while (!queue.isEmpty()) {

File diff suppressed because it is too large Load Diff

View File

@ -185,7 +185,7 @@ public class BiomeCommands extends MethodCommands {
for (int i = 0; i < biomes.length; i++) {
int count = biomes[i];
if (count != 0) {
distribution.add(new Countable<BaseBiome>(new BaseBiome(i), count));
distribution.add(new Countable<>(new BaseBiome(i), count));
}
}
Collections.sort(distribution);

View File

@ -51,14 +51,14 @@ public abstract class HelpBuilder implements Runnable {
}
boolean isRootLevel = true;
List<String> visited = new ArrayList<String>();
List<String> visited = new ArrayList<>();
// Create the message
if (callable instanceof Dispatcher) {
Dispatcher dispatcher = (Dispatcher) callable;
// Get a list of aliases
List<CommandMapping> aliases = new ArrayList<CommandMapping>(dispatcher.getCommands());
List<CommandMapping> aliases = new ArrayList<>(dispatcher.getCommands());
List<String> prefixes = Collections.nCopies(aliases.size(), "");
// Group by callable
@ -174,7 +174,7 @@ public abstract class HelpBuilder implements Runnable {
return;
}
dispatcher = (Dispatcher) callable;
aliases = new ArrayList<CommandMapping>(dispatcher.getCommands());
aliases = new ArrayList<>(dispatcher.getCommands());
prefixes = Collections.nCopies(aliases.size(), "");
} else {
aliases = new ArrayList<>();

View File

@ -139,7 +139,7 @@ public class ScriptingCommands {
engine.setTimeLimit(worldEdit.getConfiguration().scriptTimeout);
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> vars = new HashMap<>();
vars.put("argv", args);
vars.put("actor", actor);

View File

@ -556,7 +556,7 @@ public class UtilityCommands extends MethodCommands {
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;
@ -616,7 +616,7 @@ public class UtilityCommands extends MethodCommands {
EntityRemover remover = new EntityRemover();
remover.fromString(typeStr);
List<EntityVisitor> visitors = new ArrayList<EntityVisitor>();
List<EntityVisitor> visitors = new ArrayList<>();
LocalSession session = null;
EditSession editSession = null;

View File

@ -73,8 +73,8 @@ public class PlatformManager {
private final WorldEdit worldEdit;
private final CommandManager commandManager;
private final List<Platform> platforms = new ArrayList<Platform>();
private final Map<Capability, Platform> preferences = new EnumMap<Capability, Platform>(Capability.class);
private final List<Platform> platforms = new ArrayList<>();
private final Map<Capability, Platform> preferences = new EnumMap<>(Capability.class);
private @Nullable String firstSeenVersion;
private final AtomicBoolean initialized = new AtomicBoolean();
private final AtomicBoolean configured = new AtomicBoolean();
@ -230,7 +230,7 @@ public class PlatformManager {
* @return a list of platforms
*/
public synchronized List<Platform> getPlatforms() {
return new ArrayList<Platform>(platforms);
return new ArrayList<>(platforms);
}
/**
@ -566,4 +566,4 @@ public class PlatformManager {
}
}

View File

@ -143,7 +143,7 @@ public interface ClipboardFormat {
default URL uploadPublic(final Clipboard clipboard, String category, String user) {
// summary
// blocks
HashMap<String, Object> map = new HashMap<String, Object>();
HashMap<String, Object> map = new HashMap<>();
BlockVector3 dimensions = clipboard.getDimensions();
map.put("width", dimensions.getX());
map.put("height", dimensions.getY());
@ -179,4 +179,4 @@ public interface ClipboardFormat {
e.printStackTrace();
}
}
}
}

View File

@ -185,7 +185,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

@ -72,7 +72,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

@ -69,7 +69,7 @@ public class Expression {
private static final ThreadLocal<ArrayDeque<Expression>> instance = ThreadLocal.withInitial(ArrayDeque::new);
private final Map<String, RValue> variables = new HashMap<String, RValue>();
private final Map<String, RValue> variables = new HashMap<>();
private final String[] variableNames;
private Variable[] variableArray;
private RValue root;

View File

@ -124,7 +124,7 @@ public final class Functions {
throw new NoSuchMethodException(); // TODO: return null (check for side-effects first)
}
private static final Map<String, List<Overload>> functions = new HashMap<String, List<Overload>>();
private static final Map<String, List<Overload>> functions = new HashMap<>();
static {
for (Method method : Functions.class.getMethods()) {
@ -143,7 +143,7 @@ public final class Functions {
List<Overload> overloads = functions.get(methodName);
if (overloads == null) {
functions.put(methodName, overloads = new ArrayList<Overload>());
functions.put(methodName, overloads = new ArrayList<>());
}
overloads.add(overload);
@ -281,8 +281,8 @@ public final class Functions {
}
private static final Map<Integer, double[]> gmegabuf = new HashMap<Integer, double[]>();
private final Map<Integer, double[]> megabuf = new HashMap<Integer, double[]>();
private static final Map<Integer, double[]> gmegabuf = new HashMap<>();
private final Map<Integer, double[]> megabuf = new HashMap<>();
public Map<Integer, double[]> getMegabuf() {
return megabuf;

View File

@ -191,7 +191,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
@Override
public List<String> getInformationLines() {
List<String> ret = new ArrayList<String>();
List<String> ret = new ArrayList<>();
ret.add("Vertices: "+region.getVertices().size());
ret.add("Triangles: "+region.getTriangles().size());

View File

@ -260,7 +260,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
@Override
public List<String> getInformationLines() {
final List<String> lines = new ArrayList<String>();
final List<String> lines = new ArrayList<>();
if (position1 != null) {
lines.add("Position 1: " + position1);
@ -318,4 +318,4 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
}
}
}

View File

@ -241,7 +241,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
@Override
public List<String> getInformationLines() {
final List<String> lines = new ArrayList<String>();
final List<String> lines = new ArrayList<>();
if (!region.getCenter().equals(Vector3.ZERO)) {
lines.add("Center: " + region.getCenter());

View File

@ -199,7 +199,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
@Override
public List<String> getInformationLines() {
final List<String> lines = new ArrayList<String>();
final List<String> lines = new ArrayList<>();
final Vector3 center = region.getCenter();
if (center.lengthSq() > 0) {

View File

@ -40,7 +40,7 @@ import java.util.Set;
*/
public class SimpleDispatcher implements Dispatcher {
private final Map<String, CommandMapping> commands = new HashMap<String, CommandMapping>();
private final Map<String, CommandMapping> commands = new HashMap<>();
private final SimpleDescription description = new SimpleDescription();
/**
@ -82,7 +82,7 @@ public class SimpleDispatcher implements Dispatcher {
@Override
public Set<CommandMapping> getCommands() {
return Collections.unmodifiableSet(new HashSet<CommandMapping>(commands.values()));
return Collections.unmodifiableSet(new HashSet<>(commands.values()));
}
@Override
@ -92,7 +92,7 @@ public class SimpleDispatcher implements Dispatcher {
@Override
public Set<String> getPrimaryAliases() {
Set<String> aliases = new HashSet<String>();
Set<String> aliases = new HashSet<>();
for (CommandMapping mapping : getCommands()) {
aliases.add(mapping.getPrimaryAlias());
}
@ -151,7 +151,7 @@ public class SimpleDispatcher implements Dispatcher {
if (split.length <= 1) {
String prefix = split.length > 0 ? split[0] : "";
List<String> suggestions = new ArrayList<String>();
List<String> suggestions = new ArrayList<>();
for (CommandMapping mapping : getCommands()) {
if (mapping.getCallable().testPermission(locals)) {
@ -188,4 +188,4 @@ public class SimpleDispatcher implements Dispatcher {
// Checking every perm in the class here was unnecessarily stupid
return true;
}
}
}

View File

@ -171,7 +171,7 @@ public abstract class AParametricCallable implements CommandCallable {
if (!found) {
if (unusedFlags == null) {
unusedFlags = new HashSet<Character>();
unusedFlags = new HashSet<>();
}
unusedFlags.add(flag);
}

View File

@ -15,9 +15,9 @@ public class FunctionParametricCallable extends AParametricCallable {
private final ParametricBuilder builder;
private final ParameterData[] parameters;
private final Set<Character> valueFlags = new HashSet<Character>();
private final Set<Character> valueFlags = new HashSet<>();
private final boolean anyFlags;
private final Set<Character> legacyFlags = new HashSet<Character>();
private final Set<Character> legacyFlags = new HashSet<>();
private final SimpleDescription description = new SimpleDescription();
private final String permission;
private final Command command;
@ -81,7 +81,7 @@ public class FunctionParametricCallable extends AParametricCallable {
}
parameters = new ParameterData[paramParsables.size()];
List<Parameter> userParameters = new ArrayList<Parameter>();
List<Parameter> userParameters = new ArrayList<>();
// This helps keep tracks of @Nullables that appear in the middle of a list
// of parameters
@ -325,4 +325,4 @@ public class FunctionParametricCallable extends AParametricCallable {
public String toString() {
return command.aliases()[0];
}
}
}

View File

@ -65,10 +65,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class ParametricBuilder {
private final Map<Type, Binding> bindings = new HashMap<Type, Binding>();
private final Map<Type, Binding> bindings = new HashMap<>();
private final Paranamer paranamer = new FaweParanamer();
private final List<InvokeListener> invokeListeners = new ArrayList<InvokeListener>();
private final List<ExceptionConverter> exceptionConverters = new ArrayList<ExceptionConverter>();
private final List<InvokeListener> invokeListeners = new ArrayList<>();
private final List<ExceptionConverter> exceptionConverters = new ArrayList<>();
private Authorizer authorizer = new NullAuthorizer();
private CommandCompleter defaultCompleter = new NullCompleter();

View File

@ -55,9 +55,9 @@ public class ParametricCallable extends AParametricCallable {
private final Object object;
private final Method method;
private final ParameterData[] parameters;
private final Set<Character> valueFlags = new HashSet<Character>();
private final Set<Character> valueFlags = new HashSet<>();
private final boolean anyFlags;
private final Set<Character> legacyFlags = new HashSet<Character>();
private final Set<Character> legacyFlags = new HashSet<>();
private final SimpleDescription description = new SimpleDescription();
private final CommandPermissions commandPermissions;
private final Command definition;
@ -81,7 +81,7 @@ public class ParametricCallable extends AParametricCallable {
Type[] types = method.getGenericParameterTypes();
parameters = new ParameterData[types.length];
List<Parameter> userParameters = new ArrayList<Parameter>();
List<Parameter> userParameters = new ArrayList<>();
// This helps keep tracks of @Nullables that appear in the middle of a list
// of parameters
@ -221,7 +221,7 @@ public class ParametricCallable extends AParametricCallable {
try {
// preProcess handlers
List<InvokeHandler> handlers = new ArrayList<InvokeHandler>();
List<InvokeHandler> handlers = new ArrayList<>();
for (InvokeListener listener : builder.getInvokeListeners()) {
InvokeHandler handler = listener.createInvokeHandler();
handlers.add(handler);
@ -361,4 +361,4 @@ public class ParametricCallable extends AParametricCallable {
}
}
}

View File

@ -73,7 +73,7 @@ public class CommandUsageBox extends StyledFragment {
CommandListBox box = new CommandListBox(BBC.HELP_HEADER_SUBCOMMANDS.f());
String prefix = !commandString.isEmpty() ? commandString + " " : "";
List<CommandMapping> list = new ArrayList<CommandMapping>(dispatcher.getCommands());
List<CommandMapping> list = new ArrayList<>(dispatcher.getCommands());
Collections.sort(list, new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
for (CommandMapping mapping : list) {

View File

@ -83,7 +83,7 @@ public class ProgressIterator<V> implements Iterator<V>, ProgressObservable {
* @return an instance
*/
public static <V> ProgressIterator<V> create(Iterator<V> iterator, int count) {
return new ProgressIterator<V>(iterator, count);
return new ProgressIterator<>(iterator, count);
}
/**

View File

@ -81,7 +81,8 @@ public class BlockType implements FawePattern {
public ArrayList<BlockState> updateStates(){
if(settings != null) {
return settings.localStates = new ArrayList<BlockState>(settings.localStates.stream().map(state -> new BlockStateImpl(this, state.getInternalId(), state.getOrdinal())).collect(Collectors.toList()));
return settings.localStates = new ArrayList<>(settings.localStates.stream()
.map(state -> new BlockStateImpl(this, state.getInternalId(), state.getOrdinal())).collect(Collectors.toList()));
}else {
return null;
}

View File

@ -676,9 +676,9 @@ public class BlockTypes{
public static BlockType register(BlockType type) {
if(sortedRegistry == null) {
sortedRegistry = new ArrayList<BlockType>();
stateList = new ArrayList<BlockState>();
$NAMESPACES = new LinkedHashSet<String>();
sortedRegistry = new ArrayList<>();
stateList = new ArrayList<>();
$NAMESPACES = new LinkedHashSet<>();
BIT_OFFSET = MathMan.log2nlz(WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().registerBlocks().size());
BIT_MASK = ((1 << BIT_OFFSET) - 1);
}
@ -775,7 +775,7 @@ public class BlockTypes{
this.propertiesSet = Collections.emptySet();
}
this.permutations = maxInternalStateId;
this.localStates = new ArrayList<BlockState>();
this.localStates = new ArrayList<>();
this.blockMaterial = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(type);
this.itemType = ItemTypes.get(type);

View File

@ -838,7 +838,7 @@ public final class ItemTypes {
public static ItemType register(final ItemType item) {
if(sortedRegistry == null)
sortedRegistry = new ArrayList<ItemType>();
sortedRegistry = new ArrayList<>();
if(!sortedRegistry.contains(item))sortedRegistry.add(item);
// return ItemType.REGISTRY.register(item.getId(), item);
return internalRegister(item);

View File

@ -38,7 +38,7 @@ public class CommandContextTest {
@Before
public void setUpTest() {
try {
firstCommand = new CommandContext(firstCmdString, new HashSet<Character>(Arrays.asList('o', 'w')));
firstCommand = new CommandContext(firstCmdString, new HashSet<>(Arrays.asList('o', 'w')));
} catch (CommandException e) {
log.log(Level.WARNING, "Error", e);
fail("Unexpected exception when creating CommandContext");
@ -48,7 +48,7 @@ public class CommandContextTest {
@Test(expected = CommandException.class)
public void testInvalidFlags() throws CommandException {
final String failingCommand = "herpderp -opw testers";
new CommandContext(failingCommand, new HashSet<Character>(Arrays.asList('o', 'w')));
new CommandContext(failingCommand, new HashSet<>(Arrays.asList('o', 'w')));
}
@Test