More deprecation removal

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

View File

@ -67,12 +67,6 @@ public class Countable<T> implements Comparable<Countable<T>> {
@Override
public int compareTo(Countable<T> other) {
if (amount > other.amount) {
return 1;
} else if (amount == other.amount) {
return 0;
} else {
return -1;
}
return Integer.compare(amount, other.amount);
}
}

View File

@ -69,7 +69,7 @@ public final class FileDialogUtil {
private String desc;
private ExtensionFilter(String[] exts) {
this.exts = new HashSet<String>(Arrays.asList(exts));
this.exts = new HashSet<>(Arrays.asList(exts));
desc = StringUtil.joinString(exts, ",");
}

View File

@ -1,46 +0,0 @@
/*
* 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.worldedit.util;
import com.sk89q.worldedit.WorldEdit;
public final class Java7Detector {
public static void notifyIfNot8() {
int major = -1;
try {
String[] ver = System.getProperty("java.version").split("\\.");
major = Integer.parseInt(ver[1]);
} catch (Exception ignored) {
}
if (major == 7) {
WorldEdit.logger.warning(
"WorldEdit has detected you are using Java 7.");
WorldEdit.logger.warning(
"WorldEdit will stop supporting Java less than version 8 in the future,"
+ " due to Java 7 being EOL since April 2015."
+ " Please update your server to Java 8.");
}
}
private Java7Detector() {
}
}

View File

@ -63,20 +63,11 @@ public class PropertiesConfiguration extends LocalConfiguration {
@Override
public void load() {
InputStream stream = null;
try {
stream = new FileInputStream(path);
try (InputStream stream = new FileInputStream(path)) {
properties.load(stream);
} catch (FileNotFoundException ignored) {
} catch (IOException e) {
log.log(Level.WARNING, "Failed to read configuration", e);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException ignored) {
}
}
}
loadExtra();
@ -121,22 +112,11 @@ public class PropertiesConfiguration extends LocalConfiguration {
snapshotRepo = new SnapshotRepository(snapshotsDir);
}
OutputStream output = null;
path.getParentFile().mkdirs();
try {
output = new FileOutputStream(path);
try (OutputStream output = new FileOutputStream(path)) {
properties.store(output, "Don't put comments; they get removed");
} catch (FileNotFoundException e) {
log.log(Level.WARNING, "Failed to write configuration", e);
} catch (IOException e) {
log.log(Level.WARNING, "Failed to write configuration", e);
} finally {
if (output != null) {
try {
output.close();
} catch (IOException ignored) {
}
}
}
}
@ -239,13 +219,13 @@ public class PropertiesConfiguration extends LocalConfiguration {
String val = properties.getProperty(key);
if (val == null) {
properties.setProperty(key, StringUtil.joinString(def, ",", 0));
Set<Integer> set = new HashSet<Integer>();
Set<Integer> set = new HashSet<>();
for (int i : def) {
set.add(i);
}
return set;
} else {
Set<Integer> set = new HashSet<Integer>();
Set<Integer> set = new HashSet<>();
String[] parts = val.split(",");
for (String part : parts) {
try {

View File

@ -20,8 +20,8 @@
package com.sk89q.worldedit.util;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.world.World;
@ -49,7 +49,7 @@ public class TargetBlock {
*/
public TargetBlock(Player player) {
this.world = player.getWorld();
this.setValues(player.getPosition().toVector(), player.getYaw(), player.getPitch(),
this.setValues(player.getLocation().toVector(), player.getLocation().getYaw(), player.getLocation().getPitch(),
300, 1.65, 0.2);
}
@ -62,7 +62,7 @@ public class TargetBlock {
*/
public TargetBlock(Player player, int maxDistance, double checkDistance) {
this.world = player.getWorld();
this.setValues(player.getPosition().toVector(), player.getYaw(), player.getPitch(), maxDistance, 1.65, checkDistance);
this.setValues(player.getLocation().toVector(), player.getLocation().getYaw(), player.getLocation().getPitch(), maxDistance, 1.65, checkDistance);
}
/**
@ -103,7 +103,7 @@ public class TargetBlock {
boolean searchForLastBlock = true;
Location lastBlock = null;
while (getNextBlock() != null) {
if (world.getBlockType(getCurrentBlock().toVector()) == BlockID.AIR) {
if (world.getLazyBlock(getCurrentBlock().toVector()).getType() == BlockTypes.AIR) {
if (searchForLastBlock) {
lastBlock = getCurrentBlock();
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
@ -125,7 +125,7 @@ public class TargetBlock {
* @return Block
*/
public Location getTargetBlock() {
while (getNextBlock() != null && world.getBlockType(getCurrentBlock().toVector()) == 0) ;
while (getNextBlock() != null && world.getLazyBlock(getCurrentBlock().toVector()).getType() == BlockTypes.AIR) ;
return getCurrentBlock();
}

View File

@ -24,7 +24,6 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import javax.annotation.Nullable;
@ -108,7 +107,7 @@ public class TreeGenerator {
/**
* Stores a map of the names for fast access.
*/
private static final Map<String, TreeType> lookup = new HashMap<String, TreeType>();
private static final Map<String, TreeType> lookup = new HashMap<>();
private static final Set<String> primaryAliases = Sets.newHashSet();
private final String name;
@ -204,7 +203,7 @@ public class TreeGenerator {
// Create trunk
for (int i = 0; i < trunkHeight; ++i) {
if (!editSession.setBlockIfAir(basePosition.add(0, i, 0), logBlock)) {
if (!setBlockIfAir(editSession, basePosition.add(0, i, 0), logBlock)) {
return;
}
}
@ -214,38 +213,38 @@ public class TreeGenerator {
// Create tree + leaves
for (int i = 0; i < height; ++i) {
editSession.setBlockIfAir(basePosition.add(0, i, 0), logBlock);
setBlockIfAir(editSession, basePosition.add(0, i, 0), logBlock);
// Less leaves at these levels
double chance = ((i == 0 || i == height - 1) ? 0.6 : 1);
// Inner leaves
editSession.setChanceBlockIfAir(basePosition.add(-1, i, 0), leavesBlock, chance);
editSession.setChanceBlockIfAir(basePosition.add(1, i, 0), leavesBlock, chance);
editSession.setChanceBlockIfAir(basePosition.add(0, i, -1), leavesBlock, chance);
editSession.setChanceBlockIfAir(basePosition.add(0, i, 1), leavesBlock, chance);
editSession.setChanceBlockIfAir(basePosition.add(1, i, 1), leavesBlock, chance);
editSession.setChanceBlockIfAir(basePosition.add(-1, i, 1), leavesBlock, chance);
editSession.setChanceBlockIfAir(basePosition.add(1, i, -1), leavesBlock, chance);
editSession.setChanceBlockIfAir(basePosition.add(-1, i, -1), leavesBlock, chance);
setChanceBlockIfAir(editSession, basePosition.add(-1, i, 0), leavesBlock, chance);
setChanceBlockIfAir(editSession, basePosition.add(1, i, 0), leavesBlock, chance);
setChanceBlockIfAir(editSession, basePosition.add(0, i, -1), leavesBlock, chance);
setChanceBlockIfAir(editSession, basePosition.add(0, i, 1), leavesBlock, chance);
setChanceBlockIfAir(editSession, basePosition.add(1, i, 1), leavesBlock, chance);
setChanceBlockIfAir(editSession, basePosition.add(-1, i, 1), leavesBlock, chance);
setChanceBlockIfAir(editSession, basePosition.add(1, i, -1), leavesBlock, chance);
setChanceBlockIfAir(editSession, basePosition.add(-1, i, -1), leavesBlock, chance);
if (!(i == 0 || i == height - 1)) {
for (int j = -2; j <= 2; ++j) {
editSession.setChanceBlockIfAir(basePosition.add(-2, i, j), leavesBlock, 0.6);
setChanceBlockIfAir(editSession, basePosition.add(-2, i, j), leavesBlock, 0.6);
}
for (int j = -2; j <= 2; ++j) {
editSession.setChanceBlockIfAir(basePosition.add(2, i, j), leavesBlock, 0.6);
setChanceBlockIfAir(editSession, basePosition.add(2, i, j), leavesBlock, 0.6);
}
for (int j = -2; j <= 2; ++j) {
editSession.setChanceBlockIfAir(basePosition.add(j, i, -2), leavesBlock, 0.6);
setChanceBlockIfAir(editSession, basePosition.add(j, i, -2), leavesBlock, 0.6);
}
for (int j = -2; j <= 2; ++j) {
editSession.setChanceBlockIfAir(basePosition.add(j, i, 2), leavesBlock, 0.6);
setChanceBlockIfAir(editSession, basePosition.add(j, i, 2), leavesBlock, 0.6);
}
}
}
editSession.setBlockIfAir(basePosition.add(0, height, 0), leavesBlock);
setBlockIfAir(editSession, basePosition.add(0, height, 0), leavesBlock);
}
/**
@ -260,4 +259,30 @@ public class TreeGenerator {
return TreeType.lookup(type);
}
/**
* Set a block (only if a previous block was not there) if {@link Math#random()}
* returns a number less than the given probability.
*
* @param position the position
* @param block the block
* @param probability a probability between 0 and 1, inclusive
* @return whether a block was changed
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
private static boolean setChanceBlockIfAir(EditSession session, Vector position, BaseBlock block, double probability)
throws MaxChangedBlocksException {
return Math.random() <= probability && setBlockIfAir(session, position, block);
}
/**
* Set a block only if there's no block already there.
*
* @param position the position
* @param block the block to set
* @return if block was changed
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
private static boolean setBlockIfAir(EditSession session, Vector position, BaseBlock block) throws MaxChangedBlocksException {
return session.getBlock(position).isAir() && session.setBlock(position, block);
}
}

View File

@ -19,11 +19,11 @@
package com.sk89q.worldedit.util;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Optional;
import java.util.function.Function;
/**
* Returns the best choice given a weighting function and a target weight.
*
@ -60,12 +60,10 @@ public class WeightedChoice<T> {
public void consider(T object) {
checkNotNull(object);
Number value = checkNotNull(function.apply(object));
if (value != null) {
double distance = Math.abs(target - value.doubleValue());
if (current == null || distance <= best) {
best = distance;
current = object;
}
double distance = Math.abs(target - value.doubleValue());
if (current == null || distance <= best) {
best = distance;
current = object;
}
}
@ -76,9 +74,9 @@ public class WeightedChoice<T> {
*/
public Optional<Choice<T>> getChoice() {
if (current != null) {
return Optional.of(new Choice<T>(current, best));
return Optional.of(new Choice<>(current, best));
} else {
return Optional.absent();
return Optional.empty();
}
}

View File

@ -76,8 +76,8 @@ public class YAMLConfiguration extends LocalConfiguration {
butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius));
butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius));
disallowedBlocks = new HashSet<Integer>(config.getIntList("limits.disallowed-blocks", null));
allowedDataCycleBlocks = new HashSet<Integer>(config.getIntList("limits.allowed-data-cycle-blocks", null));
disallowedBlocks = new HashSet<>(config.getIntList("limits.disallowed-blocks", null));
allowedDataCycleBlocks = new HashSet<>(config.getIntList("limits.allowed-data-cycle-blocks", null));
registerHelp = config.getBoolean("register-help", true);
logCommands = config.getBoolean("logging.log-commands", logCommands);

View File

@ -33,8 +33,8 @@ import java.util.NoSuchElementException;
*/
public class DoubleArrayList<A, B> implements Iterable<Map.Entry<A, B>> {
private List<A> listA = new ArrayList<A>();
private List<B> listB = new ArrayList<B>();
private List<A> listA = new ArrayList<>();
private List<B> listB = new ArrayList<>();
private boolean isReversed = false;
/**
@ -81,11 +81,11 @@ public class DoubleArrayList<A, B> implements Iterable<Map.Entry<A, B>> {
*/
public Iterator<Map.Entry<A, B>> iterator(boolean reversed) {
if (reversed) {
return new ReverseEntryIterator<Map.Entry<A, B>>(
return new ReverseEntryIterator<>(
listA.listIterator(listA.size()),
listB.listIterator(listB.size()));
} else {
return new ForwardEntryIterator<Map.Entry<A, B>>(
return new ForwardEntryIterator<>(
listA.iterator(),
listB.iterator());
}

View File

@ -93,7 +93,7 @@ public class FastListIterator<E> implements Iterator<E> {
* @return an iterator
*/
public static <E> Iterator<E> forwardIterator(List<E> list) {
return new FastListIterator<E>(list, 0, list.size(), 1);
return new FastListIterator<>(list, 0, list.size(), 1);
}
/**
@ -105,9 +105,9 @@ public class FastListIterator<E> implements Iterator<E> {
*/
public static <E> Iterator<E> reverseIterator(List<E> list) {
if (!list.isEmpty()) {
return new FastListIterator<E>(list, list.size() - 1, list.size(), -1);
return new FastListIterator<>(list, list.size() - 1, list.size(), -1);
} else {
return new FastListIterator<E>(list, 0, 0, -1);
return new FastListIterator<>(list, 0, 0, -1);
}
}

View File

@ -39,7 +39,7 @@ public class TupleArrayList<A, B> extends ArrayList<Map.Entry<A, B>> {
* @param b the 'value'
*/
public void put(A a, B b) {
add(new Tuple<A, B>(a, b));
add(new Tuple<>(a, b));
}
/**

View File

@ -28,8 +28,8 @@ import java.util.List;
*/
public class SimpleDescription implements Description {
private List<Parameter> parameters = new ArrayList<Parameter>();
private List<String> permissions = new ArrayList<String>();
private List<Parameter> parameters = new ArrayList<>();
private List<String> permissions = new ArrayList<>();
private String description;
private String help;
private String overrideUsage;

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();
/**
@ -74,7 +74,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
@ -84,7 +84,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());
}
@ -143,7 +143,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)) {

View File

@ -39,7 +39,7 @@ public class FlagParser implements CommandExecutor<FlagData> {
private final Map<Character, CommandExecutor<?>> flags = Maps.newHashMap();
public <T> Flag<T> registerFlag(char flag, CommandExecutor<T> executor) {
Flag<T> ret = new Flag<T>(flag);
Flag<T> ret = new Flag<>(flag);
flags.put(flag, executor);
return ret;
}

View File

@ -63,7 +63,7 @@ public class ProvidedValue<T> implements CommandExecutor<T> {
}
public static <T> ProvidedValue<T> create(T value, String description) {
return new ProvidedValue<T>(value, description);
return new ProvidedValue<>(value, description);
}
}

View File

@ -54,8 +54,8 @@ public class BindingHelper implements Binding {
* Create a new instance.
*/
public BindingHelper() {
List<BoundMethod> bindings = new ArrayList<BoundMethod>();
List<Type> types = new ArrayList<Type>();
List<BoundMethod> bindings = new ArrayList<>();
List<Type> types = new ArrayList<>();
for (Method method : this.getClass().getMethods()) {
BindingMatch info = method.getAnnotation(BindingMatch.class);
@ -145,7 +145,7 @@ public class BindingHelper implements Binding {
public Object bind(ParameterData parameter, ArgumentStack scoped,
boolean onlyConsume) throws ParameterException, CommandException, InvocationTargetException {
BoundMethod binding = match(parameter);
List<Object> args = new ArrayList<Object>();
List<Object> args = new ArrayList<>();
args.add(scoped);
if (binding.classifier != null) {
@ -184,7 +184,7 @@ public class BindingHelper implements Binding {
@Override
public List<String> getSuggestions(ParameterData parameter, String prefix) {
return new ArrayList<String>();
return new ArrayList<>();
}
private static class BoundMethod implements Comparable<BoundMethod> {

View File

@ -42,7 +42,7 @@ public abstract class ExceptionConverterHelper implements ExceptionConverter {
@SuppressWarnings("unchecked")
public ExceptionConverterHelper() {
List<ExceptionHandler> handlers = new ArrayList<ExceptionHandler>();
List<ExceptionHandler> handlers = new ArrayList<>();
for (Method method : this.getClass().getMethods()) {
if (method.getAnnotation(ExceptionMatch.class) == null) {
@ -76,9 +76,7 @@ public abstract class ExceptionConverterHelper implements ExceptionConverter {
throw (CommandException) e.getCause();
}
throw new WrappedCommandException(e);
} catch (IllegalArgumentException e) {
throw new WrappedCommandException(e);
} catch (IllegalAccessException e) {
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new WrappedCommandException(e);
}
}

View File

@ -54,9 +54,9 @@ 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 CachingParanamer();
private final List<InvokeListener> invokeListeners = new ArrayList<InvokeListener>();
private final List<InvokeListener> invokeListeners = new ArrayList<>();
private Authorizer authorizer = new NullAuthorizer();
private CommandCompleter defaultCompleter = new NullCompleter();

View File

@ -39,9 +39,9 @@ class ParametricCallable implements CommandCallable {
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;
@ -63,7 +63,7 @@ class ParametricCallable implements CommandCallable {
String[] names = builder.getParanamer().lookupParameterNames(method, false);
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
@ -186,7 +186,7 @@ class ParametricCallable implements CommandCallable {
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);
@ -422,7 +422,7 @@ class ParametricCallable implements CommandCallable {
if (!found) {
if (unusedFlags == null) {
unusedFlags = new HashSet<Character>();
unusedFlags = new HashSet<>();
}
unusedFlags.add(flag);
}

View File

@ -46,7 +46,7 @@ public final class EvenMoreExecutors {
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
minThreads, maxThreads,
60L, TimeUnit.SECONDS,
new ArrayBlockingQueue<Runnable>(queueSize));
new ArrayBlockingQueue<>(queueSize));
threadPoolExecutor.allowCoreThreadTimeOut(true);
return threadPoolExecutor;
}

View File

@ -19,7 +19,8 @@
package com.sk89q.worldedit.util.eventbus;
import com.google.common.base.Supplier;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap;
@ -27,12 +28,17 @@ import com.google.common.eventbus.DeadEvent;
import com.sk89q.worldedit.internal.annotation.RequiresNewerGuava;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Dispatches events to listeners, and provides ways for listeners to register
* themselves.
@ -50,13 +56,7 @@ public class EventBus {
private final Logger logger = Logger.getLogger(EventBus.class.getCanonicalName());
private final SetMultimap<Class<?>, EventHandler> handlersByType =
Multimaps.newSetMultimap(new HashMap<Class<?>, Collection<EventHandler>>(),
new Supplier<Set<EventHandler>>() {
@Override
public Set<EventHandler> get() {
return newHandlerSet();
}
});
Multimaps.newSetMultimap(new HashMap<>(), this::newHandlerSet);
/**
* Strategy for finding handler methods in registered objects. Currently,
@ -153,7 +153,7 @@ public class EventBus {
* @param event event to post.
*/
public void post(Object event) {
List<EventHandler> dispatching = new ArrayList<EventHandler>();
List<EventHandler> dispatching = new ArrayList<>();
synchronized (this) {
Set<Class<?>> dispatchTypes = flattenHierarchy(event.getClass());
@ -211,7 +211,7 @@ public class EventBus {
* @return a new, mutable set for handlers.
*/
protected synchronized Set<EventHandler> newHandlerSet() {
return new HashSet<EventHandler>();
return new HashSet<>();
}
/**

View File

@ -34,7 +34,7 @@ import java.util.*;
@RequiresNewerGuava
class HierarchyCache {
private final Map<Class<?>, Set<Class<?>>> cache = new WeakHashMap<Class<?>, Set<Class<?>>>();
private final Map<Class<?>, Set<Class<?>>> cache = new WeakHashMap<>();
public Set<Class<?>> get(Class<?> concreteClass) {
Set<Class<?>> ret = cache.get(concreteClass);

View File

@ -126,11 +126,8 @@ public class ColorCodeBuilder {
return builder.toString();
} else if (!resetFrom.hasEqualFormatting(resetTo) ||
(resetFrom.getColor() != null && resetTo.getColor() == null)) {
StringBuilder builder = new StringBuilder();
// Have to set reset code and add back all the formatting codes
builder.append(Style.RESET);
builder.append(getCode(resetTo));
return builder.toString();
return String.valueOf(Style.RESET) + getCode(resetTo);
} else {
if (resetFrom.getColor() != resetTo.getColor()) {
return String.valueOf(resetTo.getColor());
@ -163,7 +160,7 @@ public class ColorCodeBuilder {
char[] rawChars = (rawString + ' ').toCharArray(); // add a trailing space to trigger pagination
StringBuilder word = new StringBuilder();
StringBuilder line = new StringBuilder();
List<String> lines = new LinkedList<String>();
List<String> lines = new LinkedList<>();
int lineColorChars = 0;
for (int i = 0; i < rawChars.length; i++) {

View File

@ -27,7 +27,7 @@ import java.util.List;
*/
public class StyledFragment extends Fragment {
private final List<Fragment> children = new ArrayList<Fragment>();
private final List<Fragment> children = new ArrayList<>();
private StyleSet style;
private Fragment lastText;

View File

@ -71,8 +71,8 @@ public class CommandUsageBox extends StyledFragment {
CommandListBox box = new CommandListBox("Subcommands");
String prefix = !commandString.isEmpty() ? commandString + " " : "";
List<CommandMapping> list = new ArrayList<CommandMapping>(dispatcher.getCommands());
Collections.sort(list, new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
List<CommandMapping> list = new ArrayList<>(dispatcher.getCommands());
list.sort(new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
for (CommandMapping mapping : list) {
if (locals == null || mapping.getCallable().testPermission(locals)) {

View File

@ -55,8 +55,8 @@ public final class Closer implements Closeable {
final Suppressor suppressor;
// only need space for 2 elements in most cases, so try to use the smallest array possible
private final Deque<Closeable> stack = new ArrayDeque<Closeable>(4);
private final Deque<ZipFile> zipStack = new ArrayDeque<ZipFile>(4);
private final Deque<Closeable> stack = new ArrayDeque<>(4);
private final Deque<ZipFile> zipStack = new ArrayDeque<>(4);
private Throwable thrown;
@VisibleForTesting Closer(Suppressor suppressor) {

View File

@ -22,7 +22,6 @@ package com.sk89q.worldedit.util.logging;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import java.util.logging.Level;
import java.io.PrintWriter;
import java.io.StringWriter;