IntellIJ optimizations

This commit is contained in:
beaness 2022-06-24 12:39:14 +02:00
parent b8bddfd9b3
commit cb9fadbb9f
669 changed files with 5331 additions and 6877 deletions

View File

@ -30,21 +30,21 @@ public interface Timing extends AutoCloseable {
/**
* Starts timing the execution until {@link #stopTiming()} is called.
*/
public void startTiming();
void startTiming();
/**
* <p>Stops timing and records the data. Propagates the data up to group handlers.</p>
*
* Will automatically be called when this Timing is used with try-with-resources
*/
public void stopTiming();
void stopTiming();
/**
* Starts timing the execution until {@link #stopTiming()} is called.
*
* But only if we are on the primary thread.
*/
public void startTimingIfSync();
void startTimingIfSync();
/**
* <p>Stops timing and records the data. Propagates the data up to group handlers.</p>
@ -53,12 +53,12 @@ public interface Timing extends AutoCloseable {
*
* But only if we are on the primary thread.
*/
public void stopTimingIfSync();
void stopTimingIfSync();
/**
* Stops timing and disregards current timing data.
*/
public void abort();
void abort();
/**
* Used internally to get the actual backing Handler in the case of delegated Handlers

View File

@ -35,12 +35,7 @@ import static co.aikar.util.JSONUtil.toArray;
* This is broken out to reduce memory usage
*/
class TimingData {
static Function<Integer, TimingData> LOADER = new Function<Integer, TimingData>() {
@Override
public TimingData apply(Integer input) {
return new TimingData(input);
}
};
static Function<Integer, TimingData> LOADER = TimingData::new;
int id;
int count = 0;
int lagCount = 0;

View File

@ -26,10 +26,7 @@ package co.aikar.timings;
import gnu.trove.map.hash.TIntObjectHashMap;
import org.bukkit.Bukkit;
import co.aikar.util.LoadingIntMap;
import co.aikar.util.LoadingMap;
import co.aikar.util.MRUMapCache;
import java.util.Map;
import java.util.logging.Level;
class TimingHandler implements Timing {
@ -40,7 +37,7 @@ class TimingHandler implements Timing {
final String name;
final boolean verbose;
final TIntObjectHashMap<TimingData> children = new LoadingIntMap<TimingData>(TimingData.LOADER);
final TIntObjectHashMap<TimingData> children = new LoadingIntMap<>(TimingData.LOADER);
final TimingData record;
final TimingHandler groupHandler;

View File

@ -56,12 +56,7 @@ public class TimingHistory {
public static long tileEntityTicks;
public static long activatedEntityTicks;
static int worldIdPool = 1;
static Map<String, Integer> worldMap = LoadingMap.newHashMap(new Function<String, Integer>() {
@Override
public Integer apply(String input) {
return worldIdPool++;
}
});
static Map<String, Integer> worldMap = LoadingMap.newHashMap(input -> worldIdPool++);
final long endTime;
final long startTime;
final long totalTicks;
@ -80,7 +75,7 @@ public class TimingHistory {
this.minuteReports = MINUTE_REPORTS.toArray(new MinuteReport[MINUTE_REPORTS.size() + 1]);
this.minuteReports[this.minuteReports.length - 1] = new MinuteReport();
} else {
this.minuteReports = MINUTE_REPORTS.toArray(new MinuteReport[MINUTE_REPORTS.size()]);
this.minuteReports = MINUTE_REPORTS.toArray(new MinuteReport[0]);
}
long ticks = 0;
for (MinuteReport mp : this.minuteReports) {
@ -102,14 +97,9 @@ public class TimingHistory {
new EnumMap<Material, Counter>(Material.class), Counter.LOADER
));
// Information about all loaded chunks/entities
this.worlds = toObjectMapper(Bukkit.getWorlds(), new Function<World, JSONPair>() {
@Override
public JSONPair apply(World world) {
return pair(
this.worlds = toObjectMapper(Bukkit.getWorlds(), world -> pair(
worldMap.get(world.getName()),
toArrayMapper(world.getLoadedChunks(), new Function<Chunk, Object>() {
@Override
public Object apply(Chunk chunk) {
toArrayMapper(world.getLoadedChunks(), chunk -> {
entityCounts.clear();
tileEntityCounts.clear();
@ -128,35 +118,26 @@ public class TimingHistory {
chunk.getX(),
chunk.getZ(),
toObjectMapper(entityCounts.entrySet(),
new Function<Map.Entry<EntityType, Counter>, JSONPair>() {
@Override
public JSONPair apply(Map.Entry<EntityType, Counter> entry) {
entry -> {
entityTypeSet.add(entry.getKey());
return pair(
String.valueOf(entry.getKey().getTypeId()),
entry.getValue().count()
);
}
}
),
toObjectMapper(tileEntityCounts.entrySet(),
new Function<Map.Entry<Material, Counter>, JSONPair>() {
@Override
public JSONPair apply(Map.Entry<Material, Counter> entry) {
entry -> {
tileEntityTypeSet.add(entry.getKey());
return pair(
String.valueOf(entry.getKey().getId()),
entry.getValue().count()
);
}
}
)
);
}
})
);
}
});
));
}
public static void resetTicks(boolean fullReset) {
@ -178,22 +159,14 @@ public class TimingHistory {
pair("tk", totalTicks),
pair("tm", totalTime),
pair("w", worlds),
pair("h", toArrayMapper(entries, new Function<TimingHistoryEntry, Object>() {
@Override
public Object apply(TimingHistoryEntry entry) {
pair("h", toArrayMapper(entries, entry -> {
TimingData record = entry.data;
if (record.count == 0) {
return null;
}
return entry.export();
}
})),
pair("mp", toArrayMapper(minuteReports, new Function<MinuteReport, Object>() {
@Override
public Object apply(MinuteReport input) {
return input.export();
}
}))
pair("mp", toArrayMapper(minuteReports, input -> input.export()))
);
}
@ -235,7 +208,7 @@ public class TimingHistory {
final long activatedEntity;
TicksRecord() {
timed = timedTicks - (TimingsManager.MINUTE_REPORTS.size() * 1200);
timed = timedTicks - (TimingsManager.MINUTE_REPORTS.size() * 1200L);
player = playerTicks;
entity = entityTicks;
tileEntity = tileEntityTicks;

View File

@ -46,12 +46,7 @@ class TimingHistoryEntry {
List result = data.export();
if (children.length > 0) {
result.add(
toArrayMapper(children, new Function<TimingData, Object>() {
@Override
public Object apply(TimingData child) {
return child.export();
}
})
toArrayMapper(children, TimingData::export)
);
}
return result;

View File

@ -40,12 +40,7 @@ final class TimingIdentifier {
* Holds all groups. Autoloads on request for a group by name.
*/
static final Map<String, TimingGroup> GROUP_MAP = MRUMapCache.of(
LoadingMap.newIdentityHashMap(new Function<String, TimingGroup>() {
@Override
public TimingGroup apply(String group) {
return new TimingGroup(group);
}
}, 64)
LoadingMap.newIdentityHashMap(TimingGroup::new, 64)
);
static final TimingGroup DEFAULT_GROUP = getGroup("Minecraft");
final String group;
@ -93,7 +88,7 @@ final class TimingIdentifier {
final int id = idPool++;
final String name;
ArrayDeque<TimingHandler> handlers = new ArrayDeque<TimingHandler>(64);
ArrayDeque<TimingHandler> handlers = new ArrayDeque<>(64);
private TimingGroup(String name) {
this.name = name;

View File

@ -103,7 +103,7 @@ public class TimingsCommand extends BukkitCommand {
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], TIMINGS_SUBCOMMANDS,
new ArrayList<String>(TIMINGS_SUBCOMMANDS.size()));
new ArrayList<>(TIMINGS_SUBCOMMANDS.size()));
}
return ImmutableList.of();
}

View File

@ -45,11 +45,11 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -110,12 +110,7 @@ class TimingsExport extends Thread {
pair("cpu", runtime.availableProcessors()),
pair("runtime", ManagementFactory.getRuntimeMXBean().getUptime()),
pair("flags", StringUtils.join(runtimeBean.getInputArguments(), " ")),
pair("gc", toObjectMapper(ManagementFactory.getGarbageCollectorMXBeans(), new Function<GarbageCollectorMXBean, JSONPair>() {
@Override
public JSONPair apply(GarbageCollectorMXBean input) {
return pair(input.getName(), toArray(input.getCollectionCount(), input.getCollectionTime()));
}
}))
pair("gc", toObjectMapper(ManagementFactory.getGarbageCollectorMXBeans(), input -> pair(input.getName(), toArray(input.getCollectionCount(), input.getCollectionTime()))))
)
);
@ -151,49 +146,24 @@ class TimingsExport extends Thread {
parent.put("idmap", createObject(
pair("groups", toObjectMapper(
TimingIdentifier.GROUP_MAP.values(), new Function<TimingIdentifier.TimingGroup, JSONPair>() {
@Override
public JSONPair apply(TimingIdentifier.TimingGroup group) {
return pair(group.id, group.name);
}
})),
TimingIdentifier.GROUP_MAP.values(), group -> pair(group.id, group.name))),
pair("handlers", handlers),
pair("worlds", toObjectMapper(TimingHistory.worldMap.entrySet(), new Function<Map.Entry<String, Integer>, JSONPair>() {
@Override
public JSONPair apply(Map.Entry<String, Integer> input) {
return pair(input.getValue(), input.getKey());
}
})),
pair("worlds", toObjectMapper(TimingHistory.worldMap.entrySet(), input -> pair(input.getValue(), input.getKey()))),
pair("tileentity",
toObjectMapper(tileEntityTypeSet, new Function<Material, JSONPair>() {
@Override
public JSONPair apply(Material input) {
return pair(input.getId(), input.name());
}
})),
toObjectMapper(tileEntityTypeSet, input -> pair(input.getId(), input.name()))),
pair("entity",
toObjectMapper(entityTypeSet, new Function<EntityType, JSONPair>() {
@Override
public JSONPair apply(EntityType input) {
return pair(input.getTypeId(), input.name());
}
}))
toObjectMapper(entityTypeSet, input -> pair(input.getTypeId(), input.name())))
));
// Information about loaded plugins
parent.put("plugins", toObjectMapper(Bukkit.getPluginManager().getPlugins(),
new Function<Plugin, JSONPair>() {
@Override
public JSONPair apply(Plugin plugin) {
return pair(plugin.getName(), createObject(
plugin -> pair(plugin.getName(), createObject(
pair("version", plugin.getDescription().getVersion()),
pair("description", String.valueOf(plugin.getDescription().getDescription()).trim()),
pair("website", plugin.getDescription().getWebsite()),
pair("authors", StringUtils.join(plugin.getDescription().getAuthors(), ", "))
));
}
}));
))));
@ -262,12 +232,7 @@ class TimingsExport extends Thread {
if (!(val instanceof MemorySection)) {
if (val instanceof List) {
Iterable<Object> v = (Iterable<Object>) val;
return toArrayMapper(v, new Function<Object, Object>() {
@Override
public Object apply(Object input) {
return valAsJSON(input, parentKey);
}
});
return toArrayMapper(v, input -> valAsJSON(input, parentKey));
} else {
return val.toString();
}
@ -294,12 +259,7 @@ class TimingsExport extends Thread {
sender.sendMessage(ChatColor.GREEN + "Preparing Timings Report...");
out.put("data", toArrayMapper(history, new Function<TimingHistory, Object>() {
@Override
public Object apply(TimingHistory input) {
return input.export();
}
}));
out.put("data", toArrayMapper(history, input -> input.export()));
String response = null;
@ -314,7 +274,7 @@ class TimingsExport extends Thread {
this.def.setLevel(7);
}};
request.write(JSONValue.toJSONString(out).getBytes("UTF-8"));
request.write(JSONValue.toJSONString(out).getBytes(StandardCharsets.UTF_8));
request.close();
response = getResponse(con);
@ -348,9 +308,7 @@ class TimingsExport extends Thread {
}
private String getResponse(HttpURLConnection con) throws IOException {
InputStream is = null;
try {
is = con.getInputStream();
try (InputStream is = con.getInputStream()) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[1024];
@ -364,10 +322,6 @@ class TimingsExport extends Thread {
sender.sendMessage(ChatColor.RED + "Error uploading timings, check your logs for more information");
Bukkit.getLogger().log(Level.WARNING, con.getResponseMessage(), ex);
return null;
} finally {
if (is != null) {
is.close();
}
}
}
}

View File

@ -43,25 +43,20 @@ import java.util.logging.Level;
public final class TimingsManager {
static final Map<TimingIdentifier, TimingHandler> TIMING_MAP =
Collections.synchronizedMap(LoadingMap.newHashMap(
new Function<TimingIdentifier, TimingHandler>() {
@Override
public TimingHandler apply(TimingIdentifier id) {
return (id.protect ?
id -> (id.protect ?
new UnsafeTimingHandler(id) :
new TimingHandler(id)
);
}
},
),
256, .5F
));
public static final FullServerTickHandler FULL_SERVER_TICK = new FullServerTickHandler();
public static final TimingHandler TIMINGS_TICK = Timings.ofSafe("Timings Tick", FULL_SERVER_TICK);
public static final Timing PLUGIN_GROUP_HANDLER = Timings.ofSafe("Plugins");
public static List<String> hiddenConfigs = new ArrayList<String>();
public static List<String> hiddenConfigs = new ArrayList<>();
public static boolean privacy = false;
static final Collection<TimingHandler> HANDLERS = new ArrayDeque<TimingHandler>();
static final ArrayDeque<TimingHistory.MinuteReport> MINUTE_REPORTS = new ArrayDeque<TimingHistory.MinuteReport>();
static final Collection<TimingHandler> HANDLERS = new ArrayDeque<>();
static final ArrayDeque<TimingHistory.MinuteReport> MINUTE_REPORTS = new ArrayDeque<>();
static EvictingQueue<TimingHistory> HISTORY = EvictingQueue.create(12);
static TimingHandler CURRENT;

View File

@ -3,10 +3,7 @@ package co.aikar.util;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

View File

@ -25,14 +25,10 @@ package co.aikar.util;
import com.google.common.base.Function;
import org.bukkit.Material;
import co.aikar.timings.TimingHistory;
import org.w3c.dom.css.Counter;
import java.lang.reflect.Constructor;
import java.util.AbstractMap;
import java.util.Collection;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
@ -76,7 +72,7 @@ public class LoadingMap <K,V> extends AbstractMap<K, V> {
* @return
*/
public static <K, V> Map<K, V> of(Map<K, V> backingMap, Function<K, V> loader) {
return new LoadingMap<K, V>(backingMap, loader);
return new LoadingMap<>(backingMap, loader);
}
/**
@ -96,7 +92,7 @@ public class LoadingMap <K,V> extends AbstractMap<K, V> {
*/
public static <K, V> Map<K, V> newAutoMap(Map<K, V> backingMap, final Class<? extends K> keyClass,
final Class<? extends V> valueClass) {
return new LoadingMap<K, V>(backingMap, new AutoInstantiatingLoader<K, V>(keyClass, valueClass));
return new LoadingMap<>(backingMap, new AutoInstantiatingLoader<>(keyClass, valueClass));
}
/**
* Creates a LoadingMap with an auto instantiating loader.
@ -128,7 +124,7 @@ public class LoadingMap <K,V> extends AbstractMap<K, V> {
* @return
*/
public static <K, V> Map<K, V> newHashAutoMap(final Class<? extends K> keyClass, final Class<? extends V> valueClass) {
return newAutoMap(new HashMap<K, V>(), keyClass, valueClass);
return newAutoMap(new HashMap<>(), keyClass, valueClass);
}
/**
@ -158,7 +154,7 @@ public class LoadingMap <K,V> extends AbstractMap<K, V> {
* @return
*/
public static <K, V> Map<K, V> newHashAutoMap(final Class<? extends K> keyClass, final Class<? extends V> valueClass, int initialCapacity, float loadFactor) {
return newAutoMap(new HashMap<K, V>(initialCapacity, loadFactor), keyClass, valueClass);
return newAutoMap(new HashMap<>(initialCapacity, loadFactor), keyClass, valueClass);
}
/**
@ -185,7 +181,7 @@ public class LoadingMap <K,V> extends AbstractMap<K, V> {
* @return
*/
public static <K, V> Map<K, V> newHashMap(Function<K, V> loader) {
return new LoadingMap<K, V>(new HashMap<K, V>(), loader);
return new LoadingMap<>(new HashMap<>(), loader);
}
/**
@ -198,7 +194,7 @@ public class LoadingMap <K,V> extends AbstractMap<K, V> {
* @return
*/
public static <K, V> Map<K, V> newHashMap(Function<K, V> loader, int initialCapacity, float loadFactor) {
return new LoadingMap<K, V>(new HashMap<K, V>(initialCapacity, loadFactor), loader);
return new LoadingMap<>(new HashMap<>(initialCapacity, loadFactor), loader);
}
/**
@ -209,7 +205,7 @@ public class LoadingMap <K,V> extends AbstractMap<K, V> {
* @return
*/
public static <K, V> Map<K, V> newIdentityHashMap(Function<K, V> loader) {
return new LoadingMap<K, V>(new IdentityHashMap<K, V>(), loader);
return new LoadingMap<>(new IdentityHashMap<>(), loader);
}
/**
@ -221,7 +217,7 @@ public class LoadingMap <K,V> extends AbstractMap<K, V> {
* @return
*/
public static <K, V> Map<K, V> newIdentityHashMap(Function<K, V> loader, int initialCapacity) {
return new LoadingMap<K, V>(new IdentityHashMap<K, V>(initialCapacity), loader);
return new LoadingMap<>(new IdentityHashMap<>(initialCapacity), loader);
}
@Override
@ -276,7 +272,7 @@ public class LoadingMap <K,V> extends AbstractMap<K, V> {
}
public LoadingMap<K, V> clone() {
return new LoadingMap<K, V>(backingMap, loader);
return new LoadingMap<>(backingMap, loader);
}
private static class AutoInstantiatingLoader<K, V> implements Function<K, V> {

View File

@ -95,6 +95,6 @@ public class MRUMapCache<K, V> extends AbstractMap<K, V> {
* @return
*/
public static <K, V> Map<K, V> of(Map<K, V> map) {
return new MRUMapCache<K, V>(map);
return new MRUMapCache<>(map);
}
}

View File

@ -1,7 +1,5 @@
package net.techcable.tacospigot.event.entity;
import com.google.common.base.Preconditions;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.event.Cancellable;

View File

@ -47,14 +47,14 @@ public interface BanEntry {
*
* @return the target name or IP address
*/
public String getTarget();
String getTarget();
/**
* Gets the date this ban entry was created.
*
* @return the creation date
*/
public Date getCreated();
Date getCreated();
/**
* Sets the date this ban entry was created.
@ -62,7 +62,7 @@ public interface BanEntry {
* @param created the new created date, cannot be null
* @see #save() saving changes
*/
public void setCreated(Date created);
void setCreated(Date created);
/**
* Gets the source of this ban.
@ -72,7 +72,7 @@ public interface BanEntry {
*
* @return the source of the ban
*/
public String getSource();
String getSource();
/**
* Sets the source of this ban.
@ -83,14 +83,14 @@ public interface BanEntry {
* @param source the new source where null values become empty strings
* @see #save() saving changes
*/
public void setSource(String source);
void setSource(String source);
/**
* Gets the date this ban expires on, or null for no defined end date.
*
* @return the expiration date
*/
public Date getExpiration();
Date getExpiration();
/**
* Sets the date this ban expires on. Null values are considered
@ -100,14 +100,14 @@ public interface BanEntry {
* eternity
* @see #save() saving changes
*/
public void setExpiration(Date expiration);
void setExpiration(Date expiration);
/**
* Gets the reason for this ban.
*
* @return the ban reason, or null if not set
*/
public String getReason();
String getReason();
/**
* Sets the reason for this ban. Reasons must not be null.
@ -116,7 +116,7 @@ public interface BanEntry {
* default
* @see #save() saving changes
*/
public void setReason(String reason);
void setReason(String reason);
/**
* Saves the ban entry, overwriting any previous data in the ban list.
@ -124,5 +124,5 @@ public interface BanEntry {
* Saving the ban entry of an unbanned player will cause the player to be
* banned once again.
*/
public void save();
void save();
}

View File

@ -11,7 +11,7 @@ public interface BanList {
/**
* Represents a ban-type that a {@link BanList} may track.
*/
public enum Type {
enum Type {
/**
* Banned player names
*/
@ -20,7 +20,6 @@ public interface BanList {
* Banned player IP addresses
*/
IP,
;
}
/**
@ -29,7 +28,7 @@ public interface BanList {
* @param target entry parameter to search for
* @return the corresponding entry, or null if none found
*/
public BanEntry getBanEntry(String target);
BanEntry getBanEntry(String target);
/**
* Adds a ban to the this list. If a previous ban exists, this will
@ -43,14 +42,14 @@ public interface BanList {
* @return the entry for the newly created ban, or the entry for the
* (updated) previous ban
*/
public BanEntry addBan(String target, String reason, Date expires, String source);
BanEntry addBan(String target, String reason, Date expires, String source);
/**
* Gets a set containing every {@link BanEntry} in this list.
*
* @return an immutable set containing every entry tracked by this list
*/
public Set<BanEntry> getBanEntries();
Set<BanEntry> getBanEntries();
/**
* Gets if a {@link BanEntry} exists for the target, indicating an active
@ -60,7 +59,7 @@ public interface BanList {
* @return true if a {@link BanEntry} exists for the name, indicating an
* active ban status, false otherwise
*/
public boolean isBanned(String target);
boolean isBanned(String target);
/**
* Removes the specified target from this list, therefore indicating a
@ -68,5 +67,5 @@ public interface BanList {
*
* @param target the target to remove from this list
*/
public void pardon(String target);
void pardon(String target);
}

View File

@ -22,7 +22,7 @@ public interface BlockChangeDelegate {
* @deprecated Magic value
*/
@Deprecated
public boolean setRawTypeId(int x, int y, int z, int typeId);
boolean setRawTypeId(int x, int y, int z, int typeId);
/**
* Set a block type and data at the specified coordinates without doing
@ -40,7 +40,7 @@ public interface BlockChangeDelegate {
* @deprecated Magic value
*/
@Deprecated
public boolean setRawTypeIdAndData(int x, int y, int z, int typeId, int data);
boolean setRawTypeIdAndData(int x, int y, int z, int typeId, int data);
/**
* Set a block type at the specified coordinates.
@ -55,7 +55,7 @@ public interface BlockChangeDelegate {
* @deprecated Magic value
*/
@Deprecated
public boolean setTypeId(int x, int y, int z, int typeId);
boolean setTypeId(int x, int y, int z, int typeId);
/**
* Set a block type and data at the specified coordinates.
@ -71,7 +71,7 @@ public interface BlockChangeDelegate {
* @deprecated Magic value
*/
@Deprecated
public boolean setTypeIdAndData(int x, int y, int z, int typeId, int data);
boolean setTypeIdAndData(int x, int y, int z, int typeId, int data);
/**
* Get the block type at the location.
@ -83,14 +83,14 @@ public interface BlockChangeDelegate {
* @deprecated Magic value
*/
@Deprecated
public int getTypeId(int x, int y, int z);
int getTypeId(int x, int y, int z);
/**
* Gets the height of the world.
*
* @return Height of the world
*/
public int getHeight();
int getHeight();
/**
* Checks if the specified block is empty (air) or not.
@ -100,5 +100,5 @@ public interface BlockChangeDelegate {
* @param z Z coordinate
* @return True if the block is considered empty.
*/
public boolean isEmpty(int x, int y, int z);
boolean isEmpty(int x, int y, int z);
}

View File

@ -215,7 +215,7 @@ public enum ChatColor{
* you need to dynamically convert colour codes from your custom format.
*/
public static final char COLOR_CHAR = '\u00A7';
private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf(COLOR_CHAR) + "[0-9A-FK-OR]");
private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + COLOR_CHAR + "[0-9A-FK-OR]");
private final int intCode;
private final char code;
@ -237,7 +237,7 @@ public enum ChatColor{
public net.md_5.bungee.api.ChatColor asBungee() {
return net.md_5.bungee.api.ChatColor.RESET;
};
}
/**
* Gets the char value associated with this color
@ -349,7 +349,7 @@ public enum ChatColor{
ChatColor color = getByChar(c);
if (color != null) {
result = color.toString() + result;
result = color + result;
// Once we find a color or reset we can stop searching
if (color.isColor() || color.equals(RESET)) {

View File

@ -143,7 +143,7 @@ public final class Color implements ConfigurationSerializable {
*/
public static Color fromRGB(int rgb) throws IllegalArgumentException {
Validate.isTrue((rgb >> 24) == 0, "Extrenuous data in: ", rgb);
return fromRGB(rgb >> 16 & BIT_MASK, rgb >> 8 & BIT_MASK, rgb >> 0 & BIT_MASK);
return fromRGB(rgb >> 16 & BIT_MASK, rgb >> 8 & BIT_MASK, rgb & BIT_MASK);
}
/**
@ -157,7 +157,7 @@ public final class Color implements ConfigurationSerializable {
*/
public static Color fromBGR(int bgr) throws IllegalArgumentException {
Validate.isTrue((bgr >> 24) == 0, "Extrenuous data in: ", bgr);
return fromBGR(bgr >> 16 & BIT_MASK, bgr >> 8 & BIT_MASK, bgr >> 0 & BIT_MASK);
return fromBGR(bgr >> 16 & BIT_MASK, bgr >> 8 & BIT_MASK, bgr & BIT_MASK);
}
private Color(int red, int green, int blue) {
@ -232,7 +232,7 @@ public final class Color implements ConfigurationSerializable {
* @return An integer representation of this color, as 0xRRGGBB
*/
public int asRGB() {
return getRed() << 16 | getGreen() << 8 | getBlue() << 0;
return getRed() << 16 | getGreen() << 8 | getBlue();
}
/**
@ -240,7 +240,7 @@ public final class Color implements ConfigurationSerializable {
* @return An integer representation of this color, as 0xBBGGRR
*/
public int asBGR() {
return getBlue() << 16 | getGreen() << 8 | getRed() << 0;
return getBlue() << 16 | getGreen() << 8 | getRed();
}
/**

View File

@ -40,7 +40,6 @@ public final class FireworkEffect implements ConfigurationSerializable {
* A creeper-face effect.
*/
CREEPER,
;
}
/**

View File

@ -2,11 +2,11 @@ package org.bukkit;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.bukkit.block.Block;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.util.NumberConversions;
import static org.bukkit.util.NumberConversions.checkFinite;
import org.bukkit.util.Vector;
/**
@ -497,7 +497,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
}
final Location other = (Location) obj;
if (this.world != other.world && (this.world == null || !this.world.equals(other.world))) {
if (!Objects.equals(this.world, other.world)) {
return false;
}
if (Double.doubleToLongBits(this.x) != Double.doubleToLongBits(other.x)) {
@ -568,7 +568,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
@Utility
public Map<String, Object> serialize() {
Map<String, Object> data = new HashMap<String, Object>();
Map<String, Object> data = new HashMap<>();
data.put("world", this.world.getName());
data.put("x", this.x);

View File

@ -491,9 +491,7 @@ public enum Material {
// try to cache the constructor for this material
try {
this.ctor = data.getConstructor(int.class, byte.class);
} catch (NoSuchMethodException ex) {
throw new AssertionError(ex);
} catch (SecurityException ex) {
} catch (NoSuchMethodException | SecurityException ex) {
throw new AssertionError(ex);
}
}
@ -659,7 +657,7 @@ public enum Material {
try {
result = getMaterial(Integer.parseInt(name));
} catch (NumberFormatException ex) {}
} catch (NumberFormatException ignored) {}
if (result == null) {
String filtered = name.toUpperCase();

View File

@ -17,5 +17,5 @@ public enum NetherWartsState {
/**
* Ready to harvest
*/
RIPE;
RIPE
}

View File

@ -15,7 +15,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
*
* @return true if they are online
*/
public boolean isOnline();
boolean isOnline();
/**
* Returns the name of this player
@ -25,21 +25,21 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
*
* @return Player name or null if we have not seen a name for this player yet
*/
public String getName();
String getName();
/**
* Returns the UUID of this player
*
* @return Player UUID
*/
public UUID getUniqueId();
UUID getUniqueId();
/**
* Checks if this player is banned or not
*
* @return true if banned, otherwise false
*/
public boolean isBanned();
boolean isBanned();
/**
* Bans or unbans this player
@ -50,21 +50,21 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
* functionality
*/
@Deprecated
public void setBanned(boolean banned);
void setBanned(boolean banned);
/**
* Checks if this player is whitelisted or not
*
* @return true if whitelisted
*/
public boolean isWhitelisted();
boolean isWhitelisted();
/**
* Sets if this player is whitelisted or not
*
* @param value true if whitelisted
*/
public void setWhitelisted(boolean value);
void setWhitelisted(boolean value);
/**
* Gets a {@link Player} object that this represents, if there is one
@ -74,7 +74,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
*
* @return Online player
*/
public Player getPlayer();
Player getPlayer();
/**
* Gets the first date and time that this player was witnessed on this
@ -86,7 +86,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
*
* @return Date of first log-in for this player, or 0
*/
public long getFirstPlayed();
long getFirstPlayed();
/**
* Gets the last date and time that this player was witnessed on this
@ -98,14 +98,14 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
*
* @return Date of last log-in for this player, or 0
*/
public long getLastPlayed();
long getLastPlayed();
/**
* Checks if this player has played on this server before.
*
* @return True if the player has played before, otherwise false
*/
public boolean hasPlayedBefore();
boolean hasPlayedBefore();
/**
* Gets the Location where the player will spawn at their bed, null if
@ -113,6 +113,6 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
*
* @return Bed Spawn Location if bed exists, otherwise null.
*/
public Location getBedSpawnLocation();
Location getBedSpawnLocation();
}

View File

@ -18,5 +18,5 @@ public enum PortalType {
/**
* This is a custom Plugin portal.
*/
CUSTOM;
CUSTOM
}

View File

@ -55,7 +55,7 @@ public interface Server extends PluginMessageRecipient {
* <p>
* For use in {@link #broadcast(java.lang.String, java.lang.String)}.
*/
public static final String BROADCAST_CHANNEL_ADMINISTRATIVE = "bukkit.broadcast.admin";
String BROADCAST_CHANNEL_ADMINISTRATIVE = "bukkit.broadcast.admin";
/**
* Used for all announcement messages, such as informing users that a
@ -63,28 +63,28 @@ public interface Server extends PluginMessageRecipient {
* <p>
* For use in {@link #broadcast(java.lang.String, java.lang.String)}.
*/
public static final String BROADCAST_CHANNEL_USERS = "bukkit.broadcast.user";
String BROADCAST_CHANNEL_USERS = "bukkit.broadcast.user";
/**
* Gets the name of this server implementation.
*
* @return name of this server implementation
*/
public String getName();
String getName();
/**
* Gets the version string of this server implementation.
*
* @return version of this server implementation
*/
public String getVersion();
String getVersion();
/**
* Gets the Bukkit version that this server is running.
*
* @return version of Bukkit
*/
public String getBukkitVersion();
String getBukkitVersion();
/**
* Gets an array copy of all currently logged in players.
@ -97,7 +97,7 @@ public interface Server extends PluginMessageRecipient {
* @return an array of Players that are currently online
*/
@Deprecated
public Player[] _INVALID_getOnlinePlayers();
Player[] _INVALID_getOnlinePlayers();
/**
* Gets a view of all currently logged in players. This {@linkplain
@ -126,28 +126,28 @@ public interface Server extends PluginMessageRecipient {
*
* @return a view of currently online players.
*/
public Collection<? extends Player> getOnlinePlayers();
Collection<? extends Player> getOnlinePlayers();
/**
* Get the maximum amount of players which can login to this server.
*
* @return the amount of players this server allows
*/
public int getMaxPlayers();
int getMaxPlayers();
/**
* Get the game port that the server runs on.
*
* @return the port number of this server
*/
public int getPort();
int getPort();
/**
* Get the view distance from this server.
*
* @return the view distance from this server.
*/
public int getViewDistance();
int getViewDistance();
/**
* Get the IP that this server is bound to, or empty string if not
@ -156,14 +156,14 @@ public interface Server extends PluginMessageRecipient {
* @return the IP string that this server is bound to, otherwise empty
* string
*/
public String getIp();
String getIp();
/**
* Get the name of this server.
*
* @return the name of this server
*/
public String getServerName();
String getServerName();
/**
* Get an ID of this server. The ID is a simple generally alphanumeric ID
@ -171,61 +171,61 @@ public interface Server extends PluginMessageRecipient {
*
* @return the ID of this server
*/
public String getServerId();
String getServerId();
/**
* Get world type (level-type setting) for default world.
*
* @return the value of level-type (e.g. DEFAULT, FLAT, DEFAULT_1_1)
*/
public String getWorldType();
String getWorldType();
/**
* Get generate-structures setting.
*
* @return true if structure generation is enabled, false otherwise
*/
public boolean getGenerateStructures();
boolean getGenerateStructures();
/**
* Gets whether this server allows the End or not.
*
* @return whether this server allows the End or not
*/
public boolean getAllowEnd();
boolean getAllowEnd();
/**
* Gets whether this server allows the Nether or not.
*
* @return whether this server allows the Nether or not
*/
public boolean getAllowNether();
boolean getAllowNether();
/**
* Gets whether this server has a whitelist or not.
*
* @return whether this server has a whitelist or not
*/
public boolean hasWhitelist();
boolean hasWhitelist();
/**
* Sets if the server is whitelisted.
*
* @param value true for whitelist on, false for off
*/
public void setWhitelist(boolean value);
void setWhitelist(boolean value);
/**
* Gets a list of whitelisted players.
*
* @return a set containing all whitelisted players
*/
public Set<OfflinePlayer> getWhitelistedPlayers();
Set<OfflinePlayer> getWhitelistedPlayers();
/**
* Reloads the whitelist from disk.
*/
public void reloadWhitelist();
void reloadWhitelist();
/**
* Broadcast a message to all players.
@ -236,7 +236,7 @@ public interface Server extends PluginMessageRecipient {
* @param message the message
* @return the number of players
*/
public int broadcastMessage(String message);
int broadcastMessage(String message);
// Paper start
/**
@ -244,14 +244,14 @@ public interface Server extends PluginMessageRecipient {
*
* @param component the components to send
*/
public void broadcast(net.md_5.bungee.api.chat.BaseComponent component);
void broadcast(net.md_5.bungee.api.chat.BaseComponent component);
/**
* Sends an array of components as a single message to the player
*
* @param components the components to send
*/
public void broadcast(net.md_5.bungee.api.chat.BaseComponent... components);
void broadcast(net.md_5.bungee.api.chat.BaseComponent... components);
// Paper end
/**
@ -262,7 +262,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return the name of the update folder
*/
public String getUpdateFolder();
String getUpdateFolder();
/**
* Gets the update folder. The update folder is used to safely update
@ -270,14 +270,14 @@ public interface Server extends PluginMessageRecipient {
*
* @return the update folder
*/
public File getUpdateFolderFile();
File getUpdateFolderFile();
/**
* Gets the value of the connection throttle setting.
*
* @return the value of the connection throttle setting
*/
public long getConnectionThrottle();
long getConnectionThrottle();
/**
* Gets default ticks per animal spawns value.
@ -298,7 +298,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return the default ticks per animal spawns value
*/
public int getTicksPerAnimalSpawns();
int getTicksPerAnimalSpawns();
/**
* Gets the default ticks per monster spawns value.
@ -319,7 +319,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return the default ticks per monsters spawn value
*/
public int getTicksPerMonsterSpawns();
int getTicksPerMonsterSpawns();
/**
* Gets a player object by the given username.
@ -329,7 +329,7 @@ public interface Server extends PluginMessageRecipient {
* @param name the name to look up
* @return a player if one was found, null otherwise
*/
public Player getPlayer(String name);
Player getPlayer(String name);
/**
* Gets the player with the exact given name, case insensitive.
@ -337,7 +337,7 @@ public interface Server extends PluginMessageRecipient {
* @param name Exact name of the player to retrieve
* @return a player object if one was found, null otherwise
*/
public Player getPlayerExact(String name);
Player getPlayerExact(String name);
/**
* Attempts to match any players with the given name, and returns a list
@ -349,7 +349,7 @@ public interface Server extends PluginMessageRecipient {
* @param name the (partial) name to match
* @return list of all possible players
*/
public List<Player> matchPlayer(String name);
List<Player> matchPlayer(String name);
/**
* Gets the player with the given UUID.
@ -357,35 +357,35 @@ public interface Server extends PluginMessageRecipient {
* @param id UUID of the player to retrieve
* @return a player object if one was found, null otherwise
*/
public Player getPlayer(UUID id);
Player getPlayer(UUID id);
/**
* Gets the plugin manager for interfacing with plugins.
*
* @return a plugin manager for this Server instance
*/
public PluginManager getPluginManager();
PluginManager getPluginManager();
/**
* Gets the scheduler for managing scheduled events.
*
* @return a scheduling service for this server
*/
public BukkitScheduler getScheduler();
BukkitScheduler getScheduler();
/**
* Gets a services manager.
*
* @return s services manager
*/
public ServicesManager getServicesManager();
ServicesManager getServicesManager();
/**
* Gets a list of all worlds on this server.
*
* @return a list of worlds
*/
public List<World> getWorlds();
List<World> getWorlds();
/**
* Creates or loads a world with the given name using the specified
@ -397,7 +397,7 @@ public interface Server extends PluginMessageRecipient {
* @param creator the options to use when creating the world
* @return newly created or loaded world
*/
public World createWorld(WorldCreator creator);
World createWorld(WorldCreator creator);
/**
* Unloads a world with the given name.
@ -406,7 +406,7 @@ public interface Server extends PluginMessageRecipient {
* @param save whether to save the chunks before unloading
* @return true if successful, false otherwise
*/
public boolean unloadWorld(String name, boolean save);
boolean unloadWorld(String name, boolean save);
/**
* Unloads the given world.
@ -415,7 +415,7 @@ public interface Server extends PluginMessageRecipient {
* @param save whether to save the chunks before unloading
* @return true if successful, false otherwise
*/
public boolean unloadWorld(World world, boolean save);
boolean unloadWorld(World world, boolean save);
/**
* Gets the world with the given name.
@ -423,7 +423,7 @@ public interface Server extends PluginMessageRecipient {
* @param name the name of the world to retrieve
* @return a world with the given name, or null if none exists
*/
public World getWorld(String name);
World getWorld(String name);
/**
* Gets the world from the given Unique ID.
@ -431,7 +431,7 @@ public interface Server extends PluginMessageRecipient {
* @param uid a unique-id of the world to retrieve
* @return a world with the given Unique ID, or null if none exists
*/
public World getWorld(UUID uid);
World getWorld(UUID uid);
/**
* Gets the map from the given item ID.
@ -441,7 +441,7 @@ public interface Server extends PluginMessageRecipient {
* @deprecated Magic value
*/
@Deprecated
public MapView getMap(short id);
MapView getMap(short id);
/**
* Create a new map with an automatically assigned ID.
@ -449,19 +449,19 @@ public interface Server extends PluginMessageRecipient {
* @param world the world the map will belong to
* @return a newly created map view
*/
public MapView createMap(World world);
MapView createMap(World world);
/**
* Reloads the server, refreshing settings and plugin information.
*/
public void reload();
void reload();
/**
* Returns the primary logger associated with this server instance.
*
* @return Logger associated with this server
*/
public Logger getLogger();
Logger getLogger();
/**
* Gets a {@link PluginCommand} with the given name or alias.
@ -469,12 +469,12 @@ public interface Server extends PluginMessageRecipient {
* @param name the name of the command to retrieve
* @return a plugin command if found, null otherwise
*/
public PluginCommand getPluginCommand(String name);
PluginCommand getPluginCommand(String name);
/**
* Writes loaded players to disk.
*/
public void savePlayers();
void savePlayers();
/**
* Dispatches a command on this server, and executes it if found.
@ -486,7 +486,7 @@ public interface Server extends PluginMessageRecipient {
* @throws CommandException thrown when the executor for the given command
* fails with an unhandled exception
*/
public boolean dispatchCommand(CommandSender sender, String commandLine) throws CommandException;
boolean dispatchCommand(CommandSender sender, String commandLine) throws CommandException;
/**
* Populates a given {@link ServerConfig} with values attributes to this
@ -494,7 +494,7 @@ public interface Server extends PluginMessageRecipient {
*
* @param config the server config to populate
*/
public void configureDbConfig(ServerConfig config);
void configureDbConfig(ServerConfig config);
/**
* Adds a recipe to the crafting manager.
@ -503,7 +503,7 @@ public interface Server extends PluginMessageRecipient {
* @return true if the recipe was added, false if it wasn't for some
* reason
*/
public boolean addRecipe(Recipe recipe);
boolean addRecipe(Recipe recipe);
/**
* Get a list of all recipes for a given item. The stack size is ignored
@ -512,66 +512,66 @@ public interface Server extends PluginMessageRecipient {
* @param result the item to match against recipe results
* @return a list of recipes with the given result
*/
public List<Recipe> getRecipesFor(ItemStack result);
List<Recipe> getRecipesFor(ItemStack result);
/**
* Get an iterator through the list of crafting recipes.
*
* @return an iterator
*/
public Iterator<Recipe> recipeIterator();
Iterator<Recipe> recipeIterator();
/**
* Clears the list of crafting recipes.
*/
public void clearRecipes();
void clearRecipes();
/**
* Resets the list of crafting recipes to the default.
*/
public void resetRecipes();
void resetRecipes();
/**
* Gets a list of command aliases defined in the server properties.
*
* @return a map of aliases to command names
*/
public Map<String, String[]> getCommandAliases();
Map<String, String[]> getCommandAliases();
/**
* Gets the radius, in blocks, around each worlds spawn point to protect.
*
* @return spawn radius, or 0 if none
*/
public int getSpawnRadius();
int getSpawnRadius();
/**
* Sets the radius, in blocks, around each worlds spawn point to protect.
*
* @param value new spawn radius, or 0 if none
*/
public void setSpawnRadius(int value);
void setSpawnRadius(int value);
/**
* Gets whether the Server is in online mode or not.
*
* @return true if the server authenticates clients, false otherwise
*/
public boolean getOnlineMode();
boolean getOnlineMode();
/**
* Gets whether this server allows flying or not.
*
* @return true if the server allows flight, false otherwise
*/
public boolean getAllowFlight();
boolean getAllowFlight();
/**
* Gets whether the server is in hardcore mode or not.
*
* @return true if the server mode is hardcore, false otherwise
*/
public boolean isHardcore();
boolean isHardcore();
/**
* Gets whether to use vanilla (false) or exact behaviour (true).
@ -588,12 +588,12 @@ public interface Server extends PluginMessageRecipient {
* @deprecated non standard and unused feature.
*/
@Deprecated
public boolean useExactLoginLocation();
boolean useExactLoginLocation();
/**
* Shutdowns the server, stopping everything.
*/
public void shutdown();
void shutdown();
/**
* Broadcasts the specified message to every user with the given
@ -604,7 +604,7 @@ public interface Server extends PluginMessageRecipient {
* permissibles} must have to receive the broadcast
* @return number of message recipients
*/
public int broadcast(String message, String permission);
int broadcast(String message, String permission);
/**
* Gets the player by the given name, regardless if they are offline or
@ -623,7 +623,7 @@ public interface Server extends PluginMessageRecipient {
* @see #getOfflinePlayer(java.util.UUID)
*/
@Deprecated
public OfflinePlayer getOfflinePlayer(String name);
OfflinePlayer getOfflinePlayer(String name);
/**
* Gets the player by the given UUID, regardless if they are offline or
@ -635,35 +635,35 @@ public interface Server extends PluginMessageRecipient {
* @param id the UUID of the player to retrieve
* @return an offline player
*/
public OfflinePlayer getOfflinePlayer(UUID id);
OfflinePlayer getOfflinePlayer(UUID id);
/**
* Gets a set containing all current IPs that are banned.
*
* @return a set containing banned IP addresses
*/
public Set<String> getIPBans();
Set<String> getIPBans();
/**
* Bans the specified address from the server.
*
* @param address the IP address to ban
*/
public void banIP(String address);
void banIP(String address);
/**
* Unbans the specified address from the server.
*
* @param address the IP address to unban
*/
public void unbanIP(String address);
void unbanIP(String address);
/**
* Gets a set containing all banned players.
*
* @return a set containing banned players
*/
public Set<OfflinePlayer> getBannedPlayers();
Set<OfflinePlayer> getBannedPlayers();
/**
* Gets a ban list for the supplied type.
@ -674,28 +674,28 @@ public interface Server extends PluginMessageRecipient {
* @param type the type of list to fetch, cannot be null
* @return a ban list of the specified type
*/
public BanList getBanList(BanList.Type type);
BanList getBanList(BanList.Type type);
/**
* Gets a set containing all player operators.
*
* @return a set containing player operators
*/
public Set<OfflinePlayer> getOperators();
Set<OfflinePlayer> getOperators();
/**
* Gets the default {@link GameMode} for new players.
*
* @return the default game mode
*/
public GameMode getDefaultGameMode();
GameMode getDefaultGameMode();
/**
* Sets the default {@link GameMode} for new players.
*
* @param mode the new game mode
*/
public void setDefaultGameMode(GameMode mode);
void setDefaultGameMode(GameMode mode);
/**
* Gets a {@link ConsoleCommandSender} that may be used as an input source
@ -703,35 +703,35 @@ public interface Server extends PluginMessageRecipient {
*
* @return a console command sender
*/
public ConsoleCommandSender getConsoleSender();
ConsoleCommandSender getConsoleSender();
/**
* Gets the folder that contains all of the various {@link World}s.
*
* @return folder that contains all worlds
*/
public File getWorldContainer();
File getWorldContainer();
/**
* Gets every player that has ever played on this server.
*
* @return an array containing all previous players
*/
public OfflinePlayer[] getOfflinePlayers();
OfflinePlayer[] getOfflinePlayers();
/**
* Gets the {@link Messenger} responsible for this server.
*
* @return messenger responsible for this server
*/
public Messenger getMessenger();
Messenger getMessenger();
/**
* Gets the {@link HelpMap} providing help topics for this server.
*
* @return a help map for this server
*/
public HelpMap getHelpMap();
HelpMap getHelpMap();
/**
* Creates an empty inventory of the specified type. If the type is {@link
@ -847,7 +847,7 @@ public interface Server extends PluginMessageRecipient {
*
* @return the configured warning state
*/
public WarningState getWarningState();
WarningState getWarningState();
/**
* Gets the instance of the item factory (for {@link ItemMeta}).
@ -914,14 +914,14 @@ public interface Server extends PluginMessageRecipient {
*
* @param threshold the idle timeout in minutes
*/
public void setIdleTimeout(int threshold);
void setIdleTimeout(int threshold);
/**
* Gets the idle kick timeout.
*
* @return the idle timeout in minutes
*/
public int getIdleTimeout();
int getIdleTimeout();
/**
* Create a ChunkData for use in a generator.
@ -932,7 +932,7 @@ public interface Server extends PluginMessageRecipient {
* @return a new ChunkData for the world
*
*/
public ChunkGenerator.ChunkData createChunkData(World world);
ChunkGenerator.ChunkData createChunkData(World world);
/**
* @see UnsafeValues
@ -950,7 +950,7 @@ public interface Server extends PluginMessageRecipient {
CommandMap getCommandMap();
// Paper end
public class Spigot
class Spigot
{
@Deprecated
public org.bukkit.configuration.file.YamlConfiguration getConfig()

View File

@ -8,5 +8,5 @@ public enum SkullType {
WITHER,
ZOMBIE,
PLAYER,
CREEPER;
CREEPER
}

View File

@ -128,6 +128,6 @@ public enum Statistic {
/**
* Statistics of this type require an EntityType qualifier.
*/
ENTITY;
ENTITY
}
}

View File

@ -17,14 +17,14 @@ public interface TravelAgent {
* location
* @return this travel agent
*/
public TravelAgent setSearchRadius(int radius);
TravelAgent setSearchRadius(int radius);
/**
* Gets the search radius value for finding an available portal.
*
* @return the currently set search radius
*/
public int getSearchRadius();
int getSearchRadius();
/**
* Sets the maximum radius from the given location to create a portal.
@ -32,14 +32,14 @@ public interface TravelAgent {
* @param radius the radius in which to create a portal from the location
* @return this travel agent
*/
public TravelAgent setCreationRadius(int radius);
TravelAgent setCreationRadius(int radius);
/**
* Gets the maximum radius from the given location to create a portal.
*
* @return the currently set creation radius
*/
public int getCreationRadius();
int getCreationRadius();
/**
* Returns whether the TravelAgent will attempt to create a destination
@ -48,7 +48,7 @@ public interface TravelAgent {
* @return whether the TravelAgent should create a destination portal or
* not
*/
public boolean getCanCreatePortal();
boolean getCanCreatePortal();
/**
* Sets whether the TravelAgent should attempt to create a destination
@ -57,7 +57,7 @@ public interface TravelAgent {
* @param create Sets whether the TravelAgent should create a destination
* portal or not
*/
public void setCanCreatePortal(boolean create);
void setCanCreatePortal(boolean create);
/**
* Attempt to find a portal near the given location, if a portal is not
@ -68,7 +68,7 @@ public interface TravelAgent {
* location passed to the method if unsuccessful
* @see #createPortal(Location)
*/
public Location findOrCreate(Location location);
Location findOrCreate(Location location);
/**
* Attempt to find a portal near the given location.
@ -76,7 +76,7 @@ public interface TravelAgent {
* @param location the desired location of the portal
* @return the location of the nearest portal to the location
*/
public Location findPortal(Location location);
Location findPortal(Location location);
/**
* Attempt to create a portal near the given location.
@ -90,5 +90,5 @@ public interface TravelAgent {
* @param location the desired location of the portal
* @return true if a portal was successfully created
*/
public boolean createPortal(Location location);
boolean createPortal(Location location);
}

View File

@ -21,7 +21,7 @@ public @interface Warning {
/**
* This represents the states that server verbose for warnings may be.
*/
public enum WarningState {
enum WarningState {
/**
* Indicates all warnings should be printed for deprecated items.

View File

@ -13,5 +13,4 @@ public enum WeatherType {
* Clear weather, clouds but no rain.
*/
CLEAR,
;
}

View File

@ -32,7 +32,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @see #getBlockTypeIdAt(int, int, int) Returns the current type ID of
* the block
*/
public Block getBlockAt(int x, int y, int z);
Block getBlockAt(int x, int y, int z);
/**
* Gets the {@link Block} at the given {@link Location}
@ -42,7 +42,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @see #getBlockTypeIdAt(org.bukkit.Location) Returns the current type ID
* of the block
*/
public Block getBlockAt(Location location);
Block getBlockAt(Location location);
/**
* Gets the block type ID at the given coordinates
@ -56,7 +56,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @deprecated Magic value
*/
@Deprecated
public int getBlockTypeIdAt(int x, int y, int z);
int getBlockTypeIdAt(int x, int y, int z);
/**
* Gets the block type ID at the given {@link Location}
@ -68,7 +68,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @deprecated Magic value
*/
@Deprecated
public int getBlockTypeIdAt(Location location);
int getBlockTypeIdAt(Location location);
/**
* Gets the highest non-air coordinate at the given coordinates
@ -77,7 +77,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z-coordinate of the blocks
* @return Y-coordinate of the highest non-air block
*/
public int getHighestBlockYAt(int x, int z);
int getHighestBlockYAt(int x, int z);
/**
* Gets the highest non-air coordinate at the given {@link Location}
@ -85,7 +85,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param location Location of the blocks
* @return Y-coordinate of the highest non-air block
*/
public int getHighestBlockYAt(Location location);
int getHighestBlockYAt(Location location);
/**
* Gets the highest non-empty block at the given coordinates
@ -94,7 +94,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z-coordinate of the block
* @return Highest non-empty block
*/
public Block getHighestBlockAt(int x, int z);
Block getHighestBlockAt(int x, int z);
/**
* Gets the highest non-empty block at the given coordinates
@ -102,7 +102,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param location Coordinates to get the highest block
* @return Highest non-empty block
*/
public Block getHighestBlockAt(Location location);
Block getHighestBlockAt(Location location);
/**
* Gets the {@link Chunk} at the given coordinates
@ -111,7 +111,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z-coordinate of the chunk
* @return Chunk at the given coordinates
*/
public Chunk getChunkAt(int x, int z);
Chunk getChunkAt(int x, int z);
/**
* Gets the {@link Chunk} at the given {@link Location}
@ -119,7 +119,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param location Location of the chunk
* @return Chunk at the given location
*/
public Chunk getChunkAt(Location location);
Chunk getChunkAt(Location location);
/**
* Gets the {@link Chunk} that contains the given {@link Block}
@ -127,15 +127,15 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param block Block to get the containing chunk from
* @return The chunk that contains the given block
*/
public Chunk getChunkAt(Block block);
Chunk getChunkAt(Block block);
// PaperSpigot start - Async chunk load API
public static interface ChunkLoadCallback {
public void onLoad(Chunk chunk);
interface ChunkLoadCallback {
void onLoad(Chunk chunk);
}
public void getChunkAtAsync(int x, int z, ChunkLoadCallback cb);
public void getChunkAtAsync(Location location, ChunkLoadCallback cb);
public void getChunkAtAsync(Block block, ChunkLoadCallback cb);
void getChunkAtAsync(int x, int z, ChunkLoadCallback cb);
void getChunkAtAsync(Location location, ChunkLoadCallback cb);
void getChunkAtAsync(Block block, ChunkLoadCallback cb);
// PaperSpigot end
/**
@ -144,21 +144,21 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param chunk The chunk to check
* @return true if the chunk is loaded, otherwise false
*/
public boolean isChunkLoaded(Chunk chunk);
boolean isChunkLoaded(Chunk chunk);
/**
* Gets an array of all loaded {@link Chunk}s
*
* @return Chunk[] containing all loaded chunks
*/
public Chunk[] getLoadedChunks();
Chunk[] getLoadedChunks();
/**
* Loads the specified {@link Chunk}
*
* @param chunk The chunk to load
*/
public void loadChunk(Chunk chunk);
void loadChunk(Chunk chunk);
/**
* Checks if the {@link Chunk} at the specified coordinates is loaded
@ -167,7 +167,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z-coordinate of the chunk
* @return true if the chunk is loaded, otherwise false
*/
public boolean isChunkLoaded(int x, int z);
boolean isChunkLoaded(int x, int z);
/**
* Checks if the {@link Chunk} at the specified coordinates is loaded and
@ -178,7 +178,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return true if the chunk is loaded and in use by one or more players,
* otherwise false
*/
public boolean isChunkInUse(int x, int z);
boolean isChunkInUse(int x, int z);
/**
* Loads the {@link Chunk} at the specified coordinates
@ -191,7 +191,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
*/
public void loadChunk(int x, int z);
void loadChunk(int x, int z);
/**
* Loads the {@link Chunk} at the specified coordinates
@ -202,7 +202,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* already exist
* @return true if the chunk has loaded successfully, otherwise false
*/
public boolean loadChunk(int x, int z, boolean generate);
boolean loadChunk(int x, int z, boolean generate);
/**
* Safely unloads and saves the {@link Chunk} at the specified coordinates
@ -213,7 +213,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param chunk the chunk to unload
* @return true if the chunk has unloaded successfully, otherwise false
*/
public boolean unloadChunk(Chunk chunk);
boolean unloadChunk(Chunk chunk);
/**
* Safely unloads and saves the {@link Chunk} at the specified coordinates
@ -225,7 +225,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z-coordinate of the chunk
* @return true if the chunk has unloaded successfully, otherwise false
*/
public boolean unloadChunk(int x, int z);
boolean unloadChunk(int x, int z);
/**
* Safely unloads and optionally saves the {@link Chunk} at the specified
@ -239,7 +239,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param save Whether or not to save the chunk
* @return true if the chunk has unloaded successfully, otherwise false
*/
public boolean unloadChunk(int x, int z, boolean save);
boolean unloadChunk(int x, int z, boolean save);
/**
* Unloads and optionally saves the {@link Chunk} at the specified
@ -252,7 +252,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* nearby
* @return true if the chunk has unloaded successfully, otherwise false
*/
public boolean unloadChunk(int x, int z, boolean save, boolean safe);
boolean unloadChunk(int x, int z, boolean save, boolean safe);
/**
* Safely queues the {@link Chunk} at the specified coordinates for
@ -265,7 +265,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z-coordinate of the chunk
* @return true is the queue attempt was successful, otherwise false
*/
public boolean unloadChunkRequest(int x, int z);
boolean unloadChunkRequest(int x, int z);
/**
* Queues the {@link Chunk} at the specified coordinates for unloading
@ -275,7 +275,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param safe Controls whether to queue the chunk when players are nearby
* @return Whether the chunk was actually queued
*/
public boolean unloadChunkRequest(int x, int z, boolean safe);
boolean unloadChunkRequest(int x, int z, boolean safe);
/**
* Regenerates the {@link Chunk} at the specified coordinates
@ -284,7 +284,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z-coordinate of the chunk
* @return Whether the chunk was actually regenerated
*/
public boolean regenerateChunk(int x, int z);
boolean regenerateChunk(int x, int z);
/**
* Resends the {@link Chunk} to all clients
@ -296,7 +296,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @deprecated This method is not guaranteed to work suitably across all client implementations.
*/
@Deprecated
public boolean refreshChunk(int x, int z);
boolean refreshChunk(int x, int z);
/**
* Drops an item at the specified {@link Location}
@ -305,7 +305,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param item ItemStack to drop
* @return ItemDrop entity created as a result of this method
*/
public Item dropItem(Location location, ItemStack item);
Item dropItem(Location location, ItemStack item);
/**
* Drops an item at the specified {@link Location} with a random offset
@ -314,7 +314,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param item ItemStack to drop
* @return ItemDrop entity created as a result of this method
*/
public Item dropItemNaturally(Location location, ItemStack item);
Item dropItemNaturally(Location location, ItemStack item);
/**
* Creates an {@link Arrow} entity at the given {@link Location}
@ -325,7 +325,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param spread Spread of the arrow. A recommend spread is 12
* @return Arrow entity spawned as a result of this method
*/
public Arrow spawnArrow(Location location, Vector direction, float speed, float spread);
Arrow spawnArrow(Location location, Vector direction, float speed, float spread);
/**
* Creates a tree at the given {@link Location}
@ -334,7 +334,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param type Type of the tree to create
* @return true if the tree was created successfully, otherwise false
*/
public boolean generateTree(Location location, TreeType type);
boolean generateTree(Location location, TreeType type);
/**
* Creates a tree at the given {@link Location}
@ -345,7 +345,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* this method
* @return true if the tree was created successfully, otherwise false
*/
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate);
boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate);
/**
* Creates a entity at the given {@link Location}
@ -354,7 +354,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param type The entity to spawn
* @return Resulting Entity of this method, or null if it was unsuccessful
*/
public Entity spawnEntity(Location loc, EntityType type);
Entity spawnEntity(Location loc, EntityType type);
/**
* Creates a creature at the given {@link Location}
@ -367,7 +367,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* #spawnEntity(Location, EntityType) spawnEntity} instead.
*/
@Deprecated
public LivingEntity spawnCreature(Location loc, EntityType type);
LivingEntity spawnCreature(Location loc, EntityType type);
/**
* Creates a creature at the given {@link Location}
@ -378,7 +378,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* unsuccessful
*/
@Deprecated
public LivingEntity spawnCreature(Location loc, CreatureType type);
LivingEntity spawnCreature(Location loc, CreatureType type);
/**
* Strikes lightning at the given {@link Location}
@ -386,7 +386,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param loc The location to strike lightning
* @return The lightning entity.
*/
public LightningStrike strikeLightning(Location loc);
LightningStrike strikeLightning(Location loc);
/**
* Strikes lightning at the given {@link Location} without doing damage
@ -394,21 +394,21 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param loc The location to strike lightning
* @return The lightning entity.
*/
public LightningStrike strikeLightningEffect(Location loc);
LightningStrike strikeLightningEffect(Location loc);
/**
* Get a list of all entities in this World
*
* @return A List of all Entities currently residing in this world
*/
public List<Entity> getEntities();
List<Entity> getEntities();
/**
* Get a list of all living entities in this World
*
* @return A List of all LivingEntities currently residing in this world
*/
public List<LivingEntity> getLivingEntities();
List<LivingEntity> getLivingEntities();
/**
* Get a collection of all entities in this World matching the given
@ -420,7 +420,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* match the given class/interface
*/
@Deprecated
public <T extends Entity> Collection<T> getEntitiesByClass(Class<T>... classes);
<T extends Entity> Collection<T> getEntitiesByClass(Class<T>... classes);
/**
* Get a collection of all entities in this World matching the given
@ -431,7 +431,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return A List of all Entities currently residing in this world that
* match the given class/interface
*/
public <T extends Entity> Collection<T> getEntitiesByClass(Class<T> cls);
<T extends Entity> Collection<T> getEntitiesByClass(Class<T> cls);
/**
* Get a collection of all entities in this World matching any of the
@ -441,14 +441,14 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return A List of all Entities currently residing in this world that
* match one or more of the given classes/interfaces
*/
public Collection<Entity> getEntitiesByClasses(Class<?>... classes);
Collection<Entity> getEntitiesByClasses(Class<?>... classes);
/**
* Get a list of all players in this World
*
* @return A list of all Players currently residing in this world
*/
public List<Player> getPlayers();
List<Player> getPlayers();
/**
* Returns a list of entities within a bounding box centered around a Location.
@ -461,28 +461,28 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z 1/2 the size of the box along z axis
* @return the collection of entities near location. This will always be a non-null collection.
*/
public Collection<Entity> getNearbyEntities(Location location, double x, double y, double z);
Collection<Entity> getNearbyEntities(Location location, double x, double y, double z);
/**
* Gets the unique name of this world
*
* @return Name of this world
*/
public String getName();
String getName();
/**
* Gets the Unique ID of this world
*
* @return Unique ID of this world.
*/
public UUID getUID();
UUID getUID();
/**
* Gets the default spawn {@link Location} of this world
*
* @return The spawn location of this world
*/
public Location getSpawnLocation();
Location getSpawnLocation();
/**
* Sets the spawn location of the world
@ -492,7 +492,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z coordinate
* @return True if it was successfully set.
*/
public boolean setSpawnLocation(int x, int y, int z);
boolean setSpawnLocation(int x, int y, int z);
/**
* Sets the spawn location of the world
@ -502,14 +502,14 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z coordinate
* @return True if it was successfully set.
*/
public boolean setSpawnLocation(double x, double y, double z, float yaw, float pitch);
boolean setSpawnLocation(double x, double y, double z, float yaw, float pitch);
/**
* Sets the spawn location of the world
*
* @param location Location of the spawn
* @return True if it was successfully set.
*/
public boolean setSpawnLocation(Location location);
boolean setSpawnLocation(Location location);
/**
* Gets the relative in-game time of this world.
@ -519,7 +519,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return The current relative time
* @see #getFullTime() Returns an absolute time of this world
*/
public long getTime();
long getTime();
/**
* Sets the relative in-game time on the server.
@ -534,7 +534,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* hours*1000)
* @see #setFullTime(long) Sets the absolute time of this world
*/
public void setTime(long time);
void setTime(long time);
/**
* Gets the full in-game time on this world
@ -542,7 +542,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return The current absolute time
* @see #getTime() Returns a relative time of this world
*/
public long getFullTime();
long getFullTime();
/**
* Sets the in-game time on the server
@ -553,14 +553,14 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param time The new absolute time to set this world to
* @see #setTime(long) Sets the relative time of this world
*/
public void setFullTime(long time);
void setFullTime(long time);
/**
* Returns whether the world has an ongoing storm.
*
* @return Whether there is an ongoing storm
*/
public boolean hasStorm();
boolean hasStorm();
/**
* Set whether there is a storm. A duration will be set for the new
@ -568,49 +568,49 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @param hasStorm Whether there is rain and snow
*/
public void setStorm(boolean hasStorm);
void setStorm(boolean hasStorm);
/**
* Get the remaining time in ticks of the current conditions.
*
* @return Time in ticks
*/
public int getWeatherDuration();
int getWeatherDuration();
/**
* Set the remaining time in ticks of the current conditions.
*
* @param duration Time in ticks
*/
public void setWeatherDuration(int duration);
void setWeatherDuration(int duration);
/**
* Returns whether there is thunder.
*
* @return Whether there is thunder
*/
public boolean isThundering();
boolean isThundering();
/**
* Set whether it is thundering.
*
* @param thundering Whether it is thundering
*/
public void setThundering(boolean thundering);
void setThundering(boolean thundering);
/**
* Get the thundering duration.
*
* @return Duration in ticks
*/
public int getThunderDuration();
int getThunderDuration();
/**
* Set the thundering duration.
*
* @param duration Duration in ticks
*/
public void setThunderDuration(int duration);
void setThunderDuration(int duration);
/**
* Creates explosion at given coordinates with given power
@ -621,7 +621,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param power The power of explosion, where 4F is TNT
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(double x, double y, double z, float power);
boolean createExplosion(double x, double y, double z, float power);
/**
* Creates explosion at given coordinates with given power and optionally
@ -634,7 +634,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param setFire Whether or not to set blocks on fire
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(double x, double y, double z, float power, boolean setFire);
boolean createExplosion(double x, double y, double z, float power, boolean setFire);
/**
* Creates explosion at given coordinates with given power and optionally
@ -648,7 +648,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param breakBlocks Whether or not to have blocks be destroyed
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks);
boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks);
/**
* Creates explosion at given coordinates with given power
@ -657,7 +657,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param power The power of explosion, where 4F is TNT
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(Location loc, float power);
boolean createExplosion(Location loc, float power);
/**
* Creates explosion at given coordinates with given power and optionally
@ -668,54 +668,54 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param setFire Whether or not to set blocks on fire
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(Location loc, float power, boolean setFire);
boolean createExplosion(Location loc, float power, boolean setFire);
/**
* Gets the {@link Environment} type of this world
*
* @return This worlds Environment type
*/
public Environment getEnvironment();
Environment getEnvironment();
/**
* Gets the Seed for this world.
*
* @return This worlds Seed
*/
public long getSeed();
long getSeed();
/**
* Gets the current PVP setting for this world.
*
* @return True if PVP is enabled
*/
public boolean getPVP();
boolean getPVP();
/**
* Sets the PVP setting for this world.
*
* @param pvp True/False whether PVP should be Enabled.
*/
public void setPVP(boolean pvp);
void setPVP(boolean pvp);
/**
* Gets the chunk generator for this world
*
* @return ChunkGenerator associated with this world
*/
public ChunkGenerator getGenerator();
ChunkGenerator getGenerator();
/**
* Saves world to disk
*/
public void save();
void save();
/**
* Gets a list of all applied {@link BlockPopulator}s for this World
*
* @return List containing any or none BlockPopulators
*/
public List<BlockPopulator> getPopulators();
List<BlockPopulator> getPopulators();
/**
* Spawn an entity of a specific class at the given {@link Location}
@ -727,7 +727,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @throws IllegalArgumentException if either parameter is null or the
* {@link Entity} requested cannot be spawned
*/
public <T extends Entity> T spawn(Location location, Class<T> clazz) throws IllegalArgumentException;
<T extends Entity> T spawn(Location location, Class<T> clazz) throws IllegalArgumentException;
/**
* Spawn a {@link FallingBlock} entity at the given {@link Location} of
@ -746,7 +746,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @deprecated Magic value
*/
@Deprecated
public FallingBlock spawnFallingBlock(Location location, Material material, byte data) throws IllegalArgumentException;
FallingBlock spawnFallingBlock(Location location, Material material, byte data) throws IllegalArgumentException;
/**
* Spawn a {@link FallingBlock} entity at the given {@link Location} of
@ -762,7 +762,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @deprecated Magic value
*/
@Deprecated
public FallingBlock spawnFallingBlock(Location location, int blockId, byte blockData) throws IllegalArgumentException;
FallingBlock spawnFallingBlock(Location location, int blockId, byte blockData) throws IllegalArgumentException;
/**
* Plays an effect to all players within a default radius around a given
@ -773,7 +773,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param effect the {@link Effect}
* @param data a data bit needed for some effects
*/
public void playEffect(Location location, Effect effect, int data);
void playEffect(Location location, Effect effect, int data);
/**
* Plays an effect to all players within a given radius around a location.
@ -784,7 +784,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param data a data bit needed for some effects
* @param radius the radius around the location
*/
public void playEffect(Location location, Effect effect, int data, int radius);
void playEffect(Location location, Effect effect, int data, int radius);
/**
* Plays an effect to all players within a default radius around a given
@ -796,7 +796,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param effect the {@link Effect}
* @param data a data bit needed for some effects
*/
public <T> void playEffect(Location location, Effect effect, T data);
<T> void playEffect(Location location, Effect effect, T data);
/**
* Plays an effect to all players within a given radius around a location.
@ -808,7 +808,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param data a data bit needed for some effects
* @param radius the radius around the location
*/
public <T> void playEffect(Location location, Effect effect, T data, int radius);
<T> void playEffect(Location location, Effect effect, T data, int radius);
/**
* Get empty chunk snapshot (equivalent to all air blocks), optionally
@ -823,7 +823,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* raw biome temperature and rainfall
* @return The empty snapshot.
*/
public ChunkSnapshot getEmptyChunkSnapshot(int x, int z, boolean includeBiome, boolean includeBiomeTempRain);
ChunkSnapshot getEmptyChunkSnapshot(int x, int z, boolean includeBiome, boolean includeBiomeTempRain);
/**
* Sets the spawn flags for this.
@ -833,21 +833,21 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param allowAnimals - if true, animals are allowed to spawn in this
* world.
*/
public void setSpawnFlags(boolean allowMonsters, boolean allowAnimals);
void setSpawnFlags(boolean allowMonsters, boolean allowAnimals);
/**
* Gets whether animals can spawn in this world.
*
* @return whether animals can spawn in this world.
*/
public boolean getAllowAnimals();
boolean getAllowAnimals();
/**
* Gets whether monsters can spawn in this world.
*
* @return whether monsters can spawn in this world.
*/
public boolean getAllowMonsters();
boolean getAllowMonsters();
/**
* Gets the biome for the given block coordinates.
@ -877,7 +877,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z coordinate of the block
* @return Temperature of the requested block
*/
public double getTemperature(int x, int z);
double getTemperature(int x, int z);
/**
* Gets the humidity for the given block coordinates.
@ -889,7 +889,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z coordinate of the block
* @return Humidity of the requested block
*/
public double getHumidity(int x, int z);
double getHumidity(int x, int z);
/**
* Gets the maximum height of this world.
@ -898,7 +898,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return Maximum height of the world
*/
public int getMaxHeight();
int getMaxHeight();
/**
* Gets the sea level for this world.
@ -907,7 +907,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return Sea level
*/
public int getSeaLevel();
int getSeaLevel();
/**
* Gets whether the world's spawn area should be kept loaded into memory
@ -915,7 +915,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return true if the world's spawn area will be kept loaded into memory.
*/
public boolean getKeepSpawnInMemory();
boolean getKeepSpawnInMemory();
/**
* Sets whether the world's spawn area should be kept loaded into memory
@ -924,14 +924,14 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param keepLoaded if true then the world's spawn area will be kept
* loaded into memory.
*/
public void setKeepSpawnInMemory(boolean keepLoaded);
void setKeepSpawnInMemory(boolean keepLoaded);
/**
* Gets whether or not the world will automatically save
*
* @return true if the world will automatically save, otherwise false
*/
public boolean isAutoSave();
boolean isAutoSave();
/**
* Sets whether or not the world will automatically save
@ -939,42 +939,42 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param value true if the world should automatically save, otherwise
* false
*/
public void setAutoSave(boolean value);
void setAutoSave(boolean value);
/**
* Sets the Difficulty of the world.
*
* @param difficulty the new difficulty you want to set the world to
*/
public void setDifficulty(Difficulty difficulty);
void setDifficulty(Difficulty difficulty);
/**
* Gets the Difficulty of the world.
*
* @return The difficulty of the world.
*/
public Difficulty getDifficulty();
Difficulty getDifficulty();
/**
* Gets the folder of this world on disk.
*
* @return The folder of this world.
*/
public File getWorldFolder();
File getWorldFolder();
/**
* Gets the type of this world.
*
* @return Type of this world.
*/
public WorldType getWorldType();
WorldType getWorldType();
/**
* Gets whether or not structures are being generated.
*
* @return True if structures are being generated.
*/
public boolean canGenerateStructures();
boolean canGenerateStructures();
/**
* Gets the world's ticks per animal spawns value
@ -1000,7 +1000,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return The world's ticks per animal spawns value
*/
public long getTicksPerAnimalSpawns();
long getTicksPerAnimalSpawns();
/**
* Sets the world's ticks per animal spawns value
@ -1027,7 +1027,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param ticksPerAnimalSpawns the ticks per animal spawns value you want
* to set the world to
*/
public void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns);
void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns);
/**
* Gets the world's ticks per monster spawns value
@ -1053,7 +1053,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return The world's ticks per monster spawns value
*/
public long getTicksPerMonsterSpawns();
long getTicksPerMonsterSpawns();
/**
* Sets the world's ticks per monster spawns value
@ -1080,7 +1080,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param ticksPerMonsterSpawns the ticks per monster spawns value you
* want to set the world to
*/
public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns);
void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns);
/**
* Gets limit for number of monsters that can spawn in a chunk in this
@ -1175,7 +1175,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return An array of rules
*/
public String[] getGameRules();
String[] getGameRules();
/**
* Gets the current state of the specified rule
@ -1185,7 +1185,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param rule Rule to look up value of
* @return String value of rule
*/
public String getGameRuleValue(String rule);
String getGameRuleValue(String rule);
/**
* Set the specified gamerule to specified value.
@ -1199,7 +1199,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param value Value to set rule to
* @return True if rule was set
*/
public boolean setGameRuleValue(String rule, String value);
boolean setGameRuleValue(String rule, String value);
/**
* Checks if string is a valid game rule
@ -1207,10 +1207,10 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param rule Rule to check
* @return True if rule exists
*/
public boolean isGameRule(String rule);
boolean isGameRule(String rule);
// Spigot start
public class Spigot
class Spigot
{
/**
@ -1288,12 +1288,12 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @return The world border for this world.
*/
public WorldBorder getWorldBorder();
WorldBorder getWorldBorder();
/**
* Represents various map environment types that a world may be
*/
public enum Environment {
enum Environment {
/**
* Represents the "normal"/"surface world" map
@ -1309,7 +1309,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
THE_END(1);
private final int id;
private static final Map<Integer, Environment> lookup = new HashMap<Integer, Environment>();
private static final Map<Integer, Environment> lookup = new HashMap<>();
private Environment(int id) {
this.id = id;

View File

@ -5,21 +5,21 @@ public interface WorldBorder {
/**
* Resets the border to default values.
*/
public void reset();
void reset();
/**
* Gets the current side length of the border.
*
* @return The current side length of the border.
*/
public double getSize();
double getSize();
/**
* Sets the border to a square region with the specified side length in blocks.
*
* @param newSize The new size of the border.
*/
public void setSize(double newSize);
void setSize(double newSize);
/**
* Sets the border to a square region with the specified side length in blocks.
@ -27,14 +27,14 @@ public interface WorldBorder {
* @param newSize The new side length of the border.
* @param seconds The time in seconds in which the border grows or shrinks from the previous size to that being set.
*/
public void setSize(double newSize, long seconds);
void setSize(double newSize, long seconds);
/**
* Gets the current border center.
*
* @return The current border center.
*/
public Location getCenter();
Location getCenter();
/**
* Sets the new border center.
@ -42,68 +42,68 @@ public interface WorldBorder {
* @param x The new center x-coordinate.
* @param z The new center z-coordinate.
*/
public void setCenter(double x, double z);
void setCenter(double x, double z);
/**
* Sets the new border center.
*
* @param location The new location of the border center. (Only x/z used)
*/
public void setCenter(Location location);
void setCenter(Location location);
/**
* Gets the current border damage buffer.
*
* @return The current border damage buffer.
*/
public double getDamageBuffer();
double getDamageBuffer();
/**
* Sets the amount of blocks a player may safely be outside the border before taking damage.
*
* @param blocks The amount of blocks. (The default is 5 blocks.)
*/
public void setDamageBuffer(double blocks);
void setDamageBuffer(double blocks);
/**
* Gets the current border damage amount.
*
* @return The current border damage amount.
*/
public double getDamageAmount();
double getDamageAmount();
/**
* Sets the amount of damage a player takes when outside the border plus the border buffer.
*
* @param damage The amount of damage. (The default is 0.2 damage per second per block.)
*/
public void setDamageAmount(double damage);
void setDamageAmount(double damage);
/**
* Gets the current border warning time in seconds.
*
* @return The current border warning time in seconds.
*/
public int getWarningTime();
int getWarningTime();
/**
* Sets the warning time that causes the screen to be tinted red when a contracting border will reach the player within the specified time.
*
* @param seconds The amount of time in seconds. (The default is 15 seconds.)
*/
public void setWarningTime(int seconds);
void setWarningTime(int seconds);
/**
* Gets the current border warning distance.
*
* @return The current border warning distance.
*/
public int getWarningDistance();
int getWarningDistance();
/**
* Sets the warning distance that causes the screen to be tinted red when the player is within the specified number of blocks from the border.
*
* @param distance The distance in blocks. (The default is 5 blocks.)
*/
public void setWarningDistance(int distance);
void setWarningDistance(int distance);
}

View File

@ -184,14 +184,14 @@ public interface BlockState extends Metadatable {
* @deprecated Magic value
*/
@Deprecated
public byte getRawData();
byte getRawData();
/**
* @param data The new data value for the block.
* @deprecated Magic value
*/
@Deprecated
public void setRawData(byte data);
void setRawData(byte data);
/**
* Returns whether this state is placed in the world.

View File

@ -21,5 +21,5 @@ public interface BrewingStand extends BlockState, ContainerBlock {
*/
void setBrewingTime(int brewTime);
public BrewerInventory getInventory();
BrewerInventory getInventory();
}

View File

@ -9,7 +9,7 @@ public interface CommandBlock extends BlockState {
*
* @return Command that this CommandBlock will run when powered.
*/
public String getCommand();
String getCommand();
/**
* Sets the command that this CommandBlock will run when powered.
@ -18,7 +18,7 @@ public interface CommandBlock extends BlockState {
*
* @param command Command that this CommandBlock will run when powered.
*/
public void setCommand(String command);
void setCommand(String command);
/**
* Gets the name of this CommandBlock. The name is used with commands
@ -27,7 +27,7 @@ public interface CommandBlock extends BlockState {
*
* @return Name of this CommandBlock.
*/
public String getName();
String getName();
/**
* Sets the name of this CommandBlock. The name is used with commands
@ -36,5 +36,5 @@ public interface CommandBlock extends BlockState {
*
* @param name New name for this CommandBlock.
*/
public void setName(String name);
void setName(String name);
}

View File

@ -15,21 +15,21 @@ public interface CreatureSpawner extends BlockState {
* @deprecated In favour of {@link #getSpawnedType()}.
*/
@Deprecated
public CreatureType getCreatureType();
CreatureType getCreatureType();
/**
* Get the spawner's creature type.
*
* @return The creature type.
*/
public EntityType getSpawnedType();
EntityType getSpawnedType();
/**
* Set the spawner's creature type.
*
* @param creatureType The creature type.
*/
public void setSpawnedType(EntityType creatureType);
void setSpawnedType(EntityType creatureType);
/**
* Set the spawner creature type.
@ -38,7 +38,7 @@ public interface CreatureSpawner extends BlockState {
* @deprecated In favour of {@link #setSpawnedType(EntityType)}.
*/
@Deprecated
public void setCreatureType(CreatureType creatureType);
void setCreatureType(CreatureType creatureType);
/**
* Get the spawner's creature type.
@ -47,21 +47,21 @@ public interface CreatureSpawner extends BlockState {
* @deprecated Use {@link #getCreatureTypeName()}.
*/
@Deprecated
public String getCreatureTypeId();
String getCreatureTypeId();
/**
* Set the spawner mob type.
*
* @param creatureType The creature type's name.
*/
public void setCreatureTypeByName(String creatureType);
void setCreatureTypeByName(String creatureType);
/**
* Get the spawner's creature type.
*
* @return The creature type's name.
*/
public String getCreatureTypeName();
String getCreatureTypeName();
/**
* Set the spawner mob type.
@ -70,19 +70,19 @@ public interface CreatureSpawner extends BlockState {
* @deprecated Use {@link #setCreatureTypeByName(String)}.
*/
@Deprecated
public void setCreatureTypeId(String creatureType);
void setCreatureTypeId(String creatureType);
/**
* Get the spawner's delay.
*
* @return The delay.
*/
public int getDelay();
int getDelay();
/**
* Set the spawner's delay.
*
* @param delay The delay.
*/
public void setDelay(int delay);
void setDelay(int delay);
}

View File

@ -14,7 +14,7 @@ public interface Dispenser extends BlockState, ContainerBlock {
*
* @return a BlockProjectileSource if valid, otherwise null
*/
public BlockProjectileSource getBlockProjectileSource();
BlockProjectileSource getBlockProjectileSource();
/**
* Attempts to dispense the contents of this block.
@ -23,5 +23,5 @@ public interface Dispenser extends BlockState, ContainerBlock {
*
* @return true if successful, otherwise false
*/
public boolean dispense();
boolean dispense();
}

View File

@ -21,5 +21,5 @@ public interface Dropper extends BlockState, InventoryHolder {
* ContainerBlock, the randomly selected ItemStack is dropped on
* the ground in the form of an {@link org.bukkit.entity.Item Item}.
*/
public void drop();
void drop();
}

View File

@ -12,28 +12,28 @@ public interface Furnace extends BlockState, ContainerBlock {
*
* @return Burn time
*/
public short getBurnTime();
short getBurnTime();
/**
* Set burn time.
*
* @param burnTime Burn time
*/
public void setBurnTime(short burnTime);
void setBurnTime(short burnTime);
/**
* Get cook time.
*
* @return Cook time
*/
public short getCookTime();
short getCookTime();
/**
* Set cook time.
*
* @param cookTime Cook time
*/
public void setCookTime(short cookTime);
void setCookTime(short cookTime);
public FurnaceInventory getInventory();
FurnaceInventory getInventory();
}

View File

@ -11,26 +11,26 @@ public interface Jukebox extends BlockState {
*
* @return The record Material, or AIR if none is playing
*/
public Material getPlaying();
Material getPlaying();
/**
* Set the record currently playing
*
* @param record The record Material, or null/AIR to stop playing
*/
public void setPlaying(Material record);
void setPlaying(Material record);
/**
* Check if the jukebox is currently playing a record
*
* @return True if there is a record playing
*/
public boolean isPlaying();
boolean isPlaying();
/**
* Stop the jukebox playing and eject the current record
*
* @return True if a record was ejected; false if there was none playing
*/
public boolean eject();
boolean eject();
}

View File

@ -13,7 +13,7 @@ public interface NoteBlock extends BlockState {
*
* @return The note.
*/
public Note getNote();
Note getNote();
/**
* Gets the note.
@ -22,14 +22,14 @@ public interface NoteBlock extends BlockState {
* @deprecated Magic value
*/
@Deprecated
public byte getRawNote();
byte getRawNote();
/**
* Set the note.
*
* @param note The note.
*/
public void setNote(Note note);
void setNote(Note note);
/**
* Set the note.
@ -38,7 +38,7 @@ public interface NoteBlock extends BlockState {
* @deprecated Magic value
*/
@Deprecated
public void setRawNote(byte note);
void setRawNote(byte note);
/**
* Attempts to play the note at block
@ -47,7 +47,7 @@ public interface NoteBlock extends BlockState {
*
* @return true if successful, otherwise false
*/
public boolean play();
boolean play();
/**
* Plays an arbitrary note with an arbitrary instrument
@ -58,7 +58,7 @@ public interface NoteBlock extends BlockState {
* @deprecated Magic value
*/
@Deprecated
public boolean play(byte instrument, byte note);
boolean play(byte instrument, byte note);
/**
* Plays an arbitrary note with an arbitrary instrument
@ -68,5 +68,5 @@ public interface NoteBlock extends BlockState {
* @return true if successful, otherwise false
* @see Instrument Note
*/
public boolean play(Instrument instrument, Note note);
boolean play(Instrument instrument, Note note);
}

View File

@ -19,7 +19,7 @@ public enum PistonMoveReaction {
BLOCK(2);
private int id;
private static Map<Integer, PistonMoveReaction> byId = new HashMap<Integer, PistonMoveReaction>();
private static Map<Integer, PistonMoveReaction> byId = new HashMap<>();
static {
for (PistonMoveReaction reaction : PistonMoveReaction.values()) {
byId.put(reaction.id, reaction);

View File

@ -10,7 +10,7 @@ public interface Sign extends BlockState {
*
* @return Array of Strings containing each line of text
*/
public String[] getLines();
String[] getLines();
/**
* Gets the line of text at the specified index.
@ -21,7 +21,7 @@ public interface Sign extends BlockState {
* @throws IndexOutOfBoundsException Thrown when the line does not exist
* @return Text on the given line
*/
public String getLine(int index) throws IndexOutOfBoundsException;
String getLine(int index) throws IndexOutOfBoundsException;
/**
* Sets the line of text at the specified index.
@ -33,5 +33,5 @@ public interface Sign extends BlockState {
* @param line New text to set at the specified index
* @throws IndexOutOfBoundsException If the index is out of the range 0..3
*/
public void setLine(int index, String line) throws IndexOutOfBoundsException;
void setLine(int index, String line) throws IndexOutOfBoundsException;
}

View File

@ -12,14 +12,14 @@ public interface Skull extends BlockState {
*
* @return true if the skull has an owner
*/
public boolean hasOwner();
boolean hasOwner();
/**
* Gets the owner of the skull, if one exists
*
* @return the owner of the skull or null if the skull does not have an owner
*/
public String getOwner();
String getOwner();
/**
* Sets the owner of the skull
@ -30,33 +30,33 @@ public interface Skull extends BlockState {
* @param name the new owner of the skull
* @return true if the owner was successfully set
*/
public boolean setOwner(String name);
boolean setOwner(String name);
/**
* Gets the rotation of the skull in the world
*
* @return the rotation of the skull
*/
public BlockFace getRotation();
BlockFace getRotation();
/**
* Sets the rotation of the skull in the world
*
* @param rotation the rotation of the skull
*/
public void setRotation(BlockFace rotation);
void setRotation(BlockFace rotation);
/**
* Gets the type of skull
*
* @return the type of skull
*/
public SkullType getSkullType();
SkullType getSkullType();
/**
* Sets the type of skull
*
* @param skullType the type of skull
*/
public void setSkullType(SkullType skullType);
void setSkullType(SkullType skullType);
}

View File

@ -45,7 +45,7 @@ public enum PatternType {
MOJANG("moj");
private final String identifier;
private static final Map<String, PatternType> byString = new HashMap<String, PatternType>();
private static final Map<String, PatternType> byString = new HashMap<>();
static {
for (PatternType p : values()) {

View File

@ -9,5 +9,5 @@ public interface BlockCommandSender extends CommandSender {
*
* @return Block for the command sender
*/
public Block getBlock();
Block getBlock();
}

View File

@ -36,7 +36,7 @@ public abstract class Command {
public String getTimingName() {return getName();} // Spigot
protected Command(String name) {
this(name, "", "/" + name, new ArrayList<String>());
this(name, "", "/" + name, new ArrayList<>());
}
protected Command(String name, String description, String usageMessage, List<String> aliases) {
@ -46,7 +46,7 @@ public abstract class Command {
this.description = description;
this.usageMessage = usageMessage;
this.aliases = aliases;
this.activeAliases = new ArrayList<String>(aliases);
this.activeAliases = new ArrayList<>(aliases);
}
/**
@ -98,7 +98,7 @@ public abstract class Command {
Player senderPlayer = sender instanceof Player ? (Player) sender : null;
ArrayList<String> matchedPlayers = new ArrayList<String>();
ArrayList<String> matchedPlayers = new ArrayList<>();
for (Player player : sender.getServer().getOnlinePlayers()) {
String name = player.getName();
if ((senderPlayer == null || senderPlayer.canSee(player)) && StringUtil.startsWithIgnoreCase(name, lastWord)) {
@ -106,7 +106,7 @@ public abstract class Command {
}
}
Collections.sort(matchedPlayers, String.CASE_INSENSITIVE_ORDER);
matchedPlayers.sort(String.CASE_INSENSITIVE_ORDER);
return matchedPlayers;
}
@ -289,7 +289,7 @@ public abstract class Command {
public boolean unregister(CommandMap commandMap) {
if (allowChangesFrom(commandMap)) {
this.commandMap = null;
this.activeAliases = new ArrayList<String>(this.aliases);
this.activeAliases = new ArrayList<>(this.aliases);
this.label = this.nextLabel;
return true;
}
@ -359,7 +359,7 @@ public abstract class Command {
public Command setAliases(List<String> aliases) {
this.aliases = aliases;
if (!isRegistered()) {
this.activeAliases = new ArrayList<String>(aliases);
this.activeAliases = new ArrayList<>(aliases);
}
return this;
}

View File

@ -14,5 +14,5 @@ public interface CommandExecutor {
* @param args Passed command arguments
* @return true if a valid command, otherwise false
*/
public boolean onCommand(CommandSender sender, Command command, String label, String[] args);
boolean onCommand(CommandSender sender, Command command, String label, String[] args);
}

View File

@ -19,7 +19,7 @@ public interface CommandMap {
* a ':' one or more times to make the command unique
* @param commands a list of commands to register
*/
public void registerAll(String fallbackPrefix, List<Command> commands);
void registerAll(String fallbackPrefix, List<Command> commands);
/**
* Registers a command. Returns true on success; false if name is already
@ -41,7 +41,7 @@ public interface CommandMap {
* otherwise, which indicates the fallbackPrefix was used one or more
* times
*/
public boolean register(String label, String fallbackPrefix, Command command);
boolean register(String label, String fallbackPrefix, Command command);
/**
* Registers a command. Returns true on success; false if name is already
@ -63,7 +63,7 @@ public interface CommandMap {
* otherwise, which indicates the fallbackPrefix was used one or more
* times
*/
public boolean register(String fallbackPrefix, Command command);
boolean register(String fallbackPrefix, Command command);
/**
* Looks for the requested command and executes it if found.
@ -74,12 +74,12 @@ public interface CommandMap {
* @throws CommandException Thrown when the executor for the given command
* fails with an unhandled exception
*/
public boolean dispatch(CommandSender sender, String cmdLine) throws CommandException;
boolean dispatch(CommandSender sender, String cmdLine) throws CommandException;
/**
* Clears all registered commands.
*/
public void clearCommands();
void clearCommands();
/**
* Gets the command registered to the specified name
@ -88,7 +88,7 @@ public interface CommandMap {
* @return Command with the specified name or null if a command with that
* label doesn't exist
*/
public Command getCommand(String name);
Command getCommand(String name);
/**
@ -105,5 +105,5 @@ public interface CommandMap {
* command fails with an unhandled exception
* @throws IllegalArgumentException if either sender or cmdLine are null
*/
public List<String> tabComplete(CommandSender sender, String cmdLine) throws IllegalArgumentException;
List<String> tabComplete(CommandSender sender, String cmdLine) throws IllegalArgumentException;
}

View File

@ -10,28 +10,28 @@ public interface CommandSender extends Permissible {
*
* @param message Message to be displayed
*/
public void sendMessage(String message);
void sendMessage(String message);
/**
* Sends this sender multiple messages
*
* @param messages An array of messages to be displayed
*/
public void sendMessage(String[] messages);
void sendMessage(String[] messages);
/**
* Returns the server instance that this command is running on
*
* @return Server instance
*/
public Server getServer();
Server getServer();
/**
* Gets the name of this command sender
*
* @return Name of the sender
*/
public String getName();
String getName();
// Paper start
/**

View File

@ -1,13 +1,8 @@
package org.bukkit.command;
import java.util.ArrayList;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.server.RemoteServerCommandEvent;
import org.bukkit.event.server.ServerCommandEvent;
public class FormattedCommandAlias extends Command {
private final String[] formatStrings;
@ -21,7 +16,7 @@ public class FormattedCommandAlias extends Command {
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
boolean result = false;
ArrayList<String> commands = new ArrayList<String>();
ArrayList<String> commands = new ArrayList<>();
for (String formatString : formatStrings) {
try {
commands.add(buildCommand(formatString, args));
@ -73,7 +68,7 @@ public class FormattedCommandAlias extends Command {
throw new IllegalArgumentException("Invalid replacement token");
}
int position = Integer.valueOf(formatString.substring(argStart, index));
int position = Integer.parseInt(formatString.substring(argStart, index));
// Arguments are not 0 indexed
if (position == 0) {
@ -108,7 +103,7 @@ public class FormattedCommandAlias extends Command {
replacement.append(args[position]);
}
formatString = formatString.substring(0, start) + replacement.toString() + formatString.substring(end);
formatString = formatString.substring(0, start) + replacement + formatString.substring(end);
// Move index past the replaced data so we don't process it again
index = start + replacement.length();

View File

@ -11,7 +11,7 @@ import org.bukkit.plugin.Plugin;
public class PluginCommandYamlParser {
public static List<Command> parse(Plugin plugin) {
List<Command> pluginCmds = new ArrayList<Command>();
List<Command> pluginCmds = new ArrayList<>();
Map<String, Map<String, Object>> map = plugin.getDescription().getCommands();
@ -40,19 +40,19 @@ public class PluginCommandYamlParser {
}
if (aliases != null) {
List<String> aliasList = new ArrayList<String>();
List<String> aliasList = new ArrayList<>();
if (aliases instanceof List) {
for (Object o : (List<?>) aliases) {
if (o.toString().contains(":")) {
Bukkit.getServer().getLogger().severe("Could not load alias " + o.toString() + " for plugin " + plugin.getName() + ": Illegal Characters");
Bukkit.getServer().getLogger().severe("Could not load alias " + o + " for plugin " + plugin.getName() + ": Illegal Characters");
continue;
}
aliasList.add(o.toString());
}
} else {
if (aliases.toString().contains(":")) {
Bukkit.getServer().getLogger().severe("Could not load alias " + aliases.toString() + " for plugin " + plugin.getName() + ": Illegal Characters");
Bukkit.getServer().getLogger().severe("Could not load alias " + aliases + " for plugin " + plugin.getName() + ": Illegal Characters");
} else {
aliasList.add(aliases.toString());
}

View File

@ -15,5 +15,5 @@ public interface PluginIdentifiableCommand {
*
* @return Plugin that owns this PluginIdentifiableCommand.
*/
public Plugin getPlugin();
Plugin getPlugin();
}

View File

@ -20,7 +20,7 @@ import org.bukkit.util.StringUtil;
public class SimpleCommandMap implements CommandMap {
private static final Pattern PATTERN_ON_SPACE = Pattern.compile(" ", Pattern.LITERAL);
protected final Map<String, Command> knownCommands = new HashMap<String, Command>();
protected final Map<String, Command> knownCommands = new HashMap<>();
private final Server server;
public SimpleCommandMap(final Server server) {
@ -167,8 +167,7 @@ public class SimpleCommandMap implements CommandMap {
}
public Command getCommand(String name) {
Command target = knownCommands.get(name.toLowerCase());
return target;
return knownCommands.get(name.toLowerCase());
}
public List<String> tabComplete(CommandSender sender, String cmdLine) {
@ -186,7 +185,7 @@ public class SimpleCommandMap implements CommandMap {
int spaceIndex = cmdLine.indexOf(' ');
if (spaceIndex == -1) {
ArrayList<String> completions = new ArrayList<String>();
ArrayList<String> completions = new ArrayList<>();
Map<String, Command> knownCommands = this.knownCommands;
final String prefix = (sender instanceof Player ? "/" : "");
@ -205,7 +204,7 @@ public class SimpleCommandMap implements CommandMap {
}
}
Collections.sort(completions, String.CASE_INSENSITIVE_ORDER);
completions.sort(String.CASE_INSENSITIVE_ORDER);
return completions;
}
@ -248,7 +247,7 @@ public class SimpleCommandMap implements CommandMap {
}
String[] commandStrings = values.get(alias);
List<String> targets = new ArrayList<String>();
List<String> targets = new ArrayList<>();
StringBuilder bad = new StringBuilder();
for (String commandString : commandStrings) {
@ -272,7 +271,7 @@ public class SimpleCommandMap implements CommandMap {
// We register these as commands so they have absolute priority.
if (targets.size() > 0) {
knownCommands.put(alias.toLowerCase(), new FormattedCommandAlias(alias.toLowerCase(), targets.toArray(new String[targets.size()])));
knownCommands.put(alias.toLowerCase(), new FormattedCommandAlias(alias.toLowerCase(), targets.toArray(new String[0])));
} else {
knownCommands.remove(alias.toLowerCase());
}

View File

@ -11,6 +11,6 @@ import java.util.List;
*/
@Deprecated
public interface TabCommandExecutor extends CommandExecutor {
public List<String> onTabComplete();
List<String> onTabComplete();
}

View File

@ -20,7 +20,7 @@ public interface TabCompleter {
* @return A List of possible completions for the final argument, or null
* to default to the command executor
*/
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args);
List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args);
// PaperSpigot start - location tab-completes
default List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args, Location location) {

View File

@ -2,6 +2,7 @@ package org.bukkit.command.defaults;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.Validate;
@ -173,11 +174,11 @@ public class AchievementCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
return Arrays.asList("give");
return Collections.singletonList("give");
}
if (args.length == 2) {
return Bukkit.getUnsafe().tabCompleteInternalStatisticOrAchievementName(args[1], new ArrayList<String>());
return Bukkit.getUnsafe().tabCompleteInternalStatisticOrAchievementName(args[1], new ArrayList<>());
}
if (args.length == 3) {

View File

@ -2,14 +2,12 @@ package org.bukkit.command.defaults;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.apache.commons.lang.Validate;
import org.bukkit.BanEntry;
import org.bukkit.BanList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.util.StringUtil;
@ -67,7 +65,7 @@ public class BanListCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], BANLIST_TYPES, new ArrayList<String>(BANLIST_TYPES.size()));
return StringUtil.copyPartialMatches(args[0], BANLIST_TYPES, new ArrayList<>(BANLIST_TYPES.size()));
}
return ImmutableList.of();
}

View File

@ -18,7 +18,7 @@ import java.util.List;
public class ClearCommand extends VanillaCommand {
private static List<String> materials;
static {
ArrayList<String> materialList = new ArrayList<String>();
ArrayList<String> materialList = new ArrayList<>();
for (Material material : Material.values()) {
materialList.add(material.name());
}
@ -98,7 +98,7 @@ public class ClearCommand extends VanillaCommand {
String material = materials.get(i);
if (StringUtil.startsWithIgnoreCase(material, arg)) {
if (completion == null) {
completion = new ArrayList<String>();
completion = new ArrayList<>();
}
completion.add(material);
} else {

View File

@ -36,7 +36,7 @@ public class DefaultGameModeCommand extends VanillaCommand {
try {
value = Integer.parseInt(modeArg);
} catch (NumberFormatException ex) {}
} catch (NumberFormatException ignored) {}
GameMode mode = GameMode.getByValue(value);
@ -63,7 +63,7 @@ public class DefaultGameModeCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, new ArrayList<String>(GAMEMODE_NAMES.size()));
return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, new ArrayList<>(GAMEMODE_NAMES.size()));
}
return ImmutableList.of();

View File

@ -49,7 +49,7 @@ public class DeopCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
List<String> completions = new ArrayList<String>();
List<String> completions = new ArrayList<>();
for (OfflinePlayer player : Bukkit.getOperators()) {
String playerName = player.getName();
if (StringUtil.startsWithIgnoreCase(playerName, args[0])) {

View File

@ -74,7 +74,7 @@ public class DifficultyCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], DIFFICULTY_NAMES, new ArrayList<String>(DIFFICULTY_NAMES.size()));
return StringUtil.copyPartialMatches(args[0], DIFFICULTY_NAMES, new ArrayList<>(DIFFICULTY_NAMES.size()));
}
return ImmutableList.of();

View File

@ -112,7 +112,7 @@ public class EffectCommand extends VanillaCommand {
if (args.length == 1) {
return super.tabComplete(sender, commandLabel, args);
} else if (args.length == 2) {
return StringUtil.copyPartialMatches(args[1], effects, new ArrayList<String>(effects.size()));
return StringUtil.copyPartialMatches(args[1], effects, new ArrayList<>(effects.size()));
}
return ImmutableList.of();

View File

@ -21,7 +21,7 @@ import org.bukkit.util.StringUtil;
@Deprecated
public class EnchantCommand extends VanillaCommand {
private static final List<String> ENCHANTMENT_NAMES = new ArrayList<String>();
private static final List<String> ENCHANTMENT_NAMES = new ArrayList<>();
public EnchantCommand() {
super("enchant");
@ -131,7 +131,7 @@ public class EnchantCommand extends VanillaCommand {
}
if (args.length == 2) {
return StringUtil.copyPartialMatches(args[1], ENCHANTMENT_NAMES, new ArrayList<String>(ENCHANTMENT_NAMES.size()));
return StringUtil.copyPartialMatches(args[1], ENCHANTMENT_NAMES, new ArrayList<>(ENCHANTMENT_NAMES.size()));
}
if (args.length == 3 || args.length == 4) {

View File

@ -47,7 +47,7 @@ public class GameModeCommand extends VanillaCommand {
try {
value = Integer.parseInt(modeArg);
} catch (NumberFormatException ex) {}
} catch (NumberFormatException ignored) {}
GameMode mode = GameMode.getByValue(value);
@ -70,9 +70,9 @@ public class GameModeCommand extends VanillaCommand {
sender.sendMessage("Game mode change for " + player.getName() + " failed!");
} else {
if (player == sender) {
Command.broadcastCommandMessage(sender, "Set own game mode to " + mode.toString() + " mode");
Command.broadcastCommandMessage(sender, "Set own game mode to " + mode + " mode");
} else {
Command.broadcastCommandMessage(sender, "Set " + player.getName() + "'s game mode to " + mode.toString() + " mode");
Command.broadcastCommandMessage(sender, "Set " + player.getName() + "'s game mode to " + mode + " mode");
}
}
} else {
@ -92,7 +92,7 @@ public class GameModeCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, new ArrayList<String>(GAMEMODE_NAMES.size()));
return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, new ArrayList<>(GAMEMODE_NAMES.size()));
} else if (args.length == 2) {
return super.tabComplete(sender, alias, args);
}

View File

@ -77,11 +77,11 @@ public class GameRuleCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], Arrays.asList(getGameWorld(sender).getGameRules()), new ArrayList<String>());
return StringUtil.copyPartialMatches(args[0], Arrays.asList(getGameWorld(sender).getGameRules()), new ArrayList<>());
}
if (args.length == 2) {
return StringUtil.copyPartialMatches(args[1], GAMERULE_STATES, new ArrayList<String>(GAMERULE_STATES.size()));
return StringUtil.copyPartialMatches(args[1], GAMERULE_STATES, new ArrayList<>(GAMERULE_STATES.size()));
}
return ImmutableList.of();

View File

@ -22,7 +22,7 @@ import com.google.common.collect.ImmutableList;
public class GiveCommand extends VanillaCommand {
private static List<String> materials;
static {
ArrayList<String> materialList = new ArrayList<String>();
ArrayList<String> materialList = new ArrayList<>();
for (Material material : Material.values()) {
materialList.add(material.name());
}
@ -64,7 +64,7 @@ public class GiveCommand extends VanillaCommand {
if (args.length >= 4) {
try {
data = Short.parseShort(args[3]);
} catch (NumberFormatException ex) {}
} catch (NumberFormatException ignored) {}
}
}
@ -104,7 +104,7 @@ public class GiveCommand extends VanillaCommand {
if (args.length == 2) {
final String arg = args[1];
final List<String> materials = GiveCommand.materials;
List<String> completion = new ArrayList<String>();
List<String> completion = new ArrayList<>();
final int size = materials.size();
int i = Collections.binarySearch(materials, arg, String.CASE_INSENSITIVE_ORDER);

View File

@ -118,7 +118,7 @@ public class HelpCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
List<String> matchedTopics = new ArrayList<String>();
List<String> matchedTopics = new ArrayList<>();
String searchString = args[0];
for (HelpTopic topic : Bukkit.getServer().getHelpMap().getHelpTopics()) {
String trimmedTopic = topic.getName().startsWith("/") ? topic.getName().substring(1) : topic.getName();
@ -134,7 +134,7 @@ public class HelpCommand extends VanillaCommand {
protected HelpTopic findPossibleMatches(String searchString) {
int maxDistance = (searchString.length() / 5) + 3;
Set<HelpTopic> possibleMatches = new TreeSet<HelpTopic>(HelpTopicComparator.helpTopicComparatorInstance());
Set<HelpTopic> possibleMatches = new TreeSet<>(HelpTopicComparator.helpTopicComparatorInstance());
if (searchString.startsWith("/")) {
searchString = searchString.substring(1);
@ -198,7 +198,7 @@ public class HelpCommand extends VanillaCommand {
H[0][j + 1] = INF;
}
Map<Character, Integer> sd = new HashMap<Character, Integer>();
Map<Character, Integer> sd = new HashMap<>();
for (char Letter : (s1 + s2).toCharArray()) {
if (!sd.containsKey(Letter)) {
sd.put(Letter, 0);

View File

@ -39,7 +39,7 @@ public class ListCommand extends VanillaCommand {
online.append(player.getDisplayName());
}
sender.sendMessage("There are " + players.size() + "/" + Bukkit.getMaxPlayers() + " players online:\n" + online.toString());
sender.sendMessage("There are " + players.size() + "/" + Bukkit.getMaxPlayers() + " players online:\n" + online);
return true;
}

View File

@ -29,7 +29,7 @@ public class MeCommand extends VanillaCommand {
message.append(arg);
}
Bukkit.broadcastMessage("* " + message.toString());
Bukkit.broadcastMessage("* " + message);
return true;
}

View File

@ -57,7 +57,7 @@ public class OpCommand extends VanillaCommand {
Player senderPlayer = (Player) sender;
ArrayList<String> matchedPlayers = new ArrayList<String>();
ArrayList<String> matchedPlayers = new ArrayList<>();
for (Player player : sender.getServer().getOnlinePlayers()) {
String name = player.getName();
if (!senderPlayer.canSee(player) || player.isOp()) {
@ -68,7 +68,7 @@ public class OpCommand extends VanillaCommand {
}
}
Collections.sort(matchedPlayers, String.CASE_INSENSITIVE_ORDER);
matchedPlayers.sort(String.CASE_INSENSITIVE_ORDER);
return matchedPlayers;
}
return ImmutableList.of();

View File

@ -43,7 +43,7 @@ public class PardonCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
List<String> completions = new ArrayList<String>();
List<String> completions = new ArrayList<>();
for (OfflinePlayer player : Bukkit.getBannedPlayers()) {
String name = player.getName();
if (StringUtil.startsWithIgnoreCase(name, args[0])) {

View File

@ -46,7 +46,7 @@ public class PardonIpCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], Bukkit.getIPBans(), new ArrayList<String>());
return StringUtil.copyPartialMatches(args[0], Bukkit.getIPBans(), new ArrayList<>());
}
return ImmutableList.of();
}

View File

@ -1,6 +1,7 @@
package org.bukkit.command.defaults;
import java.util.Arrays;
import java.util.Collections;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -13,7 +14,7 @@ public class PluginsCommand extends BukkitCommand {
this.description = "Gets a list of plugins running on the server";
this.usageMessage = "/plugins";
this.setPermission("bukkit.command.plugins");
this.setAliases(Arrays.asList("pl"));
this.setAliases(Collections.singletonList("pl"));
}
@Override
@ -38,7 +39,7 @@ public class PluginsCommand extends BukkitCommand {
pluginList.append(plugin.getDescription().getName());
}
return "(" + plugins.length + "): " + pluginList.toString();
return "(" + plugins.length + "): " + pluginList;
}
// Spigot Start

View File

@ -1,6 +1,7 @@
package org.bukkit.command.defaults;
import java.util.Arrays;
import java.util.Collections;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -13,7 +14,7 @@ public class ReloadCommand extends BukkitCommand {
this.description = "Reloads the server configuration and plugins";
this.usageMessage = "/reload";
this.setPermission("bukkit.command.reload");
this.setAliases(Arrays.asList("rl"));
this.setAliases(Collections.singletonList("rl"));
}
@Override

View File

@ -365,7 +365,7 @@ public class ScoreboardCommand extends VanillaCommand {
if (team == null) {
sender.sendMessage(ChatColor.RED + "No team was found by the name '" + teamName + "'");
} else {
Set<String> addedPlayers = new HashSet<String>();
Set<String> addedPlayers = new HashSet<>();
if ((sender instanceof Player) && args.length == 3) {
team.addPlayer((Player) sender);
addedPlayers.add(sender.getName());
@ -390,8 +390,8 @@ public class ScoreboardCommand extends VanillaCommand {
sender.sendMessage(ChatColor.RED + "/scoreboard teams leave [player...]");
return false;
}
Set<String> left = new HashSet<String>();
Set<String> noTeam = new HashSet<String>();
Set<String> left = new HashSet<>();
Set<String> noTeam = new HashSet<>();
if ((sender instanceof Player) && args.length == 2) {
Team team = mainScoreboard.getPlayerTeam((Player) sender);
if (team != null) {
@ -485,52 +485,52 @@ public class ScoreboardCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], MAIN_CHOICES, new ArrayList<String>());
return StringUtil.copyPartialMatches(args[0], MAIN_CHOICES, new ArrayList<>());
}
if (args.length > 1) {
if (args[0].equalsIgnoreCase("objectives")) {
if (args.length == 2) {
return StringUtil.copyPartialMatches(args[1], OBJECTIVES_CHOICES, new ArrayList<String>());
return StringUtil.copyPartialMatches(args[1], OBJECTIVES_CHOICES, new ArrayList<>());
}
if (args[1].equalsIgnoreCase("add")) {
if (args.length == 4) {
return StringUtil.copyPartialMatches(args[3], OBJECTIVES_CRITERIA, new ArrayList<String>());
return StringUtil.copyPartialMatches(args[3], OBJECTIVES_CRITERIA, new ArrayList<>());
}
} else if (args[1].equalsIgnoreCase("remove")) {
if (args.length == 3) {
return StringUtil.copyPartialMatches(args[2], this.getCurrentObjectives(), new ArrayList<String>());
return StringUtil.copyPartialMatches(args[2], this.getCurrentObjectives(), new ArrayList<>());
}
} else if (args[1].equalsIgnoreCase("setdisplay")) {
if (args.length == 3) {
return StringUtil.copyPartialMatches(args[2], OBJECTIVES_DISPLAYSLOT.keySet(), new ArrayList<String>());
return StringUtil.copyPartialMatches(args[2], OBJECTIVES_DISPLAYSLOT.keySet(), new ArrayList<>());
}
if (args.length == 4) {
return StringUtil.copyPartialMatches(args[3], this.getCurrentObjectives(), new ArrayList<String>());
return StringUtil.copyPartialMatches(args[3], this.getCurrentObjectives(), new ArrayList<>());
}
}
} else if (args[0].equalsIgnoreCase("players")) {
if (args.length == 2) {
return StringUtil.copyPartialMatches(args[1], PLAYERS_CHOICES, new ArrayList<String>());
return StringUtil.copyPartialMatches(args[1], PLAYERS_CHOICES, new ArrayList<>());
}
if (args[1].equalsIgnoreCase("set") || args[1].equalsIgnoreCase("add") || args[1].equalsIgnoreCase("remove")) {
if (args.length == 3) {
return super.tabComplete(sender, alias, args);
}
if (args.length == 4) {
return StringUtil.copyPartialMatches(args[3], this.getCurrentObjectives(), new ArrayList<String>());
return StringUtil.copyPartialMatches(args[3], this.getCurrentObjectives(), new ArrayList<>());
}
} else {
if (args.length == 3) {
return StringUtil.copyPartialMatches(args[2], this.getCurrentEntries(), new ArrayList<String>());
return StringUtil.copyPartialMatches(args[2], this.getCurrentEntries(), new ArrayList<>());
}
}
} else if (args[0].equalsIgnoreCase("teams")) {
if (args.length == 2) {
return StringUtil.copyPartialMatches(args[1], TEAMS_CHOICES, new ArrayList<String>());
return StringUtil.copyPartialMatches(args[1], TEAMS_CHOICES, new ArrayList<>());
}
if (args[1].equalsIgnoreCase("join")) {
if (args.length == 3) {
return StringUtil.copyPartialMatches(args[2], this.getCurrentTeams(), new ArrayList<String>());
return StringUtil.copyPartialMatches(args[2], this.getCurrentTeams(), new ArrayList<>());
}
if (args.length >= 4) {
return super.tabComplete(sender, alias, args);
@ -539,21 +539,21 @@ public class ScoreboardCommand extends VanillaCommand {
return super.tabComplete(sender, alias, args);
} else if (args[1].equalsIgnoreCase("option")) {
if (args.length == 3) {
return StringUtil.copyPartialMatches(args[2], this.getCurrentTeams(), new ArrayList<String>());
return StringUtil.copyPartialMatches(args[2], this.getCurrentTeams(), new ArrayList<>());
}
if (args.length == 4) {
return StringUtil.copyPartialMatches(args[3], TEAMS_OPTION_CHOICES, new ArrayList<String>());
return StringUtil.copyPartialMatches(args[3], TEAMS_OPTION_CHOICES, new ArrayList<>());
}
if (args.length == 5) {
if (args[3].equalsIgnoreCase("color")) {
return StringUtil.copyPartialMatches(args[4], TEAMS_OPTION_COLOR.keySet(), new ArrayList<String>());
return StringUtil.copyPartialMatches(args[4], TEAMS_OPTION_COLOR.keySet(), new ArrayList<>());
} else {
return StringUtil.copyPartialMatches(args[4], BOOLEAN, new ArrayList<String>());
return StringUtil.copyPartialMatches(args[4], BOOLEAN, new ArrayList<>());
}
}
} else {
if (args.length == 3) {
return StringUtil.copyPartialMatches(args[2], this.getCurrentTeams(), new ArrayList<String>());
return StringUtil.copyPartialMatches(args[2], this.getCurrentTeams(), new ArrayList<>());
}
}
}
@ -590,29 +590,27 @@ public class ScoreboardCommand extends VanillaCommand {
}
private List<String> getCurrentObjectives() {
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();
for (Objective objective : Bukkit.getScoreboardManager().getMainScoreboard().getObjectives()) {
list.add(objective.getName());
}
Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
list.sort(String.CASE_INSENSITIVE_ORDER);
return list;
}
private List<String> getCurrentEntries() {
List<String> list = new ArrayList<String>();
for (String entry : Bukkit.getScoreboardManager().getMainScoreboard().getEntries()) {
list.add(entry);
}
Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
List<String> list = new ArrayList<>();
list.addAll(Bukkit.getScoreboardManager().getMainScoreboard().getEntries());
list.sort(String.CASE_INSENSITIVE_ORDER);
return list;
}
private List<String> getCurrentTeams() {
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();
for (Team team : Bukkit.getScoreboardManager().getMainScoreboard().getTeams()) {
list.add(team.getName());
}
Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
list.sort(String.CASE_INSENSITIVE_ORDER);
return list;
}
}

View File

@ -180,11 +180,10 @@ public class SpreadPlayersCommand extends VanillaCommand {
}
if (!flag) {
Location[] locs = locations;
int i1 = locations.length;
for (j = 0; j < i1; ++j) {
loc1 = locs[j];
loc1 = locations[j];
if (world.getHighestBlockYAt(loc1) == 0) {
double x = xRangeMin >= xRangeMax ? xRangeMin : random.nextDouble() * (xRangeMax - xRangeMin) + xRangeMin;
double z = zRangeMin >= zRangeMax ? zRangeMin : random.nextDouble() * (zRangeMax - zRangeMin) + zRangeMin;
@ -209,8 +208,7 @@ public class SpreadPlayersCommand extends VanillaCommand {
int i = 0;
Map<Team, Location> hashmap = Maps.newHashMap();
for (int j = 0; j < list.size(); ++j) {
Player player = list.get(j);
for (Player player : list) {
Location location;
if (teams) {
@ -228,9 +226,9 @@ public class SpreadPlayersCommand extends VanillaCommand {
player.teleport(new Location(world, Math.floor(location.getX()) + 0.5D, world.getHighestBlockYAt((int) location.getX(), (int) location.getZ()), Math.floor(location.getZ()) + 0.5D));
double value = Double.MAX_VALUE;
for (int k = 0; k < locations.length; ++k) {
if (location != locations[k]) {
double d = location.distanceSquared(locations[k]);
for (Location item : locations) {
if (location != item) {
double d = location.distanceSquared(item);
value = Math.min(d, value);
}
}

View File

@ -1,6 +1,5 @@
package org.bukkit.command.defaults;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

View File

@ -80,9 +80,9 @@ public class TimeCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], TABCOMPLETE_ADD_SET, new ArrayList<String>(TABCOMPLETE_ADD_SET.size()));
return StringUtil.copyPartialMatches(args[0], TABCOMPLETE_ADD_SET, new ArrayList<>(TABCOMPLETE_ADD_SET.size()));
} else if (args.length == 2 && args[0].equalsIgnoreCase("set")) {
return StringUtil.copyPartialMatches(args[1], TABCOMPLETE_DAY_NIGHT, new ArrayList<String>(TABCOMPLETE_DAY_NIGHT.size()));
return StringUtil.copyPartialMatches(args[1], TABCOMPLETE_DAY_NIGHT, new ArrayList<>(TABCOMPLETE_DAY_NIGHT.size()));
}
return ImmutableList.of();
}

View File

@ -20,16 +20,7 @@ import org.bukkit.util.StringUtil;
import com.google.common.collect.ImmutableList;
// Spigot start
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.logging.Level;
import org.bukkit.command.RemoteConsoleCommandSender;
import org.bukkit.plugin.SimplePluginManager;
import org.spigotmc.CustomTimingsHandler;
// Spigot end
public class TimingsCommand extends BukkitCommand {
@ -107,7 +98,7 @@ public class TimingsCommand extends BukkitCommand {
}
sender.sendMessage("Timings written to " + timings.getPath());
if (separate) sender.sendMessage("Names written to " + names.getPath());
} catch (IOException e) {
} catch (IOException ignored) {
} finally {
if (fileTimings != null) {
fileTimings.close();
@ -130,7 +121,7 @@ public class TimingsCommand extends BukkitCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], TIMINGS_SUBCOMMANDS, new ArrayList<String>(TIMINGS_SUBCOMMANDS.size()));
return StringUtil.copyPartialMatches(args[0], TIMINGS_SUBCOMMANDS, new ArrayList<>(TIMINGS_SUBCOMMANDS.size()));
}
return ImmutableList.of();
}

View File

@ -35,7 +35,7 @@ public abstract class VanillaCommand extends Command {
int i = min;
try {
i = Integer.valueOf(value);
i = Integer.parseInt(value);
} catch (NumberFormatException ex) {
if (Throws) {
throw new NumberFormatException(String.format("%s is not a valid number", value));

View File

@ -35,7 +35,7 @@ public class VersionCommand extends BukkitCommand {
"§3This server is running §b§leSpigot§3 by the ElevateMC development team. Version §b§l1.8.8",
};
sender.sendMessage(message);;
sender.sendMessage(message);
} else {
StringBuilder name = new StringBuilder();
@ -121,7 +121,7 @@ public class VersionCommand extends BukkitCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
List<String> completions = new ArrayList<String>();
List<String> completions = new ArrayList<>();
String toComplete = args[0].toLowerCase();
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
if (StringUtil.startsWithIgnoreCase(plugin.getName(), toComplete)) {

View File

@ -66,7 +66,7 @@ public class WeatherCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], WEATHER_TYPES, new ArrayList<String>(WEATHER_TYPES.size()));
return StringUtil.copyPartialMatches(args[0], WEATHER_TYPES, new ArrayList<>(WEATHER_TYPES.size()));
}
return ImmutableList.of();

View File

@ -60,7 +60,7 @@ public class WhitelistCommand extends VanillaCommand {
result.append(player.getName());
}
sender.sendMessage("White-listed players: " + result.toString());
sender.sendMessage("White-listed players: " + result);
return true;
}
} else if (args.length == 2) {
@ -101,10 +101,10 @@ public class WhitelistCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0], WHITELIST_SUBCOMMANDS, new ArrayList<String>(WHITELIST_SUBCOMMANDS.size()));
return StringUtil.copyPartialMatches(args[0], WHITELIST_SUBCOMMANDS, new ArrayList<>(WHITELIST_SUBCOMMANDS.size()));
} else if (args.length == 2) {
if (args[0].equalsIgnoreCase("add")) {
List<String> completions = new ArrayList<String>();
List<String> completions = new ArrayList<>();
for (OfflinePlayer player : Bukkit.getOnlinePlayers()) { // Spigot - well maybe sometimes you haven't turned the whitelist on just yet.
String name = player.getName();
if (StringUtil.startsWithIgnoreCase(name, args[1]) && !player.isWhitelisted()) {
@ -113,7 +113,7 @@ public class WhitelistCommand extends VanillaCommand {
}
return completions;
} else if (args[0].equalsIgnoreCase("remove")) {
List<String> completions = new ArrayList<String>();
List<String> completions = new ArrayList<>();
for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) {
String name = player.getName();
if (StringUtil.startsWithIgnoreCase(name, args[1])) {

View File

@ -20,7 +20,7 @@ public interface Configuration extends ConfigurationSection {
* @param value Value to set the default to.
* @throws IllegalArgumentException Thrown if path is null.
*/
public void addDefault(String path, Object value);
void addDefault(String path, Object value);
/**
* Sets the default values of the given paths as provided.
@ -32,7 +32,7 @@ public interface Configuration extends ConfigurationSection {
* @param defaults A map of Path{@literal ->}Values to add to defaults.
* @throws IllegalArgumentException Thrown if defaults is null.
*/
public void addDefaults(Map<String, Object> defaults);
void addDefaults(Map<String, Object> defaults);
/**
* Sets the default values of the given paths as provided.
@ -49,7 +49,7 @@ public interface Configuration extends ConfigurationSection {
* @param defaults A configuration holding a list of defaults to copy.
* @throws IllegalArgumentException Thrown if defaults is null or this.
*/
public void addDefaults(Configuration defaults);
void addDefaults(Configuration defaults);
/**
* Sets the source of all default values for this {@link Configuration}.
@ -60,7 +60,7 @@ public interface Configuration extends ConfigurationSection {
* @param defaults New source of default values for this configuration.
* @throws IllegalArgumentException Thrown if defaults is null or this.
*/
public void setDefaults(Configuration defaults);
void setDefaults(Configuration defaults);
/**
* Gets the source {@link Configuration} for this configuration.
@ -71,7 +71,7 @@ public interface Configuration extends ConfigurationSection {
*
* @return Configuration source for default values, or null if none exist.
*/
public Configuration getDefaults();
Configuration getDefaults();
/**
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
@ -80,5 +80,5 @@ public interface Configuration extends ConfigurationSection {
*
* @return Options for this configuration
*/
public ConfigurationOptions options();
ConfigurationOptions options();
}

View File

@ -27,7 +27,7 @@ public interface ConfigurationSection {
* list.
* @return Set of keys contained within this ConfigurationSection.
*/
public Set<String> getKeys(boolean deep);
Set<String> getKeys(boolean deep);
/**
* Gets a Map containing all keys and their values for this section.
@ -43,7 +43,7 @@ public interface ConfigurationSection {
* list.
* @return Map of keys and values of this section.
*/
public Map<String, Object> getValues(boolean deep);
Map<String, Object> getValues(boolean deep);
/**
* Checks if this {@link ConfigurationSection} contains the given path.
@ -56,7 +56,7 @@ public interface ConfigurationSection {
* default or being set.
* @throws IllegalArgumentException Thrown when path is null.
*/
public boolean contains(String path);
boolean contains(String path);
/**
* Checks if this {@link ConfigurationSection} has a value set for the
@ -70,7 +70,7 @@ public interface ConfigurationSection {
* having a default.
* @throws IllegalArgumentException Thrown when path is null.
*/
public boolean isSet(String path);
boolean isSet(String path);
/**
* Gets the path of this {@link ConfigurationSection} from its root {@link
@ -87,7 +87,7 @@ public interface ConfigurationSection {
*
* @return Path of this section relative to its root
*/
public String getCurrentPath();
String getCurrentPath();
/**
* Gets the name of this individual {@link ConfigurationSection}, in the
@ -98,7 +98,7 @@ public interface ConfigurationSection {
*
* @return Name of this section
*/
public String getName();
String getName();
/**
* Gets the root {@link Configuration} that contains this {@link
@ -112,7 +112,7 @@ public interface ConfigurationSection {
*
* @return Root configuration containing this section.
*/
public Configuration getRoot();
Configuration getRoot();
/**
* Gets the parent {@link ConfigurationSection} that directly contains
@ -125,7 +125,7 @@ public interface ConfigurationSection {
*
* @return Parent section containing this section.
*/
public ConfigurationSection getParent();
ConfigurationSection getParent();
/**
* Gets the requested Object by path.
@ -137,7 +137,7 @@ public interface ConfigurationSection {
* @param path Path of the Object to get.
* @return Requested Object.
*/
public Object get(String path);
Object get(String path);
/**
* Gets the requested Object by path, returning a default value if not
@ -151,7 +151,7 @@ public interface ConfigurationSection {
* @param def The default value to return if the path is not found.
* @return Requested Object.
*/
public Object get(String path, Object def);
Object get(String path, Object def);
/**
* Sets the specified path to the given value.
@ -167,7 +167,7 @@ public interface ConfigurationSection {
* @param path Path of the object to set.
* @param value New value to set the path to.
*/
public void set(String path, Object value);
void set(String path, Object value);
/**
* Creates an empty {@link ConfigurationSection} at the specified path.
@ -179,7 +179,7 @@ public interface ConfigurationSection {
* @param path Path to create the section at.
* @return Newly created section
*/
public ConfigurationSection createSection(String path);
ConfigurationSection createSection(String path);
/**
* Creates a {@link ConfigurationSection} at the specified path, with
@ -193,7 +193,7 @@ public interface ConfigurationSection {
* @param map The values to used.
* @return Newly created section
*/
public ConfigurationSection createSection(String path, Map<?, ?> map);
ConfigurationSection createSection(String path, Map<?, ?> map);
// Primitives
/**
@ -206,7 +206,7 @@ public interface ConfigurationSection {
* @param path Path of the String to get.
* @return Requested String.
*/
public String getString(String path);
String getString(String path);
/**
* Gets the requested String by path, returning a default value if not
@ -221,7 +221,7 @@ public interface ConfigurationSection {
* not a String.
* @return Requested String.
*/
public String getString(String path, String def);
String getString(String path, String def);
/**
* Checks if the specified path is a String.
@ -234,7 +234,7 @@ public interface ConfigurationSection {
* @param path Path of the String to check.
* @return Whether or not the specified path is a String.
*/
public boolean isString(String path);
boolean isString(String path);
/**
* Gets the requested int by path.
@ -246,7 +246,7 @@ public interface ConfigurationSection {
* @param path Path of the int to get.
* @return Requested int.
*/
public int getInt(String path);
int getInt(String path);
/**
* Gets the requested int by path, returning a default value if not found.
@ -260,7 +260,7 @@ public interface ConfigurationSection {
* not an int.
* @return Requested int.
*/
public int getInt(String path, int def);
int getInt(String path, int def);
/**
* Checks if the specified path is an int.
@ -273,7 +273,7 @@ public interface ConfigurationSection {
* @param path Path of the int to check.
* @return Whether or not the specified path is an int.
*/
public boolean isInt(String path);
boolean isInt(String path);
/**
* Gets the requested boolean by path.
@ -285,7 +285,7 @@ public interface ConfigurationSection {
* @param path Path of the boolean to get.
* @return Requested boolean.
*/
public boolean getBoolean(String path);
boolean getBoolean(String path);
/**
* Gets the requested boolean by path, returning a default value if not
@ -300,7 +300,7 @@ public interface ConfigurationSection {
* not a boolean.
* @return Requested boolean.
*/
public boolean getBoolean(String path, boolean def);
boolean getBoolean(String path, boolean def);
/**
* Checks if the specified path is a boolean.
@ -313,7 +313,7 @@ public interface ConfigurationSection {
* @param path Path of the boolean to check.
* @return Whether or not the specified path is a boolean.
*/
public boolean isBoolean(String path);
boolean isBoolean(String path);
/**
* Gets the requested double by path.
@ -325,7 +325,7 @@ public interface ConfigurationSection {
* @param path Path of the double to get.
* @return Requested double.
*/
public double getDouble(String path);
double getDouble(String path);
/**
* Gets the requested double by path, returning a default value if not
@ -340,7 +340,7 @@ public interface ConfigurationSection {
* not a double.
* @return Requested double.
*/
public double getDouble(String path, double def);
double getDouble(String path, double def);
/**
* Checks if the specified path is a double.
@ -353,7 +353,7 @@ public interface ConfigurationSection {
* @param path Path of the double to check.
* @return Whether or not the specified path is a double.
*/
public boolean isDouble(String path);
boolean isDouble(String path);
// PaperSpigot start - Add getFloat
/**
@ -366,7 +366,7 @@ public interface ConfigurationSection {
* @param path Path of the float to get.
* @return Requested float.
*/
public float getFloat(String path);
float getFloat(String path);
/**
* Gets the requested float by path, returning a default value if not
@ -381,7 +381,7 @@ public interface ConfigurationSection {
* not a float.
* @return Requested float.
*/
public float getFloat(String path, float def);
float getFloat(String path, float def);
/**
* Checks if the specified path is a float.
@ -394,7 +394,7 @@ public interface ConfigurationSection {
* @param path Path of the float to check.
* @return Whether or not the specified path is a float.
*/
public boolean isFloat(String path);
boolean isFloat(String path);
// PaperSpigot end
/**
@ -407,7 +407,7 @@ public interface ConfigurationSection {
* @param path Path of the long to get.
* @return Requested long.
*/
public long getLong(String path);
long getLong(String path);
/**
* Gets the requested long by path, returning a default value if not
@ -422,7 +422,7 @@ public interface ConfigurationSection {
* not a long.
* @return Requested long.
*/
public long getLong(String path, long def);
long getLong(String path, long def);
/**
* Checks if the specified path is a long.
@ -435,7 +435,7 @@ public interface ConfigurationSection {
* @param path Path of the long to check.
* @return Whether or not the specified path is a long.
*/
public boolean isLong(String path);
boolean isLong(String path);
// Java
/**
@ -448,7 +448,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get.
* @return Requested List.
*/
public List<?> getList(String path);
List<?> getList(String path);
/**
* Gets the requested List by path, returning a default value if not
@ -463,7 +463,7 @@ public interface ConfigurationSection {
* not a List.
* @return Requested List.
*/
public List<?> getList(String path, List<?> def);
List<?> getList(String path, List<?> def);
/**
* Checks if the specified path is a List.
@ -476,7 +476,7 @@ public interface ConfigurationSection {
* @param path Path of the List to check.
* @return Whether or not the specified path is a List.
*/
public boolean isList(String path);
boolean isList(String path);
/**
* Gets the requested List of String by path.
@ -491,7 +491,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get.
* @return Requested List of String.
*/
public List<String> getStringList(String path);
List<String> getStringList(String path);
/**
* Gets the requested List of Integer by path.
@ -506,7 +506,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get.
* @return Requested List of Integer.
*/
public List<Integer> getIntegerList(String path);
List<Integer> getIntegerList(String path);
/**
* Gets the requested List of Boolean by path.
@ -521,7 +521,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get.
* @return Requested List of Boolean.
*/
public List<Boolean> getBooleanList(String path);
List<Boolean> getBooleanList(String path);
/**
* Gets the requested List of Double by path.
@ -536,7 +536,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get.
* @return Requested List of Double.
*/
public List<Double> getDoubleList(String path);
List<Double> getDoubleList(String path);
/**
* Gets the requested List of Float by path.
@ -551,7 +551,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get.
* @return Requested List of Float.
*/
public List<Float> getFloatList(String path);
List<Float> getFloatList(String path);
/**
* Gets the requested List of Long by path.
@ -566,7 +566,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get.
* @return Requested List of Long.
*/
public List<Long> getLongList(String path);
List<Long> getLongList(String path);
/**
* Gets the requested List of Byte by path.
@ -581,7 +581,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get.
* @return Requested List of Byte.
*/
public List<Byte> getByteList(String path);
List<Byte> getByteList(String path);
/**
* Gets the requested List of Character by path.
@ -596,7 +596,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get.
* @return Requested List of Character.
*/
public List<Character> getCharacterList(String path);
List<Character> getCharacterList(String path);
/**
* Gets the requested List of Short by path.
@ -611,7 +611,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get.
* @return Requested List of Short.
*/
public List<Short> getShortList(String path);
List<Short> getShortList(String path);
/**
* Gets the requested List of Maps by path.
@ -626,7 +626,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get.
* @return Requested List of Maps.
*/
public List<Map<?, ?>> getMapList(String path);
List<Map<?, ?>> getMapList(String path);
// Bukkit
/**
@ -639,7 +639,7 @@ public interface ConfigurationSection {
* @param path Path of the Vector to get.
* @return Requested Vector.
*/
public Vector getVector(String path);
Vector getVector(String path);
/**
* Gets the requested {@link Vector} by path, returning a default value if
@ -654,7 +654,7 @@ public interface ConfigurationSection {
* not a Vector.
* @return Requested Vector.
*/
public Vector getVector(String path, Vector def);
Vector getVector(String path, Vector def);
/**
* Checks if the specified path is a Vector.
@ -667,7 +667,7 @@ public interface ConfigurationSection {
* @param path Path of the Vector to check.
* @return Whether or not the specified path is a Vector.
*/
public boolean isVector(String path);
boolean isVector(String path);
/**
* Gets the requested OfflinePlayer by path.
@ -680,7 +680,7 @@ public interface ConfigurationSection {
* @param path Path of the OfflinePlayer to get.
* @return Requested OfflinePlayer.
*/
public OfflinePlayer getOfflinePlayer(String path);
OfflinePlayer getOfflinePlayer(String path);
/**
* Gets the requested {@link OfflinePlayer} by path, returning a default
@ -695,7 +695,7 @@ public interface ConfigurationSection {
* not an OfflinePlayer.
* @return Requested OfflinePlayer.
*/
public OfflinePlayer getOfflinePlayer(String path, OfflinePlayer def);
OfflinePlayer getOfflinePlayer(String path, OfflinePlayer def);
/**
* Checks if the specified path is an OfflinePlayer.
@ -708,7 +708,7 @@ public interface ConfigurationSection {
* @param path Path of the OfflinePlayer to check.
* @return Whether or not the specified path is an OfflinePlayer.
*/
public boolean isOfflinePlayer(String path);
boolean isOfflinePlayer(String path);
/**
* Gets the requested ItemStack by path.
@ -720,7 +720,7 @@ public interface ConfigurationSection {
* @param path Path of the ItemStack to get.
* @return Requested ItemStack.
*/
public ItemStack getItemStack(String path);
ItemStack getItemStack(String path);
/**
* Gets the requested {@link ItemStack} by path, returning a default value
@ -735,7 +735,7 @@ public interface ConfigurationSection {
* not an ItemStack.
* @return Requested ItemStack.
*/
public ItemStack getItemStack(String path, ItemStack def);
ItemStack getItemStack(String path, ItemStack def);
/**
* Checks if the specified path is an ItemStack.
@ -748,7 +748,7 @@ public interface ConfigurationSection {
* @param path Path of the ItemStack to check.
* @return Whether or not the specified path is an ItemStack.
*/
public boolean isItemStack(String path);
boolean isItemStack(String path);
/**
* Gets the requested Color by path.
@ -760,7 +760,7 @@ public interface ConfigurationSection {
* @param path Path of the Color to get.
* @return Requested Color.
*/
public Color getColor(String path);
Color getColor(String path);
/**
* Gets the requested {@link Color} by path, returning a default value if
@ -775,7 +775,7 @@ public interface ConfigurationSection {
* not a Color.
* @return Requested Color.
*/
public Color getColor(String path, Color def);
Color getColor(String path, Color def);
/**
* Checks if the specified path is a Color.
@ -788,7 +788,7 @@ public interface ConfigurationSection {
* @param path Path of the Color to check.
* @return Whether or not the specified path is a Color.
*/
public boolean isColor(String path);
boolean isColor(String path);
/**
* Gets the requested ConfigurationSection by path.
@ -801,7 +801,7 @@ public interface ConfigurationSection {
* @param path Path of the ConfigurationSection to get.
* @return Requested ConfigurationSection.
*/
public ConfigurationSection getConfigurationSection(String path);
ConfigurationSection getConfigurationSection(String path);
/**
* Checks if the specified path is a ConfigurationSection.
@ -815,7 +815,7 @@ public interface ConfigurationSection {
* @param path Path of the ConfigurationSection to check.
* @return Whether or not the specified path is a ConfigurationSection.
*/
public boolean isConfigurationSection(String path);
boolean isConfigurationSection(String path);
/**
* Gets the equivalent {@link ConfigurationSection} from the default
@ -827,7 +827,7 @@ public interface ConfigurationSection {
*
* @return Equivalent section in root configuration
*/
public ConfigurationSection getDefaultSection();
ConfigurationSection getDefaultSection();
/**
* Sets the default value in the root at the given path as provided.
@ -847,5 +847,5 @@ public interface ConfigurationSection {
* @param value Value to set the default to.
* @throws IllegalArgumentException Thrown if path is null.
*/
public void addDefault(String path, Object value);
void addDefault(String path, Object value);
}

View File

@ -19,7 +19,7 @@ import org.bukkit.util.Vector;
* A type of {@link ConfigurationSection} that is stored in memory.
*/
public class MemorySection implements ConfigurationSection {
protected final Map<String, Object> map = new LinkedHashMap<String, Object>();
protected final Map<String, Object> map = new LinkedHashMap<>();
private final Configuration root;
private final ConfigurationSection parent;
private final String path;
@ -69,7 +69,7 @@ public class MemorySection implements ConfigurationSection {
}
public Set<String> getKeys(boolean deep) {
Set<String> result = new LinkedHashSet<String>();
Set<String> result = new LinkedHashSet<>();
Configuration root = getRoot();
if (root != null && root.options().copyDefaults()) {
@ -86,7 +86,7 @@ public class MemorySection implements ConfigurationSection {
}
public Map<String, Object> getValues(boolean deep) {
Map<String, Object> result = new LinkedHashMap<String, Object>();
Map<String, Object> result = new LinkedHashMap<>();
Configuration root = getRoot();
if (root != null && root.options().copyDefaults()) {
@ -388,10 +388,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<String>(0);
return new ArrayList<>(0);
}
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
for (Object object : list) {
if ((object instanceof String) || (isPrimitiveWrapper(object))) {
@ -406,10 +406,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<Integer>(0);
return new ArrayList<>(0);
}
List<Integer> result = new ArrayList<Integer>();
List<Integer> result = new ArrayList<>();
for (Object object : list) {
if (object instanceof Integer) {
@ -417,10 +417,10 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) {
try {
result.add(Integer.valueOf((String) object));
} catch (Exception ex) {
} catch (Exception ignored) {
}
} else if (object instanceof Character) {
result.add((int) ((Character) object).charValue());
result.add((int) (Character) object);
} else if (object instanceof Number) {
result.add(((Number) object).intValue());
}
@ -433,10 +433,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<Boolean>(0);
return new ArrayList<>(0);
}
List<Boolean> result = new ArrayList<Boolean>();
List<Boolean> result = new ArrayList<>();
for (Object object : list) {
if (object instanceof Boolean) {
@ -457,10 +457,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<Double>(0);
return new ArrayList<>(0);
}
List<Double> result = new ArrayList<Double>();
List<Double> result = new ArrayList<>();
for (Object object : list) {
if (object instanceof Double) {
@ -468,10 +468,10 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) {
try {
result.add(Double.valueOf((String) object));
} catch (Exception ex) {
} catch (Exception ignored) {
}
} else if (object instanceof Character) {
result.add((double) ((Character) object).charValue());
result.add((double) (Character) object);
} else if (object instanceof Number) {
result.add(((Number) object).doubleValue());
}
@ -484,10 +484,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<Float>(0);
return new ArrayList<>(0);
}
List<Float> result = new ArrayList<Float>();
List<Float> result = new ArrayList<>();
for (Object object : list) {
if (object instanceof Float) {
@ -495,10 +495,10 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) {
try {
result.add(Float.valueOf((String) object));
} catch (Exception ex) {
} catch (Exception ignored) {
}
} else if (object instanceof Character) {
result.add((float) ((Character) object).charValue());
result.add((float) (Character) object);
} else if (object instanceof Number) {
result.add(((Number) object).floatValue());
}
@ -511,10 +511,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<Long>(0);
return new ArrayList<>(0);
}
List<Long> result = new ArrayList<Long>();
List<Long> result = new ArrayList<>();
for (Object object : list) {
if (object instanceof Long) {
@ -522,10 +522,10 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) {
try {
result.add(Long.valueOf((String) object));
} catch (Exception ex) {
} catch (Exception ignored) {
}
} else if (object instanceof Character) {
result.add((long) ((Character) object).charValue());
result.add((long) (Character) object);
} else if (object instanceof Number) {
result.add(((Number) object).longValue());
}
@ -538,10 +538,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<Byte>(0);
return new ArrayList<>(0);
}
List<Byte> result = new ArrayList<Byte>();
List<Byte> result = new ArrayList<>();
for (Object object : list) {
if (object instanceof Byte) {
@ -549,7 +549,7 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) {
try {
result.add(Byte.valueOf((String) object));
} catch (Exception ex) {
} catch (Exception ignored) {
}
} else if (object instanceof Character) {
result.add((byte) ((Character) object).charValue());
@ -565,10 +565,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<Character>(0);
return new ArrayList<>(0);
}
List<Character> result = new ArrayList<Character>();
List<Character> result = new ArrayList<>();
for (Object object : list) {
if (object instanceof Character) {
@ -591,10 +591,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<Short>(0);
return new ArrayList<>(0);
}
List<Short> result = new ArrayList<Short>();
List<Short> result = new ArrayList<>();
for (Object object : list) {
if (object instanceof Short) {
@ -602,7 +602,7 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) {
try {
result.add(Short.valueOf((String) object));
} catch (Exception ex) {
} catch (Exception ignored) {
}
} else if (object instanceof Character) {
result.add((short) ((Character) object).charValue());
@ -616,7 +616,7 @@ public class MemorySection implements ConfigurationSection {
public List<Map<?, ?>> getMapList(String path) {
List<?> list = getList(path);
List<Map<?, ?>> result = new ArrayList<Map<?, ?>>();
List<Map<?, ?>> result = new ArrayList<>();
if (list == null) {
return result;

View File

@ -18,6 +18,7 @@ import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.MemoryConfiguration;
@ -58,7 +59,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
final Charset defaultCharset = Charset.defaultCharset();
final String resultString = new String(testBytes, defaultCharset);
final boolean trueUTF = defaultCharset.name().contains("UTF");
UTF8_OVERRIDE = !testString.equals(resultString) || defaultCharset.equals(Charset.forName("US-ASCII"));
UTF8_OVERRIDE = !testString.equals(resultString) || defaultCharset.equals(StandardCharsets.US_ASCII);
SYSTEM_UTF = trueUTF || UTF8_OVERRIDE;
UTF_BIG = trueUTF && UTF8_OVERRIDE;
}
@ -102,12 +103,8 @@ public abstract class FileConfiguration extends MemoryConfiguration {
String data = saveToString();
Writer writer = new OutputStreamWriter(new FileOutputStream(file), UTF8_OVERRIDE && !UTF_BIG ? Charsets.UTF_8 : Charset.defaultCharset());
try {
try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), UTF8_OVERRIDE && !UTF_BIG ? Charsets.UTF_8 : Charset.defaultCharset())) {
writer.write(data);
} finally {
writer.close();
}
}

View File

@ -52,7 +52,7 @@ public class YamlConfiguration extends FileConfiguration {
Map<?, ?> input;
try {
input = (Map<?, ?>) yaml.load(contents);
input = yaml.load(contents);
} catch (YAMLException e) {
throw new InvalidConfigurationException(e);
} catch (ClassCastException e) {
@ -178,10 +178,8 @@ public class YamlConfiguration extends FileConfiguration {
try {
config.load(file);
} catch (FileNotFoundException ex) {
} catch (IOException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
} catch (InvalidConfigurationException ex) {
} catch (FileNotFoundException ignored) {
} catch (IOException | InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
}
@ -210,9 +208,7 @@ public class YamlConfiguration extends FileConfiguration {
try {
config.load(stream);
} catch (IOException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
} catch (InvalidConfigurationException ex) {
} catch (IOException | InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
}
@ -238,9 +234,7 @@ public class YamlConfiguration extends FileConfiguration {
try {
config.load(reader);
} catch (IOException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
} catch (InvalidConfigurationException ex) {
} catch (IOException | InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
}

View File

@ -26,7 +26,7 @@ public class YamlConstructor extends SafeConstructor {
Map<?, ?> raw = (Map<?, ?>) super.construct(node);
if (raw.containsKey(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) {
Map<String, Object> typed = new LinkedHashMap<String, Object>(raw.size());
Map<String, Object> typed = new LinkedHashMap<>(raw.size());
for (Map.Entry<?, ?> entry : raw.entrySet()) {
typed.put(entry.getKey().toString(), entry.getValue());
}

View File

@ -28,7 +28,7 @@ public class YamlRepresenter extends Representer {
@Override
public Node representData(Object data) {
ConfigurationSerializable serializable = (ConfigurationSerializable) data;
Map<String, Object> values = new LinkedHashMap<String, Object>();
Map<String, Object> values = new LinkedHashMap<>();
values.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(serializable.getClass()));
values.putAll(serializable.serialize());

View File

@ -31,5 +31,5 @@ public interface ConfigurationSerializable {
*
* @return Map containing the current state of this class
*/
public Map<String, Object> serialize();
Map<String, Object> serialize();
}

View File

@ -26,7 +26,7 @@ import org.bukkit.util.Vector;
public class ConfigurationSerialization {
public static final String SERIALIZED_TYPE_KEY = "==";
private final Class<? extends ConfigurationSerializable> clazz;
private static Map<String, Class<? extends ConfigurationSerializable>> aliases = new HashMap<String, Class<? extends ConfigurationSerializable>>();
private static Map<String, Class<? extends ConfigurationSerializable>> aliases = new HashMap<>();
static {
registerClass(Vector.class);
@ -55,9 +55,7 @@ public class ConfigurationSerialization {
}
return method;
} catch (NoSuchMethodException ex) {
return null;
} catch (SecurityException ex) {
} catch (NoSuchMethodException | SecurityException ex) {
return null;
}
}
@ -65,9 +63,7 @@ public class ConfigurationSerialization {
protected Constructor<? extends ConfigurationSerializable> getConstructor() {
try {
return clazz.getConstructor(Map.class);
} catch (NoSuchMethodException ex) {
return null;
} catch (SecurityException ex) {
} catch (NoSuchMethodException | SecurityException ex) {
return null;
}
}
@ -77,7 +73,7 @@ public class ConfigurationSerialization {
ConfigurationSerializable result = (ConfigurationSerializable) method.invoke(null, args);
if (result == null) {
Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE, "Could not call method '" + method.toString() + "' of " + clazz + " for deserialization: method returned null");
Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE, "Could not call method '" + method + "' of " + clazz + " for deserialization: method returned null");
} else {
return result;
}
@ -239,7 +235,6 @@ public class ConfigurationSerialization {
*/
public static void unregisterClass(Class<? extends ConfigurationSerializable> clazz) {
while (aliases.values().remove(clazz)) {
;
}
}

View File

@ -18,5 +18,5 @@ public @interface DelegateDeserialization {
*
* @return Delegate class
*/
public Class<? extends ConfigurationSerializable> value();
Class<? extends ConfigurationSerializable> value();
}

View File

@ -30,5 +30,5 @@ public @interface SerializableAs {
*
* @return Name to serialize the class as.
*/
public String value();
String value();
}

View File

@ -1,7 +1,5 @@
package org.bukkit.conversations;
import org.bukkit.command.CommandSender;
/**
* The Conversable interface is used to indicate objects that can have
* conversations.
@ -14,7 +12,7 @@ public interface Conversable {
*
* @return True if a conversation is in progress
*/
public boolean isConversing();
boolean isConversing();
/**
* Accepts input into the active conversation. If no conversation is in
@ -22,7 +20,7 @@ public interface Conversable {
*
* @param input The input message into the conversation
*/
public void acceptConversationInput(String input);
void acceptConversationInput(String input);
/**
* Enters into a dialog with a Conversation object.
@ -31,14 +29,14 @@ public interface Conversable {
* @return True if the conversation should proceed, false if it has been
* enqueued
*/
public boolean beginConversation(Conversation conversation);
boolean beginConversation(Conversation conversation);
/**
* Abandons an active conversation.
*
* @param conversation The conversation to abandon
*/
public void abandonConversation(Conversation conversation);
void abandonConversation(Conversation conversation);
/**
* Abandons an active conversation.
@ -46,12 +44,12 @@ public interface Conversable {
* @param conversation The conversation to abandon
* @param details Details about why the conversation was abandoned
*/
public void abandonConversation(Conversation conversation, ConversationAbandonedEvent details);
void abandonConversation(Conversation conversation, ConversationAbandonedEvent details);
/**
* Sends this sender a message raw
*
* @param message Message to be displayed
*/
public void sendRawMessage(String message);
void sendRawMessage(String message);
}

View File

@ -52,7 +52,7 @@ public class Conversation {
* @param firstPrompt The first prompt in the conversation graph.
*/
public Conversation(Plugin plugin, Conversable forWhom, Prompt firstPrompt) {
this(plugin, forWhom, firstPrompt, new HashMap<Object, Object>());
this(plugin, forWhom, firstPrompt, new HashMap<>());
}
/**
@ -70,8 +70,8 @@ public class Conversation {
this.modal = true;
this.localEchoEnabled = true;
this.prefix = new NullConversationPrefix();
this.cancellers = new ArrayList<ConversationCanceller>();
this.abandonedListeners = new ArrayList<ConversationAbandonedListener>();
this.cancellers = new ArrayList<>();
this.abandonedListeners = new ArrayList<>();
}
/**

View File

@ -11,5 +11,5 @@ public interface ConversationAbandonedListener extends EventListener {
* @param abandonedEvent Contains details about the abandoned
* conversation.
*/
public void conversationAbandoned(ConversationAbandonedEvent abandonedEvent);
void conversationAbandoned(ConversationAbandonedEvent abandonedEvent);
}

View File

@ -11,7 +11,7 @@ public interface ConversationCanceller extends Cloneable {
*
* @param conversation A conversation.
*/
public void setConversation(Conversation conversation);
void setConversation(Conversation conversation);
/**
* Cancels a conversation based on user input.
@ -20,7 +20,7 @@ public interface ConversationCanceller extends Cloneable {
* @param input The input text from the user.
* @return True to cancel the conversation, False otherwise.
*/
public boolean cancelBasedOnInput(ConversationContext context, String input);
boolean cancelBasedOnInput(ConversationContext context, String input);
/**
* Allows the {@link ConversationFactory} to duplicate this
@ -30,5 +30,5 @@ public interface ConversationCanceller extends Cloneable {
*
* @return A clone.
*/
public ConversationCanceller clone();
ConversationCanceller clone();
}

View File

@ -42,10 +42,10 @@ public class ConversationFactory {
localEchoEnabled = true;
prefix = new NullConversationPrefix();
firstPrompt = Prompt.END_OF_CONVERSATION;
initialSessionData = new HashMap<Object, Object>();
initialSessionData = new HashMap<>();
playerOnlyMessage = null;
cancellers = new ArrayList<ConversationCanceller>();
abandonedListeners = new ArrayList<ConversationAbandonedListener>();
cancellers = new ArrayList<>();
abandonedListeners = new ArrayList<>();
}
/**
@ -192,8 +192,7 @@ public class ConversationFactory {
}
//Clone any initial session data
Map<Object, Object> copiedInitialSessionData = new HashMap<Object, Object>();
copiedInitialSessionData.putAll(initialSessionData);
Map<Object, Object> copiedInitialSessionData = new HashMap<>(initialSessionData);
//Build and return a conversation
Conversation conversation = new Conversation(plugin, forWhom, firstPrompt, copiedInitialSessionData);

Some files were not shown because too many files have changed in this diff Show More