mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2025-01-08 09:27:34 +01:00
Diamond inference cleanup (#1593)
This commit is contained in:
parent
764195bd55
commit
240920d642
@ -2,6 +2,7 @@ package com.comphenix.protocol;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -79,7 +80,7 @@ public class CommandFilter extends CommandBase {
|
||||
public Filter(String name, String predicate, Set<PacketType> packets) {
|
||||
this.name = name;
|
||||
this.predicate = predicate;
|
||||
this.packets = Sets.newHashSet(packets);
|
||||
this.packets = new HashSet<>(packets);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,7 +104,7 @@ public class CommandFilter extends CommandBase {
|
||||
* @return Set of packets this filter applies to.
|
||||
*/
|
||||
public Set<PacketType> getRanges() {
|
||||
return Sets.newHashSet(packets);
|
||||
return new HashSet<>(packets);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,7 @@ import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -34,25 +35,17 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.comphenix.protocol.utility.ByteBuddyGenerated;
|
||||
import com.comphenix.protocol.PacketType.Sender;
|
||||
import com.comphenix.protocol.concurrency.PacketTypeSet;
|
||||
import com.comphenix.protocol.error.ErrorReporter;
|
||||
import com.comphenix.protocol.error.Report;
|
||||
import com.comphenix.protocol.error.ReportType;
|
||||
import com.comphenix.protocol.events.ListeningWhitelist;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import com.comphenix.protocol.reflect.EquivalentConverter;
|
||||
import com.comphenix.protocol.reflect.PrettyPrinter;
|
||||
import com.comphenix.protocol.reflect.PrettyPrinter.ObjectPrinter;
|
||||
import com.comphenix.protocol.utility.ChatExtensions;
|
||||
import com.comphenix.protocol.utility.HexDumper;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.comphenix.protocol.wrappers.BukkitConverters;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Handles the "packet" debug command.
|
||||
@ -306,7 +299,7 @@ class CommandPacket extends CommandBase {
|
||||
}
|
||||
|
||||
private Set<PacketType> filterTypes(Set<PacketType> types, Sender sender) {
|
||||
Set<PacketType> result = Sets.newHashSet();
|
||||
final Set<PacketType> result = new HashSet<>();
|
||||
|
||||
for (PacketType type : types) {
|
||||
if (type.getSender() == sender) {
|
||||
|
@ -17,7 +17,6 @@ import com.comphenix.protocol.utility.MinecraftVersion;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -695,7 +694,8 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
||||
* @return Every packet type.
|
||||
*/
|
||||
public static Iterable<PacketType> values() {
|
||||
List<Iterable<? extends PacketType>> sources = Lists.newArrayList();
|
||||
final List<Iterable<? extends PacketType>> sources = new ArrayList<>();
|
||||
|
||||
sources.add(Handshake.Client.getInstance());
|
||||
sources.add(Handshake.Server.getInstance());
|
||||
sources.add(Play.Client.getInstance());
|
||||
|
@ -23,11 +23,6 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Represents a more modern object-based enum.
|
||||
* <p>
|
||||
@ -37,7 +32,7 @@ import com.google.common.collect.Sets;
|
||||
*/
|
||||
public class PacketTypeEnum implements Iterable<PacketType> {
|
||||
// Used to convert between IDs and names
|
||||
protected Set<PacketType> members = Sets.newHashSet();
|
||||
protected Set<PacketType> members = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Registers every declared PacketType field.
|
||||
|
@ -19,14 +19,14 @@ import com.google.common.collect.Multimap;
|
||||
class PacketTypeLookup {
|
||||
public static class ProtocolSenderLookup {
|
||||
// Unroll lookup for performance reasons
|
||||
public final IntegerMap<PacketType> HANDSHAKE_CLIENT = IntegerMap.newMap();
|
||||
public final IntegerMap<PacketType> HANDSHAKE_SERVER = IntegerMap.newMap();
|
||||
public final IntegerMap<PacketType> GAME_CLIENT = IntegerMap.newMap();
|
||||
public final IntegerMap<PacketType> GAME_SERVER = IntegerMap.newMap();
|
||||
public final IntegerMap<PacketType> STATUS_CLIENT = IntegerMap.newMap();
|
||||
public final IntegerMap<PacketType> STATUS_SERVER = IntegerMap.newMap();
|
||||
public final IntegerMap<PacketType> LOGIN_CLIENT = IntegerMap.newMap();
|
||||
public final IntegerMap<PacketType> LOGIN_SERVER = IntegerMap.newMap();
|
||||
public final IntegerMap<PacketType> HANDSHAKE_CLIENT = new IntegerMap<>();
|
||||
public final IntegerMap<PacketType> HANDSHAKE_SERVER = new IntegerMap<>();
|
||||
public final IntegerMap<PacketType> GAME_CLIENT = new IntegerMap<>();
|
||||
public final IntegerMap<PacketType> GAME_SERVER = new IntegerMap<>();
|
||||
public final IntegerMap<PacketType> STATUS_CLIENT = new IntegerMap<>();
|
||||
public final IntegerMap<PacketType> STATUS_SERVER = new IntegerMap<>();
|
||||
public final IntegerMap<PacketType> LOGIN_CLIENT = new IntegerMap<>();
|
||||
public final IntegerMap<PacketType> LOGIN_SERVER = new IntegerMap<>();
|
||||
|
||||
/**
|
||||
* Retrieve the correct integer map for a specific protocol and sender.
|
||||
@ -52,14 +52,14 @@ class PacketTypeLookup {
|
||||
|
||||
public static class ClassLookup {
|
||||
// Unroll lookup for performance reasons
|
||||
public final Map<String, PacketType> HANDSHAKE_CLIENT = new ConcurrentHashMap<String, PacketType>();
|
||||
public final Map<String, PacketType> HANDSHAKE_SERVER = new ConcurrentHashMap<String, PacketType>();
|
||||
public final Map<String, PacketType> GAME_CLIENT = new ConcurrentHashMap<String, PacketType>();
|
||||
public final Map<String, PacketType> GAME_SERVER = new ConcurrentHashMap<String, PacketType>();
|
||||
public final Map<String, PacketType> STATUS_CLIENT = new ConcurrentHashMap<String, PacketType>();
|
||||
public final Map<String, PacketType> STATUS_SERVER = new ConcurrentHashMap<String, PacketType>();
|
||||
public final Map<String, PacketType> LOGIN_CLIENT = new ConcurrentHashMap<String, PacketType>();
|
||||
public final Map<String, PacketType> LOGIN_SERVER = new ConcurrentHashMap<String, PacketType>();
|
||||
public final Map<String, PacketType> HANDSHAKE_CLIENT = new ConcurrentHashMap<>();
|
||||
public final Map<String, PacketType> HANDSHAKE_SERVER = new ConcurrentHashMap<>();
|
||||
public final Map<String, PacketType> GAME_CLIENT = new ConcurrentHashMap<>();
|
||||
public final Map<String, PacketType> GAME_SERVER = new ConcurrentHashMap<>();
|
||||
public final Map<String, PacketType> STATUS_CLIENT = new ConcurrentHashMap<>();
|
||||
public final Map<String, PacketType> STATUS_SERVER = new ConcurrentHashMap<>();
|
||||
public final Map<String, PacketType> LOGIN_CLIENT = new ConcurrentHashMap<>();
|
||||
public final Map<String, PacketType> LOGIN_SERVER = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Retrieve the correct integer map for a specific protocol and sender.
|
||||
@ -84,9 +84,9 @@ class PacketTypeLookup {
|
||||
}
|
||||
|
||||
// Packet IDs from 1.6.4 and below
|
||||
private final IntegerMap<PacketType> legacyLookup = new IntegerMap<PacketType>();
|
||||
private final IntegerMap<PacketType> serverLookup = new IntegerMap<PacketType>();
|
||||
private final IntegerMap<PacketType> clientLookup = new IntegerMap<PacketType>();
|
||||
private final IntegerMap<PacketType> legacyLookup = new IntegerMap<>();
|
||||
private final IntegerMap<PacketType> serverLookup = new IntegerMap<>();
|
||||
private final IntegerMap<PacketType> clientLookup = new IntegerMap<>();
|
||||
|
||||
// Packets for 1.7.2
|
||||
private final ProtocolSenderLookup idLookup = new ProtocolSenderLookup();
|
||||
|
@ -1,29 +1,29 @@
|
||||
package com.comphenix.protocol;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import com.comphenix.protocol.PacketType.Protocol;
|
||||
import com.comphenix.protocol.PacketType.Sender;
|
||||
import com.comphenix.protocol.events.ConnectionSide;
|
||||
import com.google.common.collect.ContiguousSet;
|
||||
import com.google.common.collect.DiscreteDomain;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Range;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
class PacketTypeParser {
|
||||
public final static Range<Integer> DEFAULT_MAX_RANGE = Range.closed(0, 255);
|
||||
public static final Range<Integer> DEFAULT_MAX_RANGE = Range.closed(0, 255);
|
||||
|
||||
private Sender side = null;
|
||||
private Protocol protocol = null;
|
||||
|
||||
public Set<PacketType> parseTypes(Deque<String> arguments, Range<Integer> defaultRange) {
|
||||
Set<PacketType> result = Sets.newHashSet();
|
||||
final Set<PacketType> result = new HashSet<>();
|
||||
side = null;
|
||||
protocol = null;
|
||||
|
||||
@ -68,8 +68,7 @@ class PacketTypeParser {
|
||||
|
||||
// Supply a default integer range
|
||||
if (ranges.isEmpty() && result.isEmpty()) {
|
||||
ranges = Lists.newArrayList();
|
||||
ranges.add(defaultRange);
|
||||
ranges = Collections.singletonList(defaultRange);
|
||||
}
|
||||
|
||||
for (Range<Integer> range : ranges) {
|
||||
@ -130,19 +129,20 @@ class PacketTypeParser {
|
||||
* @return The protocol, or NULL if not found.
|
||||
*/
|
||||
public Protocol parseProtocol(String text) {
|
||||
if (text == null)
|
||||
return null;
|
||||
String candidate = text.toLowerCase();
|
||||
|
||||
if ("handshake".equals(candidate) || "handshaking".equals(candidate))
|
||||
return Protocol.HANDSHAKING;
|
||||
else if ("login".equals(candidate))
|
||||
return Protocol.LOGIN;
|
||||
else if ("play".equals(candidate) || "game".equals(candidate))
|
||||
return Protocol.PLAY;
|
||||
else if ("status".equals(candidate))
|
||||
return Protocol.STATUS;
|
||||
else
|
||||
return null;
|
||||
if (text == null) return null;
|
||||
|
||||
switch (text.toLowerCase()) {
|
||||
case "handshake":
|
||||
case "handshaking":
|
||||
return Protocol.HANDSHAKING;
|
||||
case "login":
|
||||
return Protocol.LOGIN;
|
||||
case "play":
|
||||
case "game":
|
||||
return Protocol.PLAY;
|
||||
case "status":
|
||||
return Protocol.STATUS;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ import com.comphenix.protocol.utility.MinecraftVersion;
|
||||
import com.comphenix.protocol.utility.NettyVersion;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Handler;
|
||||
@ -235,7 +235,7 @@ public class ProtocolLib extends JavaPlugin {
|
||||
private ErrorReporter getFilteredReporter(ErrorReporter reporter) {
|
||||
return new DelegatedErrorReporter(reporter) {
|
||||
private int lastModCount = -1;
|
||||
private Set<String> reports = Sets.newHashSet();
|
||||
private Set<String> reports = new HashSet<>();
|
||||
|
||||
@Override
|
||||
protected Report filterReport(Object sender, Report report, boolean detailed) {
|
||||
@ -245,7 +245,7 @@ public class ProtocolLib extends JavaPlugin {
|
||||
|
||||
if (config != null && config.getModificationCount() != this.lastModCount) {
|
||||
// Update our cached set again
|
||||
this.reports = Sets.newHashSet(config.getSuppressedReports());
|
||||
this.reports = new HashSet<>(config.getSuppressedReports());
|
||||
this.lastModCount = config.getModificationCount();
|
||||
}
|
||||
|
||||
|
@ -17,22 +17,24 @@
|
||||
|
||||
package com.comphenix.protocol;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ContiguousSet;
|
||||
import com.google.common.collect.DiscreteDomain;
|
||||
import com.google.common.collect.Range;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Used to parse ranges in CommandPacket.
|
||||
*
|
||||
* @author Kristian
|
||||
*/
|
||||
class RangeParser {
|
||||
final class RangeParser {
|
||||
private RangeParser() {}
|
||||
|
||||
/**
|
||||
* Parse a range from a given text.
|
||||
* @param text - the text.
|
||||
@ -40,20 +42,18 @@ class RangeParser {
|
||||
* @return The parsed ranges.
|
||||
*/
|
||||
public static List<Range<Integer>> getRanges(String text, Range<Integer> legalRange) {
|
||||
return getRanges(new ArrayDeque<String>(Arrays.asList(text)), legalRange);
|
||||
return getRanges(new ArrayDeque<>(Collections.singletonList(text)), legalRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse ranges from an array of elements.
|
||||
* @param args - array of elements.
|
||||
* @param offset - beginning offset.
|
||||
* @param lastIndex - the last index of the array to read.
|
||||
* @param input the input to parse the ranges from
|
||||
* @param legalRange - range of legal values.
|
||||
* @return The parsed ranges.
|
||||
*/
|
||||
public static List<Range<Integer>> getRanges(Deque<String> input, Range<Integer> legalRange) {
|
||||
List<String> tokens = tokenizeInput(input);
|
||||
List<Range<Integer>> ranges = new ArrayList<Range<Integer>>();
|
||||
List<Range<Integer>> ranges = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < tokens.size(); i++) {
|
||||
Range<Integer> range;
|
||||
@ -96,7 +96,7 @@ class RangeParser {
|
||||
* @return A simplified list of ranges.
|
||||
*/
|
||||
private static List<Range<Integer>> simplify(List<Range<Integer>> ranges, int maximum) {
|
||||
List<Range<Integer>> result = new ArrayList<Range<Integer>>();
|
||||
List<Range<Integer>> result = new ArrayList<>();
|
||||
boolean[] set = new boolean[maximum + 1];
|
||||
int start = -1;
|
||||
|
||||
@ -125,7 +125,7 @@ class RangeParser {
|
||||
}
|
||||
|
||||
private static List<String> tokenizeInput(Deque<String> input) {
|
||||
List<String> tokens = new ArrayList<String>();
|
||||
List<String> tokens = new ArrayList<>();
|
||||
|
||||
// Tokenize the input
|
||||
while (!input.isEmpty()) {
|
||||
|
@ -36,7 +36,6 @@ import com.comphenix.protocol.injector.SortedPacketListenerList;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -87,7 +86,7 @@ public class AsyncFilterManager implements AsynchronousManager {
|
||||
// Initialize timeout listeners
|
||||
this.serverTimeoutListeners = new SortedPacketListenerList();
|
||||
this.clientTimeoutListeners = new SortedPacketListenerList();
|
||||
this.timeoutListeners = Sets.newSetFromMap(new ConcurrentHashMap<>());
|
||||
this.timeoutListeners = ConcurrentHashMap.newKeySet();
|
||||
|
||||
this.playerSendingHandler = new PlayerSendingHandler(reporter, serverTimeoutListeners, clientTimeoutListeners);
|
||||
this.serverProcessingQueue = new PacketProcessingQueue(playerSendingHandler);
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.comphenix.protocol.collections;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* Represents a very quick integer-based lookup map, with a fixed key space size.
|
||||
@ -16,15 +16,6 @@ public class IntegerMap<T> {
|
||||
private T[] array;
|
||||
private int size;
|
||||
|
||||
/**
|
||||
* Construct a new integer map.
|
||||
* @param <T> Parameter type
|
||||
* @return A new integer map.
|
||||
*/
|
||||
public static <T> IntegerMap<T> newMap() {
|
||||
return new IntegerMap<T>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new integer map with a default capacity.
|
||||
*/
|
||||
@ -128,7 +119,7 @@ public class IntegerMap<T> {
|
||||
* @return The Integer map.
|
||||
*/
|
||||
public Map<Integer, Object> toMap() {
|
||||
Map<Integer, Object> map = Maps.newHashMap();
|
||||
final Map<Integer, Object> map = new HashMap<>();
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
if (array[i] != null) {
|
||||
|
@ -7,7 +7,6 @@ import com.google.common.base.Preconditions;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.RemovalListener;
|
||||
import com.google.common.collect.AbstractIterator;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
@ -73,7 +72,7 @@ public class ConcurrentPlayerMap<TValue> extends AbstractMap<Player, TValue> imp
|
||||
* @return Concurrent player map.
|
||||
*/
|
||||
public static <T> ConcurrentPlayerMap<T> usingAddress() {
|
||||
return new ConcurrentPlayerMap<T>(PlayerKey.ADDRESS);
|
||||
return new ConcurrentPlayerMap<>(PlayerKey.ADDRESS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,7 +81,7 @@ public class ConcurrentPlayerMap<TValue> extends AbstractMap<Player, TValue> imp
|
||||
* @return Concurrent player map.
|
||||
*/
|
||||
public static <T> ConcurrentPlayerMap<T> usingName() {
|
||||
return new ConcurrentPlayerMap<T>(PlayerKey.NAME);
|
||||
return new ConcurrentPlayerMap<>(PlayerKey.NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,7 +107,7 @@ public class ConcurrentPlayerMap<TValue> extends AbstractMap<Player, TValue> imp
|
||||
* @return The value map.
|
||||
*/
|
||||
private ConcurrentMap<Object, TValue> createValueMap() {
|
||||
return Maps.newConcurrentMap();
|
||||
return new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,7 +116,7 @@ public class ListeningWhitelist {
|
||||
*/
|
||||
private static <T> Set<T> safeSet(Collection<T> set) {
|
||||
if (set != null) {
|
||||
return Sets.newHashSet(set);
|
||||
return new HashSet<>(set);
|
||||
} else {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
@ -204,9 +204,9 @@ public class ListeningWhitelist {
|
||||
|
||||
// Default values
|
||||
private ListenerPriority priority = ListenerPriority.NORMAL;
|
||||
private Set<PacketType> types = Sets.newHashSet();
|
||||
private Set<PacketType> types = new HashSet<>();
|
||||
private GamePhase gamePhase = GamePhase.PLAYING;
|
||||
private Set<ListenerOptions> options = Sets.newHashSet();
|
||||
private Set<ListenerOptions> options = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Construct a new listening whitelist template.
|
||||
|
@ -396,7 +396,7 @@ public abstract class PacketAdapter implements PacketListener {
|
||||
if (options == null) {
|
||||
return options(option);
|
||||
} else {
|
||||
Set<ListenerOptions> current = Sets.newHashSet(options);
|
||||
final Set<ListenerOptions> current = Sets.newHashSet(options);
|
||||
current.add(option);
|
||||
return options(current);
|
||||
}
|
||||
|
@ -17,61 +17,44 @@
|
||||
|
||||
package com.comphenix.protocol.events;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.PacketType.Protocol;
|
||||
import com.comphenix.protocol.injector.StructureCache;
|
||||
import com.comphenix.protocol.reflect.*;
|
||||
import com.comphenix.protocol.reflect.cloning.*;
|
||||
import com.comphenix.protocol.reflect.FuzzyReflection;
|
||||
import com.comphenix.protocol.reflect.ObjectWriter;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.reflect.cloning.AggregateCloner;
|
||||
import com.comphenix.protocol.reflect.cloning.AggregateCloner.BuilderParameters;
|
||||
import com.comphenix.protocol.reflect.cloning.BukkitCloner;
|
||||
import com.comphenix.protocol.reflect.cloning.Cloner;
|
||||
import com.comphenix.protocol.reflect.cloning.CollectionCloner;
|
||||
import com.comphenix.protocol.reflect.cloning.FieldCloner;
|
||||
import com.comphenix.protocol.reflect.cloning.GuavaOptionalCloner;
|
||||
import com.comphenix.protocol.reflect.cloning.ImmutableDetector;
|
||||
import com.comphenix.protocol.reflect.cloning.JavaOptionalCloner;
|
||||
import com.comphenix.protocol.reflect.cloning.SerializableCloner;
|
||||
import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract;
|
||||
import com.comphenix.protocol.reflect.instances.MinecraftGenerator;
|
||||
import com.comphenix.protocol.utility.MinecraftMethods;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||
import com.comphenix.protocol.utility.StreamSerializer;
|
||||
import com.comphenix.protocol.wrappers.*;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.*;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||
|
||||
import com.comphenix.protocol.wrappers.Converters;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.MerchantRecipe;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* Represents a Minecraft packet indirectly.
|
||||
@ -85,8 +68,8 @@ public class PacketContainer extends AbstractStructure implements Serializable {
|
||||
private PacketType type;
|
||||
|
||||
// Support for serialization
|
||||
private static ConcurrentMap<Class<?>, Method> writeMethods = Maps.newConcurrentMap();
|
||||
private static ConcurrentMap<Class<?>, Method> readMethods = Maps.newConcurrentMap();
|
||||
private static ConcurrentMap<Class<?>, Method> writeMethods = new ConcurrentHashMap<>();
|
||||
private static ConcurrentMap<Class<?>, Method> readMethods = new ConcurrentHashMap<>();
|
||||
|
||||
// Used to clone packets
|
||||
private static final AggregateCloner DEEP_CLONER = AggregateCloner
|
||||
|
@ -28,7 +28,6 @@ import com.comphenix.protocol.utility.MinecraftFields;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||
import com.comphenix.protocol.wrappers.WrappedIntHashMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -221,7 +220,7 @@ class EntityUtilities {
|
||||
}
|
||||
|
||||
private List<Object> unwrapBukkit(List<Player> players) {
|
||||
List<Object> output = Lists.newArrayList();
|
||||
final List<Object> output = new ArrayList<>();
|
||||
BukkitUnwrapper unwrapper = new BukkitUnwrapper();
|
||||
|
||||
// Get the NMS equivalent
|
||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginLoadOrder;
|
||||
|
||||
@ -55,12 +56,12 @@ class PluginVerifier {
|
||||
/**
|
||||
* Contains a list of plugins that will detect and use ProtocolLib dynamically, instead of relying on the dependency system.
|
||||
*/
|
||||
private static final Set<String> DYNAMIC_DEPENDENCY = Sets.newHashSet("mcore", "MassiveCore");
|
||||
private static final Set<String> DYNAMIC_DEPENDENCY = ImmutableSet.of("mcore", "MassiveCore");
|
||||
|
||||
/**
|
||||
* Set of plugins that have been loaded after ProtocolLib.
|
||||
*/
|
||||
private final Set<String> loadedAfter = new HashSet<String>();
|
||||
private final Set<String> loadedAfter = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Reference to ProtocolLib.
|
||||
@ -201,7 +202,7 @@ class PluginVerifier {
|
||||
if (list == null)
|
||||
return Collections.emptySet();
|
||||
else
|
||||
return Sets.newHashSet(list);
|
||||
return new HashSet<>(list);
|
||||
}
|
||||
|
||||
// Avoid cycles. DFS.
|
||||
|
@ -30,9 +30,6 @@ import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.reflect.fuzzy.FuzzyFieldContract;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Static packet registry in Minecraft.
|
||||
@ -51,9 +48,9 @@ public class PacketRegistry {
|
||||
private final Map<PacketType, Optional<Class<?>>> typeToClass = new ConcurrentHashMap<>();
|
||||
private final Map<Class<?>, PacketType> classToType = new ConcurrentHashMap<>();
|
||||
|
||||
private volatile Set<PacketType> serverPackets = Sets.newHashSet();
|
||||
private volatile Set<PacketType> clientPackets = Sets.newHashSet();
|
||||
private final List<MapContainer> containers = Lists.newArrayList();
|
||||
private volatile Set<PacketType> serverPackets = new HashSet<>();
|
||||
private volatile Set<PacketType> clientPackets = new HashSet<>();
|
||||
private final List<MapContainer> containers = new ArrayList<>();
|
||||
|
||||
public Register() {}
|
||||
|
||||
@ -106,8 +103,8 @@ public class PacketRegistry {
|
||||
Object[] protocols = ENUM_PROTOCOL.getEnumConstants();
|
||||
|
||||
// ID to Packet class maps
|
||||
Map<Object, Map<Integer, Class<?>>> serverMaps = Maps.newLinkedHashMap();
|
||||
Map<Object, Map<Integer, Class<?>>> clientMaps = Maps.newLinkedHashMap();
|
||||
final Map<Object, Map<Integer, Class<?>>> serverMaps = new LinkedHashMap<>();
|
||||
final Map<Object, Map<Integer, Class<?>>> clientMaps = new LinkedHashMap<>();
|
||||
|
||||
Register result = new Register();
|
||||
StructureModifier<Object> modifier = null;
|
||||
@ -157,8 +154,8 @@ public class PacketRegistry {
|
||||
Object[] protocols = ENUM_PROTOCOL.getEnumConstants();
|
||||
|
||||
// ID to Packet class maps
|
||||
Map<Object, Map<Class<?>, Integer>> serverMaps = Maps.newLinkedHashMap();
|
||||
Map<Object, Map<Class<?>, Integer>> clientMaps = Maps.newLinkedHashMap();
|
||||
final Map<Object, Map<Class<?>, Integer>> serverMaps = new LinkedHashMap<>();
|
||||
final Map<Object, Map<Class<?>, Integer>> clientMaps = new LinkedHashMap<>();
|
||||
|
||||
Register result = new Register();
|
||||
Field mainMapField = null;
|
||||
|
@ -2,10 +2,10 @@ package com.comphenix.protocol.reflect;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.comphenix.protocol.reflect.ClassAnalyser.AsmMethod.AsmOpcodes;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.bytebuddy.jar.asm.ClassReader;
|
||||
import net.bytebuddy.jar.asm.ClassVisitor;
|
||||
import net.bytebuddy.jar.asm.MethodVisitor;
|
||||
@ -109,7 +109,7 @@ public class ClassAnalyser {
|
||||
*/
|
||||
private List<AsmMethod> getMethodCalls(Class<?> clazz, Method method) throws IOException {
|
||||
final ClassReader reader = new ClassReader(clazz.getCanonicalName());
|
||||
final List<AsmMethod> output = Lists.newArrayList();
|
||||
final List<AsmMethod> output = new ArrayList<>();
|
||||
|
||||
// The method we are looking for
|
||||
final String methodName = method.getName();
|
||||
|
@ -20,6 +20,8 @@ package com.comphenix.protocol.reflect;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -31,8 +33,6 @@ import org.apache.commons.lang.Validate;
|
||||
import com.comphenix.protocol.reflect.accessors.Accessors;
|
||||
import com.comphenix.protocol.reflect.fuzzy.AbstractFuzzyMatcher;
|
||||
import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
@ -211,7 +211,7 @@ public class FuzzyReflection {
|
||||
* @return List of found methods.
|
||||
*/
|
||||
public List<Method> getMethodList(AbstractFuzzyMatcher<MethodInfo> matcher) {
|
||||
List<Method> methods = Lists.newArrayList();
|
||||
final List<Method> methods = new ArrayList<>();
|
||||
|
||||
// Add all matching fields to the list
|
||||
for (Method method : getMethods()) {
|
||||
@ -349,7 +349,7 @@ public class FuzzyReflection {
|
||||
* @return Every method that satisfies the given constraints.
|
||||
*/
|
||||
public List<Method> getMethodListByParameters(Class<?> returnType, Class<?>[] args) {
|
||||
List<Method> methods = new ArrayList<Method>();
|
||||
final List<Method> methods = new ArrayList<>();
|
||||
|
||||
// Find the correct method to call
|
||||
for (Method method : getMethods()) {
|
||||
@ -388,7 +388,7 @@ public class FuzzyReflection {
|
||||
* @return The first field with a type that is an instance of the given type.
|
||||
*/
|
||||
public Field getFieldByType(String name, Class<?> type) {
|
||||
List<Field> fields = getFieldListByType(type);
|
||||
final List<Field> fields = getFieldListByType(type);
|
||||
|
||||
if (fields.size() > 0) {
|
||||
return fields.get(0);
|
||||
@ -406,7 +406,7 @@ public class FuzzyReflection {
|
||||
* @return Every field with a type that is an instance of the given type.
|
||||
*/
|
||||
public List<Field> getFieldListByType(Class<?> type) {
|
||||
List<Field> fields = new ArrayList<Field>();
|
||||
final List<Field> fields = new ArrayList<>();
|
||||
|
||||
// Field with a compatible type
|
||||
for (Field field : getFields()) {
|
||||
@ -468,7 +468,7 @@ public class FuzzyReflection {
|
||||
* @return List of found fields.
|
||||
*/
|
||||
public List<Field> getFieldList(AbstractFuzzyMatcher<Field> matcher) {
|
||||
List<Field> fields = Lists.newArrayList();
|
||||
final List<Field> fields = new ArrayList<>();
|
||||
|
||||
// Add all matching fields to the list
|
||||
for (Field field : getFields()) {
|
||||
@ -550,7 +550,7 @@ public class FuzzyReflection {
|
||||
* @throws IllegalArgumentException If the constructor cannot be found.
|
||||
*/
|
||||
public Constructor<?> getConstructor(AbstractFuzzyMatcher<MethodInfo> matcher) {
|
||||
List<Constructor<?>> result = getConstructorList(matcher);
|
||||
final List<Constructor<?>> result = getConstructorList(matcher);
|
||||
|
||||
if (result.size() > 0)
|
||||
return result.get(0);
|
||||
@ -566,7 +566,7 @@ public class FuzzyReflection {
|
||||
* @return A map over every given method.
|
||||
*/
|
||||
public Map<String, Method> getMappedMethods(List<Method> methods) {
|
||||
Map<String, Method> map = Maps.newHashMap();
|
||||
final Map<String, Method> map = new HashMap<>();
|
||||
|
||||
for (Method method : methods) {
|
||||
map.put(method.getName(), method);
|
||||
@ -582,7 +582,7 @@ public class FuzzyReflection {
|
||||
* @return List of found constructors.
|
||||
*/
|
||||
public List<Constructor<?>> getConstructorList(AbstractFuzzyMatcher<MethodInfo> matcher) {
|
||||
List<Constructor<?>> constructors = Lists.newArrayList();
|
||||
final List<Constructor<?>> constructors = new ArrayList<>();
|
||||
|
||||
// Add all matching fields to the list
|
||||
for (Constructor<?> constructor : getConstructors()) {
|
||||
@ -659,12 +659,10 @@ public class FuzzyReflection {
|
||||
|
||||
@SafeVarargs
|
||||
private static <T> Set<T> setUnion(T[]... array) {
|
||||
Set<T> result = new LinkedHashSet<T>();
|
||||
final Set<T> result = new LinkedHashSet<>();
|
||||
|
||||
for (T[] elements : array) {
|
||||
for (T element : elements) {
|
||||
result.add(element);
|
||||
}
|
||||
Collections.addAll(result, elements);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -6,12 +6,11 @@ import java.lang.reflect.GenericDeclaration;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.TypeVariable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Represents a method or a constructor.
|
||||
*
|
||||
@ -103,11 +102,10 @@ public abstract class MethodInfo implements GenericDeclaration, Member {
|
||||
* @return Method info list.
|
||||
*/
|
||||
public static List<MethodInfo> fromMethods(Collection<Method> methods) {
|
||||
List<MethodInfo> infos = Lists.newArrayList();
|
||||
|
||||
for (Method method : methods)
|
||||
infos.add(fromMethod(method));
|
||||
return infos;
|
||||
final List<MethodInfo> list = new ArrayList<>();
|
||||
|
||||
for (Method method : methods) list.add(fromMethod(method));
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,7 +193,7 @@ public abstract class MethodInfo implements GenericDeclaration, Member {
|
||||
* @return Method info list.
|
||||
*/
|
||||
public static List<MethodInfo> fromConstructors(Collection<Constructor<?>> constructors) {
|
||||
List<MethodInfo> infos = Lists.newArrayList();
|
||||
final List<MethodInfo> infos = new ArrayList<>();
|
||||
|
||||
for (Constructor<?> constructor : constructors)
|
||||
infos.add(fromConstructor(constructor));
|
||||
|
@ -36,7 +36,6 @@ import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Provides list-oriented access to the fields of a Minecraft packet.
|
||||
@ -58,7 +57,7 @@ public class StructureModifier<TField> {
|
||||
|
||||
// The fields to read in order
|
||||
protected Class fieldType;
|
||||
protected List<Field> data = new ArrayList<Field>();
|
||||
protected List<Field> data = new ArrayList<>();
|
||||
|
||||
// Improved default values
|
||||
protected Map<Field, Integer> defaultFields;
|
||||
@ -76,7 +75,7 @@ public class StructureModifier<TField> {
|
||||
private static DefaultInstances DEFAULT_GENERATOR = getDefaultGenerator();
|
||||
|
||||
private static DefaultInstances getDefaultGenerator() {
|
||||
List<InstanceProvider> providers = Lists.newArrayList();
|
||||
final List<InstanceProvider> providers = new ArrayList<>();
|
||||
|
||||
// Prevent certain classes from being generated
|
||||
providers.add(new BannedGenerator(MinecraftReflection.getItemStackClass(), MinecraftReflection.getBlockClass()));
|
||||
@ -120,10 +119,9 @@ public class StructureModifier<TField> {
|
||||
*/
|
||||
public StructureModifier(Class targetType, Class superclassExclude, boolean requireDefault, boolean useStructureCompiler) {
|
||||
List<Field> fields = getFields(targetType, superclassExclude);
|
||||
Map<Field, Integer> defaults = requireDefault ? generateDefaultFields(fields) : new HashMap<Field, Integer>();
|
||||
Map<Field, Integer> defaults = requireDefault ? generateDefaultFields(fields) : new HashMap<>();
|
||||
|
||||
initialize(targetType, Object.class, fields, defaults, null,
|
||||
new ConcurrentHashMap<Class, StructureModifier>(), useStructureCompiler);
|
||||
initialize(targetType, Object.class, fields, defaults, null, new ConcurrentHashMap<>(), useStructureCompiler);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -510,8 +508,8 @@ public class StructureModifier<TField> {
|
||||
|
||||
// Do we need to update the cache?
|
||||
if (result == null) {
|
||||
List<Field> filtered = new ArrayList<Field>();
|
||||
Map<Field, Integer> defaults = new HashMap<Field, Integer>();
|
||||
List<Field> filtered = new ArrayList<>();
|
||||
Map<Field, Integer> defaults = new HashMap<>();
|
||||
int index = 0;
|
||||
|
||||
for (Field field : data) {
|
||||
@ -607,9 +605,9 @@ public class StructureModifier<TField> {
|
||||
Class fieldType, List<Field> filtered,
|
||||
Map<Field, Integer> defaults, EquivalentConverter<T> converter) {
|
||||
|
||||
StructureModifier<T> result = new StructureModifier<T>();
|
||||
StructureModifier<T> result = new StructureModifier<>();
|
||||
result.initialize(targetType, fieldType, filtered, defaults,
|
||||
converter, new ConcurrentHashMap<Class, StructureModifier>(),
|
||||
converter, new ConcurrentHashMap<>(),
|
||||
useStructureCompiler);
|
||||
return result;
|
||||
}
|
||||
@ -620,7 +618,7 @@ public class StructureModifier<TField> {
|
||||
* @return Structure modifier with the new target.
|
||||
*/
|
||||
public StructureModifier<TField> withTarget(Object target) {
|
||||
StructureModifier<TField> copy = new StructureModifier<TField>();
|
||||
final StructureModifier<TField> copy = new StructureModifier<>();
|
||||
|
||||
// Create a new instance
|
||||
copy.initialize(this);
|
||||
@ -676,7 +674,7 @@ public class StructureModifier<TField> {
|
||||
* @throws FieldAccessException Unable to access one or all of the fields
|
||||
*/
|
||||
public List<TField> getValues() throws FieldAccessException {
|
||||
List<TField> values = new ArrayList<TField>();
|
||||
final List<TField> values = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < size(); i++) {
|
||||
values.add(read(i));
|
||||
@ -687,8 +685,7 @@ public class StructureModifier<TField> {
|
||||
|
||||
// Used to generate plausible default values
|
||||
private static Map<Field, Integer> generateDefaultFields(List<Field> fields) {
|
||||
|
||||
Map<Field, Integer> requireDefaults = new HashMap<Field, Integer>();
|
||||
final Map<Field, Integer> requireDefaults = new HashMap<>();
|
||||
DefaultInstances generator = DEFAULT_GENERATOR;
|
||||
int index = 0;
|
||||
|
||||
@ -714,7 +711,7 @@ public class StructureModifier<TField> {
|
||||
|
||||
// Used to filter out irrelevant fields
|
||||
private static List<Field> getFields(Class type, Class superclassExclude) {
|
||||
List<Field> result = new ArrayList<Field>();
|
||||
final List<Field> result = new ArrayList<>();
|
||||
|
||||
// Retrieve every private and public field
|
||||
for (Field field : FuzzyReflection.fromClass(type, true).getDeclaredFields(superclassExclude)) {
|
||||
|
@ -18,6 +18,7 @@
|
||||
package com.comphenix.protocol.reflect.cloning;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -75,8 +76,8 @@ public class AggregateCloner implements Cloner {
|
||||
* @author Kristian
|
||||
*/
|
||||
public static class Builder {
|
||||
private List<Function<BuilderParameters, Cloner>> factories = Lists.newArrayList();
|
||||
private BuilderParameters parameters;
|
||||
private final List<Function<BuilderParameters, Cloner>> factories = new ArrayList<>();
|
||||
private final BuilderParameters parameters;
|
||||
|
||||
/**
|
||||
* Create a new aggregate builder.
|
||||
@ -147,7 +148,7 @@ public class AggregateCloner implements Cloner {
|
||||
);
|
||||
|
||||
// Build every cloner in the correct order
|
||||
List<Cloner> cloners = Lists.newArrayList();
|
||||
final List<Cloner> cloners = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < factories.size(); i++) {
|
||||
Cloner cloner = factories.get(i).apply(parameters);
|
||||
|
@ -21,6 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@ -39,7 +40,7 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
||||
* @author Kristian
|
||||
*/
|
||||
public class BukkitCloner implements Cloner {
|
||||
private static final Map<Class<?>, Function<Object, Object>> CLONERS = Maps.newConcurrentMap();
|
||||
private static final Map<Class<?>, Function<Object, Object>> CLONERS = new ConcurrentHashMap<>();
|
||||
|
||||
private static void fromWrapper(Supplier<Class<?>> getClass, Function<Object, ClonableWrapper> fromHandle) {
|
||||
try {
|
||||
|
@ -28,6 +28,7 @@ import java.security.PublicKey;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
@ -35,7 +36,6 @@ import javax.crypto.SecretKey;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.primitives.Primitives;
|
||||
|
||||
/**
|
||||
@ -55,7 +55,7 @@ public class ImmutableDetector implements Cloner {
|
||||
SecretKey.class, PublicKey.class
|
||||
);
|
||||
|
||||
private static final Set<Class<?>> immutableNMS = Sets.newConcurrentHashSet();
|
||||
private static final Set<Class<?>> immutableNMS = ConcurrentHashMap.newKeySet();
|
||||
|
||||
static {
|
||||
add(MinecraftReflection::getGameProfileClass);
|
||||
|
@ -20,6 +20,7 @@ package com.comphenix.protocol.reflect.compiler;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryPoolMXBean;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
@ -35,7 +36,6 @@ import com.comphenix.protocol.error.ReportType;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.reflect.compiler.StructureCompiler.StructureKey;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
|
||||
/**
|
||||
@ -66,7 +66,7 @@ public class BackgroundCompiler {
|
||||
private static BackgroundCompiler backgroundCompiler;
|
||||
|
||||
// Classes we're currently compiling
|
||||
private Map<StructureKey, List<CompileListener<?>>> listeners = Maps.newHashMap();
|
||||
private Map<StructureKey, List<CompileListener<?>>> listeners = new HashMap<>();
|
||||
private Object listenerLock = new Object();
|
||||
|
||||
private StructureCompiler compiler;
|
||||
|
@ -18,13 +18,13 @@
|
||||
package com.comphenix.protocol.reflect.compiler;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.reflect.instances.DefaultInstances;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Represents a compiled structure modifier.
|
||||
@ -48,7 +48,7 @@ public abstract class CompiledStructureModifier extends StructureModifier<Object
|
||||
// We can remove the read-only status
|
||||
if (isReadOnly(fieldIndex) && !value) {
|
||||
if (exempted == null)
|
||||
exempted = Sets.newHashSet();
|
||||
exempted = new HashSet<>();
|
||||
exempted.add(fieldIndex);
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,13 @@ package com.comphenix.protocol.reflect.fuzzy;
|
||||
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* Represents a matcher that matches members.
|
||||
@ -251,7 +251,7 @@ public abstract class AbstractFuzzyMember<T extends Member> extends AbstractFuzz
|
||||
* @return A modifiable key-value view.
|
||||
*/
|
||||
protected Map<String, Object> getKeyValueView() {
|
||||
Map<String, Object> map = Maps.newLinkedHashMap();
|
||||
final Map<String, Object> map = new LinkedHashMap<>();
|
||||
|
||||
// Build our representation
|
||||
if (modifiersRequired != Integer.MAX_VALUE || modifiersBanned != 0) {
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.comphenix.protocol.reflect.fuzzy;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -11,7 +13,6 @@ import com.comphenix.protocol.reflect.FuzzyReflection;
|
||||
import com.comphenix.protocol.reflect.MethodInfo;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
@ -33,12 +34,12 @@ public class FuzzyClassContract extends AbstractFuzzyMatcher<Class<?>> {
|
||||
*
|
||||
*/
|
||||
public static class Builder {
|
||||
private List<AbstractFuzzyMatcher<Field>> fieldContracts = Lists.newArrayList();
|
||||
private List<AbstractFuzzyMatcher<MethodInfo>> methodContracts = Lists.newArrayList();
|
||||
private List<AbstractFuzzyMatcher<MethodInfo>> constructorContracts = Lists.newArrayList();
|
||||
private final List<AbstractFuzzyMatcher<Field>> fieldContracts = new ArrayList<>();
|
||||
private final List<AbstractFuzzyMatcher<MethodInfo>> methodContracts = new ArrayList<>();
|
||||
private final List<AbstractFuzzyMatcher<MethodInfo>> constructorContracts = new ArrayList<>();
|
||||
|
||||
private List<AbstractFuzzyMatcher<Class<?>>> baseclassContracts = Lists.newArrayList();
|
||||
private List<AbstractFuzzyMatcher<Class<?>>> interfaceContracts = Lists.newArrayList();
|
||||
private final List<AbstractFuzzyMatcher<Class<?>>> baseclassContracts = new ArrayList<>();
|
||||
private final List<AbstractFuzzyMatcher<Class<?>>> interfaceContracts = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Add a new field contract.
|
||||
@ -305,7 +306,7 @@ public class FuzzyClassContract extends AbstractFuzzyMatcher<Class<?>> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
Map<String, Object> params = Maps.newLinkedHashMap();
|
||||
final Map<String, Object> params = new LinkedHashMap<>();
|
||||
|
||||
if (fieldContracts.size() > 0) {
|
||||
params.put("fields", fieldContracts);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.comphenix.protocol.reflect.fuzzy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -10,8 +11,6 @@ import javax.annotation.Nonnull;
|
||||
import com.comphenix.protocol.reflect.MethodInfo;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Represents a contract for matching methods or constructors.
|
||||
*
|
||||
@ -394,8 +393,8 @@ public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo> {
|
||||
|
||||
private FuzzyMethodContract() {
|
||||
// Only allow construction from the builder
|
||||
paramMatchers = Lists.newArrayList();
|
||||
exceptionMatchers = Lists.newArrayList();
|
||||
paramMatchers = new ArrayList<>();
|
||||
exceptionMatchers = new ArrayList<>();
|
||||
}
|
||||
|
||||
private FuzzyMethodContract(FuzzyMethodContract other) {
|
||||
|
@ -3,6 +3,7 @@ package com.comphenix.protocol.timing;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@ -10,7 +11,6 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* Represents a system for recording the time spent by each packet listener.
|
||||
@ -33,7 +33,7 @@ public class TimedListenerManager {
|
||||
private volatile Date stopped;
|
||||
|
||||
// The map of time trackers
|
||||
private ConcurrentMap<String, ImmutableMap<ListenerType, TimedTracker>> map = Maps.newConcurrentMap();
|
||||
private final ConcurrentMap<String, ImmutableMap<ListenerType, TimedTracker>> map = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Retrieve the shared listener manager.
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.comphenix.protocol.timing;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@ -60,7 +59,7 @@ public class TimedTracker {
|
||||
* @return The map of statistics.
|
||||
*/
|
||||
public synchronized Map<PacketType, StatisticsStream> getStatistics() {
|
||||
Map<PacketType, StatisticsStream> clone = Maps.newHashMap();
|
||||
final Map<PacketType, StatisticsStream> clone = new HashMap<>();
|
||||
|
||||
for (Entry<PacketType, StatisticsStream> entry : this.packets.entrySet()) {
|
||||
clone.put(
|
||||
|
@ -6,6 +6,7 @@ import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.timing.TimedListenerManager.ListenerType;
|
||||
@ -75,7 +76,7 @@ public class TimingReportGenerator {
|
||||
destination.write(SEPERATION_LINE);
|
||||
|
||||
// Write every packet ID that we care about
|
||||
for (PacketType key : Sets.newTreeSet(streams.keySet())) {
|
||||
for (PacketType key : new TreeSet<>(streams.keySet())) {
|
||||
final StatisticsStream stream = streams.get(key);
|
||||
|
||||
if (stream != null && stream.getCount() > 0) {
|
||||
|
@ -18,6 +18,7 @@ package com.comphenix.protocol.utility;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
@ -40,7 +41,7 @@ class CachedPackage {
|
||||
*/
|
||||
public CachedPackage(String packageName, ClassSource source) {
|
||||
this.packageName = packageName;
|
||||
this.cache = Maps.newConcurrentMap();
|
||||
this.cache = new ConcurrentHashMap<>();
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,6 @@ import java.util.Map.Entry;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* A lookup of the associated protocol version of a given Minecraft server.
|
||||
* @author Kristian
|
||||
@ -14,7 +12,7 @@ public class MinecraftProtocolVersion {
|
||||
private static final NavigableMap<MinecraftVersion, Integer> lookup = createLookup();
|
||||
|
||||
private static NavigableMap<MinecraftVersion, Integer> createLookup() {
|
||||
TreeMap<MinecraftVersion, Integer> map = Maps.newTreeMap();
|
||||
TreeMap<MinecraftVersion, Integer> map = new TreeMap<>();
|
||||
|
||||
// Source: http://wiki.vg/Protocol_version_numbers
|
||||
// Doesn't include pre-releases
|
||||
|
@ -31,6 +31,7 @@ import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
@ -69,7 +70,6 @@ import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtType;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* Methods and constants specifically used in conjuction with reflecting Minecraft object.
|
||||
@ -142,7 +142,7 @@ public class MinecraftReflection {
|
||||
private static Class<?> itemStackArrayClass;
|
||||
|
||||
// Cache of getBukkitEntity
|
||||
private static ConcurrentMap<Class<?>, MethodAccessor> getBukkitEntityCache = Maps.newConcurrentMap();
|
||||
private static final ConcurrentMap<Class<?>, MethodAccessor> getBukkitEntityCache = new ConcurrentHashMap<>();
|
||||
|
||||
// The current class source
|
||||
private static ClassSource classSource;
|
||||
|
@ -457,8 +457,8 @@ public abstract class EnumWrappers {
|
||||
private static Class<?> ENTITY_POSE_CLASS = null;
|
||||
|
||||
private static boolean INITIALIZED = false;
|
||||
private static Map<Class<?>, EquivalentConverter<?>> FROM_NATIVE = Maps.newHashMap();
|
||||
private static Map<Class<?>, EquivalentConverter<?>> FROM_WRAPPER = Maps.newHashMap();
|
||||
private static Map<Class<?>, EquivalentConverter<?>> FROM_NATIVE = new HashMap<>();
|
||||
private static Map<Class<?>, EquivalentConverter<?>> FROM_WRAPPER = new HashMap<>();
|
||||
static Set<String> INVALID = new HashSet<>();
|
||||
|
||||
/**
|
||||
|
@ -399,7 +399,7 @@ public class WrappedAttribute extends AbstractWrapper {
|
||||
* @return Unwrapped modifiers.
|
||||
*/
|
||||
private Set<Object> getUnwrappedModifiers() {
|
||||
Set<Object> output = Sets.newHashSet();
|
||||
final Set<Object> output = new HashSet<>();
|
||||
|
||||
for (WrappedAttributeModifier modifier : modifiers) {
|
||||
output.add(modifier.getHandle());
|
||||
|
@ -6,6 +6,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
@ -29,7 +30,6 @@ import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@ -288,7 +288,7 @@ public class WrappedServerPing extends AbstractWrapper implements ClonableWrappe
|
||||
* @param players - the players to display.
|
||||
*/
|
||||
public void setBukkitPlayers(Iterable<? extends Player> players) {
|
||||
List<WrappedGameProfile> profiles = Lists.newArrayList();
|
||||
final List<WrappedGameProfile> profiles = new ArrayList<>();
|
||||
|
||||
for (Player player : players) {
|
||||
Object profile = ENTITY_HUMAN_PROFILE.get(BukkitUnwrapper.getInstance().unwrapItem(player));
|
||||
|
@ -18,12 +18,12 @@
|
||||
package com.comphenix.protocol.wrappers.collection;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Represents a collection that wraps another collection by transforming the elements going in and out.
|
||||
@ -103,7 +103,7 @@ public abstract class ConvertedCollection<VInner, VOuter> extends AbstractConver
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
List<VInner> innerCopy = Lists.newArrayList();
|
||||
final List<VInner> innerCopy = new ArrayList<>();
|
||||
|
||||
// Convert all the elements
|
||||
for (Object outer : c)
|
||||
|
@ -1,12 +1,13 @@
|
||||
package com.comphenix.protocol.wrappers.nbt;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
public abstract class NameProperty {
|
||||
private static final Map<Class<?>, StructureModifier<String>> MODIFIERS = Maps.newConcurrentMap();
|
||||
private static final Map<Class<?>, StructureModifier<String>> MODIFIERS = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Retrieve the name.
|
||||
|
@ -5,6 +5,7 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import com.comphenix.protocol.injector.BukkitUnwrapper;
|
||||
@ -18,8 +19,6 @@ import com.comphenix.protocol.utility.MinecraftMethods;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
|
||||
import net.bytebuddy.implementation.InvocationHandlerAdapter;
|
||||
import net.bytebuddy.jar.asm.ClassReader;
|
||||
@ -41,12 +40,12 @@ class TileEntityAccessor<T extends BlockState> {
|
||||
/**
|
||||
* Token indicating that the given block state doesn't contain any tile entities.
|
||||
*/
|
||||
private static final TileEntityAccessor<BlockState> EMPTY_ACCESSOR = new TileEntityAccessor<BlockState>();
|
||||
private static final TileEntityAccessor<BlockState> EMPTY_ACCESSOR = new TileEntityAccessor<>();
|
||||
|
||||
/**
|
||||
* Cached field accessors - {@link #EMPTY_ACCESSOR} represents no valid tile entity.
|
||||
*/
|
||||
private static final ConcurrentMap<Class<?>, TileEntityAccessor<?>> cachedAccessors = Maps.newConcurrentMap();
|
||||
private static final ConcurrentMap<Class<?>, TileEntityAccessor<?>> cachedAccessors = new ConcurrentHashMap<>();
|
||||
|
||||
private static Constructor<?> nbtCompoundParserConstructor;
|
||||
|
||||
|
@ -5,9 +5,11 @@ import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -19,8 +21,6 @@ import com.comphenix.protocol.wrappers.nbt.NbtList;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtType;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtVisitor;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtWrapper;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
/**
|
||||
@ -81,7 +81,7 @@ public class NbtConfigurationSerializer {
|
||||
private List<Object> currentList;
|
||||
|
||||
// Store the index of a configuration section that works like a list
|
||||
private Map<ConfigurationSection, Integer> workingIndex = Maps.newHashMap();
|
||||
private Map<ConfigurationSection, Integer> workingIndex = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public boolean visitEnter(NbtCompound compound) {
|
||||
@ -99,7 +99,7 @@ public class NbtConfigurationSerializer {
|
||||
current = current.createSection(name);
|
||||
workingIndex.put(current, 0);
|
||||
} else {
|
||||
currentList = Lists.newArrayList();
|
||||
currentList = new ArrayList<>();
|
||||
current.set(name, currentList);
|
||||
}
|
||||
return true;
|
||||
@ -282,17 +282,10 @@ public class NbtConfigurationSerializer {
|
||||
|
||||
private List<String> sortSet(Set<String> unsorted) {
|
||||
// Convert to integers
|
||||
List<String> sorted = new ArrayList<String>(unsorted);
|
||||
|
||||
Collections.sort(sorted, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
// Parse the name
|
||||
int index1 = Integer.parseInt(getDecodedName(o1)[0]);
|
||||
int index2 = Integer.parseInt(getDecodedName(o2)[0]);
|
||||
return Ints.compare(index1, index2);
|
||||
}
|
||||
});
|
||||
final List<String> sorted = new ArrayList<>(unsorted);
|
||||
|
||||
// Parse the name and sort.
|
||||
sorted.sort((o1, o2) -> Ints.compare(Integer.parseInt(getDecodedName(o1)[0]), Integer.parseInt(getDecodedName(o2)[0])));
|
||||
return sorted;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user