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. * 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> * <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 * 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. * Starts timing the execution until {@link #stopTiming()} is called.
* *
* But only if we are on the primary thread. * 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> * <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. * But only if we are on the primary thread.
*/ */
public void stopTimingIfSync(); void stopTimingIfSync();
/** /**
* Stops timing and disregards current timing data. * 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 * 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 * This is broken out to reduce memory usage
*/ */
class TimingData { class TimingData {
static Function<Integer, TimingData> LOADER = new Function<Integer, TimingData>() { static Function<Integer, TimingData> LOADER = TimingData::new;
@Override
public TimingData apply(Integer input) {
return new TimingData(input);
}
};
int id; int id;
int count = 0; int count = 0;
int lagCount = 0; int lagCount = 0;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,10 +3,7 @@ package co.aikar.util;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; 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.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@ -25,14 +25,10 @@ package co.aikar.util;
import com.google.common.base.Function; 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.lang.reflect.Constructor;
import java.util.AbstractMap; import java.util.AbstractMap;
import java.util.Collection; import java.util.Collection;
import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
import java.util.Map; import java.util.Map;
@ -76,7 +72,7 @@ public class LoadingMap <K,V> extends AbstractMap<K, V> {
* @return * @return
*/ */
public static <K, V> Map<K, V> of(Map<K, V> backingMap, Function<K, V> loader) { 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, public static <K, V> Map<K, V> newAutoMap(Map<K, V> backingMap, final Class<? extends K> keyClass,
final Class<? extends V> valueClass) { 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. * Creates a LoadingMap with an auto instantiating loader.
@ -128,7 +124,7 @@ public class LoadingMap <K,V> extends AbstractMap<K, V> {
* @return * @return
*/ */
public static <K, V> Map<K, V> newHashAutoMap(final Class<? extends K> keyClass, final Class<? extends V> valueClass) { 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 * @return
*/ */
public static <K, V> Map<K, V> newHashAutoMap(final Class<? extends K> keyClass, final Class<? extends V> valueClass, int initialCapacity, float loadFactor) { 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 * @return
*/ */
public static <K, V> Map<K, V> newHashMap(Function<K, V> loader) { 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 * @return
*/ */
public static <K, V> Map<K, V> newHashMap(Function<K, V> loader, int initialCapacity, float loadFactor) { 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 * @return
*/ */
public static <K, V> Map<K, V> newIdentityHashMap(Function<K, V> loader) { 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 * @return
*/ */
public static <K, V> Map<K, V> newIdentityHashMap(Function<K, V> loader, int initialCapacity) { 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 @Override
@ -276,7 +272,7 @@ public class LoadingMap <K,V> extends AbstractMap<K, V> {
} }
public LoadingMap<K, V> clone() { 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> { 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 * @return
*/ */
public static <K, V> Map<K, V> of(Map<K, V> map) { 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; package net.techcable.tacospigot.event.entity;
import com.google.common.base.Preconditions;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;

View File

@ -47,14 +47,14 @@ public interface BanEntry {
* *
* @return the target name or IP address * @return the target name or IP address
*/ */
public String getTarget(); String getTarget();
/** /**
* Gets the date this ban entry was created. * Gets the date this ban entry was created.
* *
* @return the creation date * @return the creation date
*/ */
public Date getCreated(); Date getCreated();
/** /**
* Sets the date this ban entry was created. * Sets the date this ban entry was created.
@ -62,7 +62,7 @@ public interface BanEntry {
* @param created the new created date, cannot be null * @param created the new created date, cannot be null
* @see #save() saving changes * @see #save() saving changes
*/ */
public void setCreated(Date created); void setCreated(Date created);
/** /**
* Gets the source of this ban. * Gets the source of this ban.
@ -72,7 +72,7 @@ public interface BanEntry {
* *
* @return the source of the ban * @return the source of the ban
*/ */
public String getSource(); String getSource();
/** /**
* Sets the source of this ban. * Sets the source of this ban.
@ -83,14 +83,14 @@ public interface BanEntry {
* @param source the new source where null values become empty strings * @param source the new source where null values become empty strings
* @see #save() saving changes * @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. * Gets the date this ban expires on, or null for no defined end date.
* *
* @return the expiration date * @return the expiration date
*/ */
public Date getExpiration(); Date getExpiration();
/** /**
* Sets the date this ban expires on. Null values are considered * Sets the date this ban expires on. Null values are considered
@ -100,14 +100,14 @@ public interface BanEntry {
* eternity * eternity
* @see #save() saving changes * @see #save() saving changes
*/ */
public void setExpiration(Date expiration); void setExpiration(Date expiration);
/** /**
* Gets the reason for this ban. * Gets the reason for this ban.
* *
* @return the ban reason, or null if not set * @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. * Sets the reason for this ban. Reasons must not be null.
@ -116,7 +116,7 @@ public interface BanEntry {
* default * default
* @see #save() saving changes * @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. * 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 * Saving the ban entry of an unbanned player will cause the player to be
* banned once again. * 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. * Represents a ban-type that a {@link BanList} may track.
*/ */
public enum Type { enum Type {
/** /**
* Banned player names * Banned player names
*/ */
@ -20,7 +20,6 @@ public interface BanList {
* Banned player IP addresses * Banned player IP addresses
*/ */
IP, IP,
;
} }
/** /**
@ -29,7 +28,7 @@ public interface BanList {
* @param target entry parameter to search for * @param target entry parameter to search for
* @return the corresponding entry, or null if none found * @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 * 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 * @return the entry for the newly created ban, or the entry for the
* (updated) previous ban * (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. * Gets a set containing every {@link BanEntry} in this list.
* *
* @return an immutable set containing every entry tracked by 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 * 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 * @return true if a {@link BanEntry} exists for the name, indicating an
* active ban status, false otherwise * active ban status, false otherwise
*/ */
public boolean isBanned(String target); boolean isBanned(String target);
/** /**
* Removes the specified target from this list, therefore indicating a * 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 * @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 Magic value
*/ */
@Deprecated @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 * Set a block type and data at the specified coordinates without doing
@ -40,7 +40,7 @@ public interface BlockChangeDelegate {
* @deprecated Magic value * @deprecated Magic value
*/ */
@Deprecated @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. * Set a block type at the specified coordinates.
@ -55,7 +55,7 @@ public interface BlockChangeDelegate {
* @deprecated Magic value * @deprecated Magic value
*/ */
@Deprecated @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. * Set a block type and data at the specified coordinates.
@ -71,7 +71,7 @@ public interface BlockChangeDelegate {
* @deprecated Magic value * @deprecated Magic value
*/ */
@Deprecated @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. * Get the block type at the location.
@ -83,14 +83,14 @@ public interface BlockChangeDelegate {
* @deprecated Magic value * @deprecated Magic value
*/ */
@Deprecated @Deprecated
public int getTypeId(int x, int y, int z); int getTypeId(int x, int y, int z);
/** /**
* Gets the height of the world. * Gets the height of the world.
* *
* @return Height of the world * @return Height of the world
*/ */
public int getHeight(); int getHeight();
/** /**
* Checks if the specified block is empty (air) or not. * Checks if the specified block is empty (air) or not.
@ -100,5 +100,5 @@ public interface BlockChangeDelegate {
* @param z Z coordinate * @param z Z coordinate
* @return True if the block is considered empty. * @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. * you need to dynamically convert colour codes from your custom format.
*/ */
public static final char COLOR_CHAR = '\u00A7'; 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 int intCode;
private final char code; private final char code;
@ -237,7 +237,7 @@ public enum ChatColor{
public net.md_5.bungee.api.ChatColor asBungee() { public net.md_5.bungee.api.ChatColor asBungee() {
return net.md_5.bungee.api.ChatColor.RESET; return net.md_5.bungee.api.ChatColor.RESET;
}; }
/** /**
* Gets the char value associated with this color * Gets the char value associated with this color
@ -349,7 +349,7 @@ public enum ChatColor{
ChatColor color = getByChar(c); ChatColor color = getByChar(c);
if (color != null) { if (color != null) {
result = color.toString() + result; result = color + result;
// Once we find a color or reset we can stop searching // Once we find a color or reset we can stop searching
if (color.isColor() || color.equals(RESET)) { 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 { public static Color fromRGB(int rgb) throws IllegalArgumentException {
Validate.isTrue((rgb >> 24) == 0, "Extrenuous data in: ", rgb); 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 { public static Color fromBGR(int bgr) throws IllegalArgumentException {
Validate.isTrue((bgr >> 24) == 0, "Extrenuous data in: ", bgr); 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) { 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 * @return An integer representation of this color, as 0xRRGGBB
*/ */
public int asRGB() { 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 * @return An integer representation of this color, as 0xBBGGRR
*/ */
public int asBGR() { 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. * A creeper-face effect.
*/ */
CREEPER, CREEPER,
;
} }
/** /**

View File

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

View File

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

View File

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

View File

@ -15,7 +15,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
* *
* @return true if they are online * @return true if they are online
*/ */
public boolean isOnline(); boolean isOnline();
/** /**
* Returns the name of this player * 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 * @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 * Returns the UUID of this player
* *
* @return Player UUID * @return Player UUID
*/ */
public UUID getUniqueId(); UUID getUniqueId();
/** /**
* Checks if this player is banned or not * Checks if this player is banned or not
* *
* @return true if banned, otherwise false * @return true if banned, otherwise false
*/ */
public boolean isBanned(); boolean isBanned();
/** /**
* Bans or unbans this player * Bans or unbans this player
@ -50,21 +50,21 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
* functionality * functionality
*/ */
@Deprecated @Deprecated
public void setBanned(boolean banned); void setBanned(boolean banned);
/** /**
* Checks if this player is whitelisted or not * Checks if this player is whitelisted or not
* *
* @return true if whitelisted * @return true if whitelisted
*/ */
public boolean isWhitelisted(); boolean isWhitelisted();
/** /**
* Sets if this player is whitelisted or not * Sets if this player is whitelisted or not
* *
* @param value true if whitelisted * @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 * 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 * @return Online player
*/ */
public Player getPlayer(); Player getPlayer();
/** /**
* Gets the first date and time that this player was witnessed on this * 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 * @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 * 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 * @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. * Checks if this player has played on this server before.
* *
* @return True if the player has played before, otherwise false * @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 * 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. * @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. * This is a custom Plugin portal.
*/ */
CUSTOM; CUSTOM
} }

View File

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

View File

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

View File

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

View File

@ -17,14 +17,14 @@ public interface TravelAgent {
* location * location
* @return this travel agent * @return this travel agent
*/ */
public TravelAgent setSearchRadius(int radius); TravelAgent setSearchRadius(int radius);
/** /**
* Gets the search radius value for finding an available portal. * Gets the search radius value for finding an available portal.
* *
* @return the currently set search radius * @return the currently set search radius
*/ */
public int getSearchRadius(); int getSearchRadius();
/** /**
* Sets the maximum radius from the given location to create a portal. * 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 * @param radius the radius in which to create a portal from the location
* @return this travel agent * @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. * Gets the maximum radius from the given location to create a portal.
* *
* @return the currently set creation radius * @return the currently set creation radius
*/ */
public int getCreationRadius(); int getCreationRadius();
/** /**
* Returns whether the TravelAgent will attempt to create a destination * 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 * @return whether the TravelAgent should create a destination portal or
* not * not
*/ */
public boolean getCanCreatePortal(); boolean getCanCreatePortal();
/** /**
* Sets whether the TravelAgent should attempt to create a destination * 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 * @param create Sets whether the TravelAgent should create a destination
* portal or not * 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 * 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 * location passed to the method if unsuccessful
* @see #createPortal(Location) * @see #createPortal(Location)
*/ */
public Location findOrCreate(Location location); Location findOrCreate(Location location);
/** /**
* Attempt to find a portal near the given 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 * @param location the desired location of the portal
* @return the location of the nearest portal to the location * @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. * Attempt to create a portal near the given location.
@ -90,5 +90,5 @@ public interface TravelAgent {
* @param location the desired location of the portal * @param location the desired location of the portal
* @return true if a portal was successfully created * @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. * 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. * 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 weather, clouds but no rain.
*/ */
CLEAR, CLEAR,
;
} }

View File

@ -32,7 +32,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @see #getBlockTypeIdAt(int, int, int) Returns the current type ID of * @see #getBlockTypeIdAt(int, int, int) Returns the current type ID of
* the block * 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} * 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 * @see #getBlockTypeIdAt(org.bukkit.Location) Returns the current type ID
* of the block * of the block
*/ */
public Block getBlockAt(Location location); Block getBlockAt(Location location);
/** /**
* Gets the block type ID at the given coordinates * Gets the block type ID at the given coordinates
@ -56,7 +56,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @deprecated Magic value * @deprecated Magic value
*/ */
@Deprecated @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} * Gets the block type ID at the given {@link Location}
@ -68,7 +68,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @deprecated Magic value * @deprecated Magic value
*/ */
@Deprecated @Deprecated
public int getBlockTypeIdAt(Location location); int getBlockTypeIdAt(Location location);
/** /**
* Gets the highest non-air coordinate at the given coordinates * 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 * @param z Z-coordinate of the blocks
* @return Y-coordinate of the highest non-air block * @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} * 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 * @param location Location of the blocks
* @return Y-coordinate of the highest non-air block * @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 * 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 * @param z Z-coordinate of the block
* @return Highest non-empty 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 * 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 * @param location Coordinates to get the highest block
* @return Highest non-empty block * @return Highest non-empty block
*/ */
public Block getHighestBlockAt(Location location); Block getHighestBlockAt(Location location);
/** /**
* Gets the {@link Chunk} at the given coordinates * 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 * @param z Z-coordinate of the chunk
* @return Chunk at the given coordinates * @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} * 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 * @param location Location of the chunk
* @return Chunk at the given location * @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} * 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 * @param block Block to get the containing chunk from
* @return The chunk that contains the given block * @return The chunk that contains the given block
*/ */
public Chunk getChunkAt(Block block); Chunk getChunkAt(Block block);
// PaperSpigot start - Async chunk load API // PaperSpigot start - Async chunk load API
public static interface ChunkLoadCallback { interface ChunkLoadCallback {
public void onLoad(Chunk chunk); void onLoad(Chunk chunk);
} }
public void getChunkAtAsync(int x, int z, ChunkLoadCallback cb); void getChunkAtAsync(int x, int z, ChunkLoadCallback cb);
public void getChunkAtAsync(Location location, ChunkLoadCallback cb); void getChunkAtAsync(Location location, ChunkLoadCallback cb);
public void getChunkAtAsync(Block block, ChunkLoadCallback cb); void getChunkAtAsync(Block block, ChunkLoadCallback cb);
// PaperSpigot end // PaperSpigot end
/** /**
@ -144,21 +144,21 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param chunk The chunk to check * @param chunk The chunk to check
* @return true if the chunk is loaded, otherwise false * @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 * Gets an array of all loaded {@link Chunk}s
* *
* @return Chunk[] containing all loaded chunks * @return Chunk[] containing all loaded chunks
*/ */
public Chunk[] getLoadedChunks(); Chunk[] getLoadedChunks();
/** /**
* Loads the specified {@link Chunk} * Loads the specified {@link Chunk}
* *
* @param chunk The chunk to load * @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 * 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 * @param z Z-coordinate of the chunk
* @return true if the chunk is loaded, otherwise false * @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 * 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, * @return true if the chunk is loaded and in use by one or more players,
* otherwise false * otherwise false
*/ */
public boolean isChunkInUse(int x, int z); boolean isChunkInUse(int x, int z);
/** /**
* Loads the {@link Chunk} at the specified coordinates * 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 x X-coordinate of the chunk
* @param z Z-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 * Loads the {@link Chunk} at the specified coordinates
@ -202,7 +202,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* already exist * already exist
* @return true if the chunk has loaded successfully, otherwise false * @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 * 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 * @param chunk the chunk to unload
* @return true if the chunk has unloaded successfully, otherwise false * @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 * 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 * @param z Z-coordinate of the chunk
* @return true if the chunk has unloaded successfully, otherwise false * @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 * 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 * @param save Whether or not to save the chunk
* @return true if the chunk has unloaded successfully, otherwise false * @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 * Unloads and optionally saves the {@link Chunk} at the specified
@ -252,7 +252,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* nearby * nearby
* @return true if the chunk has unloaded successfully, otherwise false * @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 * 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 * @param z Z-coordinate of the chunk
* @return true is the queue attempt was successful, otherwise false * @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 * 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 * @param safe Controls whether to queue the chunk when players are nearby
* @return Whether the chunk was actually queued * @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 * 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 * @param z Z-coordinate of the chunk
* @return Whether the chunk was actually regenerated * @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 * 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 This method is not guaranteed to work suitably across all client implementations.
*/ */
@Deprecated @Deprecated
public boolean refreshChunk(int x, int z); boolean refreshChunk(int x, int z);
/** /**
* Drops an item at the specified {@link Location} * Drops an item at the specified {@link Location}
@ -305,7 +305,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param item ItemStack to drop * @param item ItemStack to drop
* @return ItemDrop entity created as a result of this method * @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 * 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 * @param item ItemStack to drop
* @return ItemDrop entity created as a result of this method * @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} * 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 * @param spread Spread of the arrow. A recommend spread is 12
* @return Arrow entity spawned as a result of this method * @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} * 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 * @param type Type of the tree to create
* @return true if the tree was created successfully, otherwise false * @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} * Creates a tree at the given {@link Location}
@ -345,7 +345,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* this method * this method
* @return true if the tree was created successfully, otherwise false * @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} * Creates a entity at the given {@link Location}
@ -354,7 +354,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param type The entity to spawn * @param type The entity to spawn
* @return Resulting Entity of this method, or null if it was unsuccessful * @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} * Creates a creature at the given {@link Location}
@ -367,7 +367,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* #spawnEntity(Location, EntityType) spawnEntity} instead. * #spawnEntity(Location, EntityType) spawnEntity} instead.
*/ */
@Deprecated @Deprecated
public LivingEntity spawnCreature(Location loc, EntityType type); LivingEntity spawnCreature(Location loc, EntityType type);
/** /**
* Creates a creature at the given {@link Location} * Creates a creature at the given {@link Location}
@ -378,7 +378,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* unsuccessful * unsuccessful
*/ */
@Deprecated @Deprecated
public LivingEntity spawnCreature(Location loc, CreatureType type); LivingEntity spawnCreature(Location loc, CreatureType type);
/** /**
* Strikes lightning at the given {@link Location} * Strikes lightning at the given {@link Location}
@ -386,7 +386,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param loc The location to strike lightning * @param loc The location to strike lightning
* @return The lightning entity. * @return The lightning entity.
*/ */
public LightningStrike strikeLightning(Location loc); LightningStrike strikeLightning(Location loc);
/** /**
* Strikes lightning at the given {@link Location} without doing damage * 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 * @param loc The location to strike lightning
* @return The lightning entity. * @return The lightning entity.
*/ */
public LightningStrike strikeLightningEffect(Location loc); LightningStrike strikeLightningEffect(Location loc);
/** /**
* Get a list of all entities in this World * Get a list of all entities in this World
* *
* @return A List of all Entities currently residing 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 * Get a list of all living entities in this World
* *
* @return A List of all LivingEntities currently residing 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 * 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 * match the given class/interface
*/ */
@Deprecated @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 * 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 * @return A List of all Entities currently residing in this world that
* match the given class/interface * 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 * 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 * @return A List of all Entities currently residing in this world that
* match one or more of the given classes/interfaces * 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 * Get a list of all players in this World
* *
* @return A list of all Players currently residing 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. * 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 * @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. * @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 * Gets the unique name of this world
* *
* @return Name of this world * @return Name of this world
*/ */
public String getName(); String getName();
/** /**
* Gets the Unique ID of this world * Gets the Unique ID of this world
* *
* @return 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 * Gets the default spawn {@link Location} of this world
* *
* @return The spawn location of this world * @return The spawn location of this world
*/ */
public Location getSpawnLocation(); Location getSpawnLocation();
/** /**
* Sets the spawn location of the world * Sets the spawn location of the world
@ -492,7 +492,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z coordinate * @param z Z coordinate
* @return True if it was successfully set. * @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 * Sets the spawn location of the world
@ -502,14 +502,14 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z coordinate * @param z Z coordinate
* @return True if it was successfully set. * @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 * Sets the spawn location of the world
* *
* @param location Location of the spawn * @param location Location of the spawn
* @return True if it was successfully set. * @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. * Gets the relative in-game time of this world.
@ -519,7 +519,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return The current relative time * @return The current relative time
* @see #getFullTime() Returns an absolute time of this world * @see #getFullTime() Returns an absolute time of this world
*/ */
public long getTime(); long getTime();
/** /**
* Sets the relative in-game time on the server. * Sets the relative in-game time on the server.
@ -534,7 +534,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* hours*1000) * hours*1000)
* @see #setFullTime(long) Sets the absolute time of this world * @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 * Gets the full in-game time on this world
@ -542,7 +542,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return The current absolute time * @return The current absolute time
* @see #getTime() Returns a relative time of this world * @see #getTime() Returns a relative time of this world
*/ */
public long getFullTime(); long getFullTime();
/** /**
* Sets the in-game time on the server * 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 * @param time The new absolute time to set this world to
* @see #setTime(long) Sets the relative time of this world * @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. * Returns whether the world has an ongoing storm.
* *
* @return Whether there is 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 * 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 * @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. * Get the remaining time in ticks of the current conditions.
* *
* @return Time in ticks * @return Time in ticks
*/ */
public int getWeatherDuration(); int getWeatherDuration();
/** /**
* Set the remaining time in ticks of the current conditions. * Set the remaining time in ticks of the current conditions.
* *
* @param duration Time in ticks * @param duration Time in ticks
*/ */
public void setWeatherDuration(int duration); void setWeatherDuration(int duration);
/** /**
* Returns whether there is thunder. * Returns whether there is thunder.
* *
* @return Whether there is thunder * @return Whether there is thunder
*/ */
public boolean isThundering(); boolean isThundering();
/** /**
* Set whether it is thundering. * Set whether it is thundering.
* *
* @param thundering Whether it is thundering * @param thundering Whether it is thundering
*/ */
public void setThundering(boolean thundering); void setThundering(boolean thundering);
/** /**
* Get the thundering duration. * Get the thundering duration.
* *
* @return Duration in ticks * @return Duration in ticks
*/ */
public int getThunderDuration(); int getThunderDuration();
/** /**
* Set the thundering duration. * Set the thundering duration.
* *
* @param duration Duration in ticks * @param duration Duration in ticks
*/ */
public void setThunderDuration(int duration); void setThunderDuration(int duration);
/** /**
* Creates explosion at given coordinates with given power * 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 * @param power The power of explosion, where 4F is TNT
* @return false if explosion was canceled, otherwise true * @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 * 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 * @param setFire Whether or not to set blocks on fire
* @return false if explosion was canceled, otherwise true * @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 * 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 * @param breakBlocks Whether or not to have blocks be destroyed
* @return false if explosion was canceled, otherwise true * @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 * 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 * @param power The power of explosion, where 4F is TNT
* @return false if explosion was canceled, otherwise true * @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 * 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 * @param setFire Whether or not to set blocks on fire
* @return false if explosion was canceled, otherwise true * @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 * Gets the {@link Environment} type of this world
* *
* @return This worlds Environment type * @return This worlds Environment type
*/ */
public Environment getEnvironment(); Environment getEnvironment();
/** /**
* Gets the Seed for this world. * Gets the Seed for this world.
* *
* @return This worlds Seed * @return This worlds Seed
*/ */
public long getSeed(); long getSeed();
/** /**
* Gets the current PVP setting for this world. * Gets the current PVP setting for this world.
* *
* @return True if PVP is enabled * @return True if PVP is enabled
*/ */
public boolean getPVP(); boolean getPVP();
/** /**
* Sets the PVP setting for this world. * Sets the PVP setting for this world.
* *
* @param pvp True/False whether PVP should be Enabled. * @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 * Gets the chunk generator for this world
* *
* @return ChunkGenerator associated with this world * @return ChunkGenerator associated with this world
*/ */
public ChunkGenerator getGenerator(); ChunkGenerator getGenerator();
/** /**
* Saves world to disk * Saves world to disk
*/ */
public void save(); void save();
/** /**
* Gets a list of all applied {@link BlockPopulator}s for this World * Gets a list of all applied {@link BlockPopulator}s for this World
* *
* @return List containing any or none BlockPopulators * @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} * 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 * @throws IllegalArgumentException if either parameter is null or the
* {@link Entity} requested cannot be spawned * {@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 * 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 Magic value
*/ */
@Deprecated @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 * 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 Magic value
*/ */
@Deprecated @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 * 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 effect the {@link Effect}
* @param data a data bit needed for some effects * @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. * 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 data a data bit needed for some effects
* @param radius the radius around the location * @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 * 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 effect the {@link Effect}
* @param data a data bit needed for some effects * @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. * 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 data a data bit needed for some effects
* @param radius the radius around the location * @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 * 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 * raw biome temperature and rainfall
* @return The empty snapshot. * @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. * 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 * @param allowAnimals - if true, animals are allowed to spawn in this
* world. * world.
*/ */
public void setSpawnFlags(boolean allowMonsters, boolean allowAnimals); void setSpawnFlags(boolean allowMonsters, boolean allowAnimals);
/** /**
* Gets whether animals can spawn in this world. * Gets whether animals can spawn in this world.
* *
* @return 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. * Gets whether monsters can spawn in this world.
* *
* @return 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. * 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 * @param z Z coordinate of the block
* @return Temperature of the requested 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. * 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 * @param z Z coordinate of the block
* @return Humidity of the requested 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. * Gets the maximum height of this world.
@ -898,7 +898,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* *
* @return Maximum height of the world * @return Maximum height of the world
*/ */
public int getMaxHeight(); int getMaxHeight();
/** /**
* Gets the sea level for this world. * Gets the sea level for this world.
@ -907,7 +907,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* *
* @return Sea level * @return Sea level
*/ */
public int getSeaLevel(); int getSeaLevel();
/** /**
* Gets whether the world's spawn area should be kept loaded into memory * 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. * @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 * 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 * @param keepLoaded if true then the world's spawn area will be kept
* loaded into memory. * loaded into memory.
*/ */
public void setKeepSpawnInMemory(boolean keepLoaded); void setKeepSpawnInMemory(boolean keepLoaded);
/** /**
* Gets whether or not the world will automatically save * Gets whether or not the world will automatically save
* *
* @return true if the world will automatically save, otherwise false * @return true if the world will automatically save, otherwise false
*/ */
public boolean isAutoSave(); boolean isAutoSave();
/** /**
* Sets whether or not the world will automatically save * 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 * @param value true if the world should automatically save, otherwise
* false * false
*/ */
public void setAutoSave(boolean value); void setAutoSave(boolean value);
/** /**
* Sets the Difficulty of the world. * Sets the Difficulty of the world.
* *
* @param difficulty the new difficulty you want to set the world to * @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. * Gets the Difficulty of the world.
* *
* @return The difficulty of the world. * @return The difficulty of the world.
*/ */
public Difficulty getDifficulty(); Difficulty getDifficulty();
/** /**
* Gets the folder of this world on disk. * Gets the folder of this world on disk.
* *
* @return The folder of this world. * @return The folder of this world.
*/ */
public File getWorldFolder(); File getWorldFolder();
/** /**
* Gets the type of this world. * Gets the type of this world.
* *
* @return Type of this world. * @return Type of this world.
*/ */
public WorldType getWorldType(); WorldType getWorldType();
/** /**
* Gets whether or not structures are being generated. * Gets whether or not structures are being generated.
* *
* @return True if 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 * 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 * @return The world's ticks per animal spawns value
*/ */
public long getTicksPerAnimalSpawns(); long getTicksPerAnimalSpawns();
/** /**
* Sets the world's ticks per animal spawns value * 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 * @param ticksPerAnimalSpawns the ticks per animal spawns value you want
* to set the world to * to set the world to
*/ */
public void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns); void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns);
/** /**
* Gets the world's ticks per monster spawns value * 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 * @return The world's ticks per monster spawns value
*/ */
public long getTicksPerMonsterSpawns(); long getTicksPerMonsterSpawns();
/** /**
* Sets the world's ticks per monster spawns value * 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 * @param ticksPerMonsterSpawns the ticks per monster spawns value you
* want to set the world to * 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 * 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 * @return An array of rules
*/ */
public String[] getGameRules(); String[] getGameRules();
/** /**
* Gets the current state of the specified rule * 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 * @param rule Rule to look up value of
* @return String value of rule * @return String value of rule
*/ */
public String getGameRuleValue(String rule); String getGameRuleValue(String rule);
/** /**
* Set the specified gamerule to specified value. * Set the specified gamerule to specified value.
@ -1199,7 +1199,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param value Value to set rule to * @param value Value to set rule to
* @return True if rule was set * @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 * Checks if string is a valid game rule
@ -1207,10 +1207,10 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param rule Rule to check * @param rule Rule to check
* @return True if rule exists * @return True if rule exists
*/ */
public boolean isGameRule(String rule); boolean isGameRule(String rule);
// Spigot start // Spigot start
public class Spigot class Spigot
{ {
/** /**
@ -1288,12 +1288,12 @@ public interface World extends PluginMessageRecipient, Metadatable {
* *
* @return The world border for this world. * @return The world border for this world.
*/ */
public WorldBorder getWorldBorder(); WorldBorder getWorldBorder();
/** /**
* Represents various map environment types that a world may be * Represents various map environment types that a world may be
*/ */
public enum Environment { enum Environment {
/** /**
* Represents the "normal"/"surface world" map * Represents the "normal"/"surface world" map
@ -1309,7 +1309,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
THE_END(1); THE_END(1);
private final int id; 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) { private Environment(int id) {
this.id = id; this.id = id;

View File

@ -5,21 +5,21 @@ public interface WorldBorder {
/** /**
* Resets the border to default values. * Resets the border to default values.
*/ */
public void reset(); void reset();
/** /**
* Gets the current side length of the border. * Gets the current side length of the border.
* *
* @return 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. * Sets the border to a square region with the specified side length in blocks.
* *
* @param newSize The new size of the border. * @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. * 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 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. * @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. * Gets the current border center.
* *
* @return The current border center. * @return The current border center.
*/ */
public Location getCenter(); Location getCenter();
/** /**
* Sets the new border center. * Sets the new border center.
@ -42,68 +42,68 @@ public interface WorldBorder {
* @param x The new center x-coordinate. * @param x The new center x-coordinate.
* @param z The new center z-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. * Sets the new border center.
* *
* @param location The new location of the border center. (Only x/z used) * @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. * Gets the current border damage buffer.
* *
* @return 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. * 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.) * @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. * Gets the current border damage amount.
* *
* @return 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. * 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.) * @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. * Gets the current border warning time in seconds.
* *
* @return 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. * 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.) * @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. * Gets the current border warning distance.
* *
* @return 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. * 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.) * @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 Magic value
*/ */
@Deprecated @Deprecated
public byte getRawData(); byte getRawData();
/** /**
* @param data The new data value for the block. * @param data The new data value for the block.
* @deprecated Magic value * @deprecated Magic value
*/ */
@Deprecated @Deprecated
public void setRawData(byte data); void setRawData(byte data);
/** /**
* Returns whether this state is placed in the world. * 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); 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. * @return Command that this CommandBlock will run when powered.
*/ */
public String getCommand(); String getCommand();
/** /**
* Sets the command that this CommandBlock will run when powered. * 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. * @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 * 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. * @return Name of this CommandBlock.
*/ */
public String getName(); String getName();
/** /**
* Sets the name of this CommandBlock. The name is used with commands * 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. * @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 In favour of {@link #getSpawnedType()}.
*/ */
@Deprecated @Deprecated
public CreatureType getCreatureType(); CreatureType getCreatureType();
/** /**
* Get the spawner's creature type. * Get the spawner's creature type.
* *
* @return The creature type. * @return The creature type.
*/ */
public EntityType getSpawnedType(); EntityType getSpawnedType();
/** /**
* Set the spawner's creature type. * Set the spawner's creature type.
* *
* @param creatureType The creature type. * @param creatureType The creature type.
*/ */
public void setSpawnedType(EntityType creatureType); void setSpawnedType(EntityType creatureType);
/** /**
* Set the spawner creature type. * Set the spawner creature type.
@ -38,7 +38,7 @@ public interface CreatureSpawner extends BlockState {
* @deprecated In favour of {@link #setSpawnedType(EntityType)}. * @deprecated In favour of {@link #setSpawnedType(EntityType)}.
*/ */
@Deprecated @Deprecated
public void setCreatureType(CreatureType creatureType); void setCreatureType(CreatureType creatureType);
/** /**
* Get the spawner's creature type. * Get the spawner's creature type.
@ -47,21 +47,21 @@ public interface CreatureSpawner extends BlockState {
* @deprecated Use {@link #getCreatureTypeName()}. * @deprecated Use {@link #getCreatureTypeName()}.
*/ */
@Deprecated @Deprecated
public String getCreatureTypeId(); String getCreatureTypeId();
/** /**
* Set the spawner mob type. * Set the spawner mob type.
* *
* @param creatureType The creature type's name. * @param creatureType The creature type's name.
*/ */
public void setCreatureTypeByName(String creatureType); void setCreatureTypeByName(String creatureType);
/** /**
* Get the spawner's creature type. * Get the spawner's creature type.
* *
* @return The creature type's name. * @return The creature type's name.
*/ */
public String getCreatureTypeName(); String getCreatureTypeName();
/** /**
* Set the spawner mob type. * Set the spawner mob type.
@ -70,19 +70,19 @@ public interface CreatureSpawner extends BlockState {
* @deprecated Use {@link #setCreatureTypeByName(String)}. * @deprecated Use {@link #setCreatureTypeByName(String)}.
*/ */
@Deprecated @Deprecated
public void setCreatureTypeId(String creatureType); void setCreatureTypeId(String creatureType);
/** /**
* Get the spawner's delay. * Get the spawner's delay.
* *
* @return The delay. * @return The delay.
*/ */
public int getDelay(); int getDelay();
/** /**
* Set the spawner's delay. * Set the spawner's delay.
* *
* @param delay The 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 * @return a BlockProjectileSource if valid, otherwise null
*/ */
public BlockProjectileSource getBlockProjectileSource(); BlockProjectileSource getBlockProjectileSource();
/** /**
* Attempts to dispense the contents of this block. * Attempts to dispense the contents of this block.
@ -23,5 +23,5 @@ public interface Dispenser extends BlockState, ContainerBlock {
* *
* @return true if successful, otherwise false * @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 * ContainerBlock, the randomly selected ItemStack is dropped on
* the ground in the form of an {@link org.bukkit.entity.Item Item}. * 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 * @return Burn time
*/ */
public short getBurnTime(); short getBurnTime();
/** /**
* Set burn time. * Set burn time.
* *
* @param burnTime Burn time * @param burnTime Burn time
*/ */
public void setBurnTime(short burnTime); void setBurnTime(short burnTime);
/** /**
* Get cook time. * Get cook time.
* *
* @return Cook time * @return Cook time
*/ */
public short getCookTime(); short getCookTime();
/** /**
* Set cook time. * Set cook time.
* *
* @param cookTime 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 * @return The record Material, or AIR if none is playing
*/ */
public Material getPlaying(); Material getPlaying();
/** /**
* Set the record currently playing * Set the record currently playing
* *
* @param record The record Material, or null/AIR to stop 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 * Check if the jukebox is currently playing a record
* *
* @return True if there is a record playing * @return True if there is a record playing
*/ */
public boolean isPlaying(); boolean isPlaying();
/** /**
* Stop the jukebox playing and eject the current record * Stop the jukebox playing and eject the current record
* *
* @return True if a record was ejected; false if there was none playing * @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. * @return The note.
*/ */
public Note getNote(); Note getNote();
/** /**
* Gets the note. * Gets the note.
@ -22,14 +22,14 @@ public interface NoteBlock extends BlockState {
* @deprecated Magic value * @deprecated Magic value
*/ */
@Deprecated @Deprecated
public byte getRawNote(); byte getRawNote();
/** /**
* Set the note. * Set the note.
* *
* @param note The note. * @param note The note.
*/ */
public void setNote(Note note); void setNote(Note note);
/** /**
* Set the note. * Set the note.
@ -38,7 +38,7 @@ public interface NoteBlock extends BlockState {
* @deprecated Magic value * @deprecated Magic value
*/ */
@Deprecated @Deprecated
public void setRawNote(byte note); void setRawNote(byte note);
/** /**
* Attempts to play the note at block * Attempts to play the note at block
@ -47,7 +47,7 @@ public interface NoteBlock extends BlockState {
* *
* @return true if successful, otherwise false * @return true if successful, otherwise false
*/ */
public boolean play(); boolean play();
/** /**
* Plays an arbitrary note with an arbitrary instrument * Plays an arbitrary note with an arbitrary instrument
@ -58,7 +58,7 @@ public interface NoteBlock extends BlockState {
* @deprecated Magic value * @deprecated Magic value
*/ */
@Deprecated @Deprecated
public boolean play(byte instrument, byte note); boolean play(byte instrument, byte note);
/** /**
* Plays an arbitrary note with an arbitrary instrument * Plays an arbitrary note with an arbitrary instrument
@ -68,5 +68,5 @@ public interface NoteBlock extends BlockState {
* @return true if successful, otherwise false * @return true if successful, otherwise false
* @see Instrument Note * @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); BLOCK(2);
private int id; private int id;
private static Map<Integer, PistonMoveReaction> byId = new HashMap<Integer, PistonMoveReaction>(); private static Map<Integer, PistonMoveReaction> byId = new HashMap<>();
static { static {
for (PistonMoveReaction reaction : PistonMoveReaction.values()) { for (PistonMoveReaction reaction : PistonMoveReaction.values()) {
byId.put(reaction.id, reaction); 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 * @return Array of Strings containing each line of text
*/ */
public String[] getLines(); String[] getLines();
/** /**
* Gets the line of text at the specified index. * 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 * @throws IndexOutOfBoundsException Thrown when the line does not exist
* @return Text on the given line * @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. * 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 * @param line New text to set at the specified index
* @throws IndexOutOfBoundsException If the index is out of the range 0..3 * @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 * @return true if the skull has an owner
*/ */
public boolean hasOwner(); boolean hasOwner();
/** /**
* Gets the owner of the skull, if one exists * 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 * @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 * Sets the owner of the skull
@ -30,33 +30,33 @@ public interface Skull extends BlockState {
* @param name the new owner of the skull * @param name the new owner of the skull
* @return true if the owner was successfully set * @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 * Gets the rotation of the skull in the world
* *
* @return the rotation of the skull * @return the rotation of the skull
*/ */
public BlockFace getRotation(); BlockFace getRotation();
/** /**
* Sets the rotation of the skull in the world * Sets the rotation of the skull in the world
* *
* @param rotation the rotation of the skull * @param rotation the rotation of the skull
*/ */
public void setRotation(BlockFace rotation); void setRotation(BlockFace rotation);
/** /**
* Gets the type of skull * Gets the type of skull
* *
* @return the type of skull * @return the type of skull
*/ */
public SkullType getSkullType(); SkullType getSkullType();
/** /**
* Sets the type of skull * Sets the type of skull
* *
* @param skullType 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"); MOJANG("moj");
private final String identifier; 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 { static {
for (PatternType p : values()) { for (PatternType p : values()) {

View File

@ -9,5 +9,5 @@ public interface BlockCommandSender extends CommandSender {
* *
* @return Block for the command sender * @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 public String getTimingName() {return getName();} // Spigot
protected Command(String name) { 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) { protected Command(String name, String description, String usageMessage, List<String> aliases) {
@ -46,7 +46,7 @@ public abstract class Command {
this.description = description; this.description = description;
this.usageMessage = usageMessage; this.usageMessage = usageMessage;
this.aliases = aliases; 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; 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()) { for (Player player : sender.getServer().getOnlinePlayers()) {
String name = player.getName(); String name = player.getName();
if ((senderPlayer == null || senderPlayer.canSee(player)) && StringUtil.startsWithIgnoreCase(name, lastWord)) { 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; return matchedPlayers;
} }
@ -289,7 +289,7 @@ public abstract class Command {
public boolean unregister(CommandMap commandMap) { public boolean unregister(CommandMap commandMap) {
if (allowChangesFrom(commandMap)) { if (allowChangesFrom(commandMap)) {
this.commandMap = null; this.commandMap = null;
this.activeAliases = new ArrayList<String>(this.aliases); this.activeAliases = new ArrayList<>(this.aliases);
this.label = this.nextLabel; this.label = this.nextLabel;
return true; return true;
} }
@ -359,7 +359,7 @@ public abstract class Command {
public Command setAliases(List<String> aliases) { public Command setAliases(List<String> aliases) {
this.aliases = aliases; this.aliases = aliases;
if (!isRegistered()) { if (!isRegistered()) {
this.activeAliases = new ArrayList<String>(aliases); this.activeAliases = new ArrayList<>(aliases);
} }
return this; return this;
} }

View File

@ -14,5 +14,5 @@ public interface CommandExecutor {
* @param args Passed command arguments * @param args Passed command arguments
* @return true if a valid command, otherwise false * @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 * a ':' one or more times to make the command unique
* @param commands a list of commands to register * @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 * 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 * otherwise, which indicates the fallbackPrefix was used one or more
* times * 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 * 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 * otherwise, which indicates the fallbackPrefix was used one or more
* times * times
*/ */
public boolean register(String fallbackPrefix, Command command); boolean register(String fallbackPrefix, Command command);
/** /**
* Looks for the requested command and executes it if found. * 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 * @throws CommandException Thrown when the executor for the given command
* fails with an unhandled exception * 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. * Clears all registered commands.
*/ */
public void clearCommands(); void clearCommands();
/** /**
* Gets the command registered to the specified name * 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 * @return Command with the specified name or null if a command with that
* label doesn't exist * 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 * command fails with an unhandled exception
* @throws IllegalArgumentException if either sender or cmdLine are null * @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 * @param message Message to be displayed
*/ */
public void sendMessage(String message); void sendMessage(String message);
/** /**
* Sends this sender multiple messages * Sends this sender multiple messages
* *
* @param messages An array of messages to be displayed * @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 * Returns the server instance that this command is running on
* *
* @return Server instance * @return Server instance
*/ */
public Server getServer(); Server getServer();
/** /**
* Gets the name of this command sender * Gets the name of this command sender
* *
* @return Name of the sender * @return Name of the sender
*/ */
public String getName(); String getName();
// Paper start // Paper start
/** /**

View File

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

View File

@ -11,7 +11,7 @@ import org.bukkit.plugin.Plugin;
public class PluginCommandYamlParser { public class PluginCommandYamlParser {
public static List<Command> parse(Plugin plugin) { 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(); Map<String, Map<String, Object>> map = plugin.getDescription().getCommands();
@ -40,19 +40,19 @@ public class PluginCommandYamlParser {
} }
if (aliases != null) { if (aliases != null) {
List<String> aliasList = new ArrayList<String>(); List<String> aliasList = new ArrayList<>();
if (aliases instanceof List) { if (aliases instanceof List) {
for (Object o : (List<?>) aliases) { for (Object o : (List<?>) aliases) {
if (o.toString().contains(":")) { 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; continue;
} }
aliasList.add(o.toString()); aliasList.add(o.toString());
} }
} else { } else {
if (aliases.toString().contains(":")) { 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 { } else {
aliasList.add(aliases.toString()); aliasList.add(aliases.toString());
} }

View File

@ -15,5 +15,5 @@ public interface PluginIdentifiableCommand {
* *
* @return Plugin that owns this 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 { public class SimpleCommandMap implements CommandMap {
private static final Pattern PATTERN_ON_SPACE = Pattern.compile(" ", Pattern.LITERAL); 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; private final Server server;
public SimpleCommandMap(final Server server) { public SimpleCommandMap(final Server server) {
@ -167,8 +167,7 @@ public class SimpleCommandMap implements CommandMap {
} }
public Command getCommand(String name) { public Command getCommand(String name) {
Command target = knownCommands.get(name.toLowerCase()); return knownCommands.get(name.toLowerCase());
return target;
} }
public List<String> tabComplete(CommandSender sender, String cmdLine) { public List<String> tabComplete(CommandSender sender, String cmdLine) {
@ -186,7 +185,7 @@ public class SimpleCommandMap implements CommandMap {
int spaceIndex = cmdLine.indexOf(' '); int spaceIndex = cmdLine.indexOf(' ');
if (spaceIndex == -1) { if (spaceIndex == -1) {
ArrayList<String> completions = new ArrayList<String>(); ArrayList<String> completions = new ArrayList<>();
Map<String, Command> knownCommands = this.knownCommands; Map<String, Command> knownCommands = this.knownCommands;
final String prefix = (sender instanceof Player ? "/" : ""); 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; return completions;
} }
@ -248,7 +247,7 @@ public class SimpleCommandMap implements CommandMap {
} }
String[] commandStrings = values.get(alias); String[] commandStrings = values.get(alias);
List<String> targets = new ArrayList<String>(); List<String> targets = new ArrayList<>();
StringBuilder bad = new StringBuilder(); StringBuilder bad = new StringBuilder();
for (String commandString : commandStrings) { for (String commandString : commandStrings) {
@ -272,7 +271,7 @@ public class SimpleCommandMap implements CommandMap {
// We register these as commands so they have absolute priority. // We register these as commands so they have absolute priority.
if (targets.size() > 0) { 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 { } else {
knownCommands.remove(alias.toLowerCase()); knownCommands.remove(alias.toLowerCase());
} }

View File

@ -11,6 +11,6 @@ import java.util.List;
*/ */
@Deprecated @Deprecated
public interface TabCommandExecutor extends CommandExecutor { 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 * @return A List of possible completions for the final argument, or null
* to default to the command executor * 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 // PaperSpigot start - location tab-completes
default List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args, Location location) { 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.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
@ -173,11 +174,11 @@ public class AchievementCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null"); Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) { if (args.length == 1) {
return Arrays.asList("give"); return Collections.singletonList("give");
} }
if (args.length == 2) { 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) { if (args.length == 3) {

View File

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

View File

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

View File

@ -36,7 +36,7 @@ public class DefaultGameModeCommand extends VanillaCommand {
try { try {
value = Integer.parseInt(modeArg); value = Integer.parseInt(modeArg);
} catch (NumberFormatException ex) {} } catch (NumberFormatException ignored) {}
GameMode mode = GameMode.getByValue(value); GameMode mode = GameMode.getByValue(value);
@ -63,7 +63,7 @@ public class DefaultGameModeCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null"); Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) { 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(); return ImmutableList.of();

View File

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

View File

@ -74,7 +74,7 @@ public class DifficultyCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null"); Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) { 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(); return ImmutableList.of();

View File

@ -112,7 +112,7 @@ public class EffectCommand extends VanillaCommand {
if (args.length == 1) { if (args.length == 1) {
return super.tabComplete(sender, commandLabel, args); return super.tabComplete(sender, commandLabel, args);
} else if (args.length == 2) { } 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(); return ImmutableList.of();

View File

@ -21,7 +21,7 @@ import org.bukkit.util.StringUtil;
@Deprecated @Deprecated
public class EnchantCommand extends VanillaCommand { 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() { public EnchantCommand() {
super("enchant"); super("enchant");
@ -131,7 +131,7 @@ public class EnchantCommand extends VanillaCommand {
} }
if (args.length == 2) { 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) { if (args.length == 3 || args.length == 4) {

View File

@ -47,7 +47,7 @@ public class GameModeCommand extends VanillaCommand {
try { try {
value = Integer.parseInt(modeArg); value = Integer.parseInt(modeArg);
} catch (NumberFormatException ex) {} } catch (NumberFormatException ignored) {}
GameMode mode = GameMode.getByValue(value); GameMode mode = GameMode.getByValue(value);
@ -70,9 +70,9 @@ public class GameModeCommand extends VanillaCommand {
sender.sendMessage("Game mode change for " + player.getName() + " failed!"); sender.sendMessage("Game mode change for " + player.getName() + " failed!");
} else { } else {
if (player == sender) { 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 { } 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 { } else {
@ -92,7 +92,7 @@ public class GameModeCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null"); Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) { 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) { } else if (args.length == 2) {
return super.tabComplete(sender, alias, args); return super.tabComplete(sender, alias, args);
} }

View File

@ -77,11 +77,11 @@ public class GameRuleCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null"); Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) { 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) { 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(); return ImmutableList.of();

View File

@ -22,7 +22,7 @@ import com.google.common.collect.ImmutableList;
public class GiveCommand extends VanillaCommand { public class GiveCommand extends VanillaCommand {
private static List<String> materials; private static List<String> materials;
static { static {
ArrayList<String> materialList = new ArrayList<String>(); ArrayList<String> materialList = new ArrayList<>();
for (Material material : Material.values()) { for (Material material : Material.values()) {
materialList.add(material.name()); materialList.add(material.name());
} }
@ -64,7 +64,7 @@ public class GiveCommand extends VanillaCommand {
if (args.length >= 4) { if (args.length >= 4) {
try { try {
data = Short.parseShort(args[3]); data = Short.parseShort(args[3]);
} catch (NumberFormatException ex) {} } catch (NumberFormatException ignored) {}
} }
} }
@ -104,7 +104,7 @@ public class GiveCommand extends VanillaCommand {
if (args.length == 2) { if (args.length == 2) {
final String arg = args[1]; final String arg = args[1];
final List<String> materials = GiveCommand.materials; final List<String> materials = GiveCommand.materials;
List<String> completion = new ArrayList<String>(); List<String> completion = new ArrayList<>();
final int size = materials.size(); final int size = materials.size();
int i = Collections.binarySearch(materials, arg, String.CASE_INSENSITIVE_ORDER); 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"); Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) { if (args.length == 1) {
List<String> matchedTopics = new ArrayList<String>(); List<String> matchedTopics = new ArrayList<>();
String searchString = args[0]; String searchString = args[0];
for (HelpTopic topic : Bukkit.getServer().getHelpMap().getHelpTopics()) { for (HelpTopic topic : Bukkit.getServer().getHelpMap().getHelpTopics()) {
String trimmedTopic = topic.getName().startsWith("/") ? topic.getName().substring(1) : topic.getName(); 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) { protected HelpTopic findPossibleMatches(String searchString) {
int maxDistance = (searchString.length() / 5) + 3; int maxDistance = (searchString.length() / 5) + 3;
Set<HelpTopic> possibleMatches = new TreeSet<HelpTopic>(HelpTopicComparator.helpTopicComparatorInstance()); Set<HelpTopic> possibleMatches = new TreeSet<>(HelpTopicComparator.helpTopicComparatorInstance());
if (searchString.startsWith("/")) { if (searchString.startsWith("/")) {
searchString = searchString.substring(1); searchString = searchString.substring(1);
@ -198,7 +198,7 @@ public class HelpCommand extends VanillaCommand {
H[0][j + 1] = INF; 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()) { for (char Letter : (s1 + s2).toCharArray()) {
if (!sd.containsKey(Letter)) { if (!sd.containsKey(Letter)) {
sd.put(Letter, 0); sd.put(Letter, 0);

View File

@ -39,7 +39,7 @@ public class ListCommand extends VanillaCommand {
online.append(player.getDisplayName()); 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; return true;
} }

View File

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

View File

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

View File

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

View File

@ -46,7 +46,7 @@ public class PardonIpCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null"); Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) { 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(); return ImmutableList.of();
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -80,9 +80,9 @@ public class TimeCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null"); Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) { 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")) { } 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(); return ImmutableList.of();
} }

View File

@ -20,16 +20,7 @@ import org.bukkit.util.StringUtil;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
// Spigot start // 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 // Spigot end
public class TimingsCommand extends BukkitCommand { public class TimingsCommand extends BukkitCommand {
@ -107,7 +98,7 @@ public class TimingsCommand extends BukkitCommand {
} }
sender.sendMessage("Timings written to " + timings.getPath()); sender.sendMessage("Timings written to " + timings.getPath());
if (separate) sender.sendMessage("Names written to " + names.getPath()); if (separate) sender.sendMessage("Names written to " + names.getPath());
} catch (IOException e) { } catch (IOException ignored) {
} finally { } finally {
if (fileTimings != null) { if (fileTimings != null) {
fileTimings.close(); fileTimings.close();
@ -130,7 +121,7 @@ public class TimingsCommand extends BukkitCommand {
Validate.notNull(alias, "Alias cannot be null"); Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) { 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(); return ImmutableList.of();
} }

View File

@ -35,7 +35,7 @@ public abstract class VanillaCommand extends Command {
int i = min; int i = min;
try { try {
i = Integer.valueOf(value); i = Integer.parseInt(value);
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
if (Throws) { if (Throws) {
throw new NumberFormatException(String.format("%s is not a valid number", value)); 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", "§3This server is running §b§leSpigot§3 by the ElevateMC development team. Version §b§l1.8.8",
}; };
sender.sendMessage(message);; sender.sendMessage(message);
} else { } else {
StringBuilder name = new StringBuilder(); StringBuilder name = new StringBuilder();
@ -121,7 +121,7 @@ public class VersionCommand extends BukkitCommand {
Validate.notNull(alias, "Alias cannot be null"); Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) { if (args.length == 1) {
List<String> completions = new ArrayList<String>(); List<String> completions = new ArrayList<>();
String toComplete = args[0].toLowerCase(); String toComplete = args[0].toLowerCase();
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
if (StringUtil.startsWithIgnoreCase(plugin.getName(), toComplete)) { if (StringUtil.startsWithIgnoreCase(plugin.getName(), toComplete)) {

View File

@ -66,7 +66,7 @@ public class WeatherCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null"); Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) { 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(); return ImmutableList.of();

View File

@ -60,7 +60,7 @@ public class WhitelistCommand extends VanillaCommand {
result.append(player.getName()); result.append(player.getName());
} }
sender.sendMessage("White-listed players: " + result.toString()); sender.sendMessage("White-listed players: " + result);
return true; return true;
} }
} else if (args.length == 2) { } else if (args.length == 2) {
@ -101,10 +101,10 @@ public class WhitelistCommand extends VanillaCommand {
Validate.notNull(alias, "Alias cannot be null"); Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1) { 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) { } else if (args.length == 2) {
if (args[0].equalsIgnoreCase("add")) { 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. for (OfflinePlayer player : Bukkit.getOnlinePlayers()) { // Spigot - well maybe sometimes you haven't turned the whitelist on just yet.
String name = player.getName(); String name = player.getName();
if (StringUtil.startsWithIgnoreCase(name, args[1]) && !player.isWhitelisted()) { if (StringUtil.startsWithIgnoreCase(name, args[1]) && !player.isWhitelisted()) {
@ -113,7 +113,7 @@ public class WhitelistCommand extends VanillaCommand {
} }
return completions; return completions;
} else if (args[0].equalsIgnoreCase("remove")) { } else if (args[0].equalsIgnoreCase("remove")) {
List<String> completions = new ArrayList<String>(); List<String> completions = new ArrayList<>();
for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) { for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) {
String name = player.getName(); String name = player.getName();
if (StringUtil.startsWithIgnoreCase(name, args[1])) { 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. * @param value Value to set the default to.
* @throws IllegalArgumentException Thrown if path is null. * @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. * 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. * @param defaults A map of Path{@literal ->}Values to add to defaults.
* @throws IllegalArgumentException Thrown if defaults is null. * @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. * 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. * @param defaults A configuration holding a list of defaults to copy.
* @throws IllegalArgumentException Thrown if defaults is null or this. * @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}. * 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. * @param defaults New source of default values for this configuration.
* @throws IllegalArgumentException Thrown if defaults is null or this. * @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. * 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. * @return Configuration source for default values, or null if none exist.
*/ */
public Configuration getDefaults(); Configuration getDefaults();
/** /**
* Gets the {@link ConfigurationOptions} for this {@link Configuration}. * Gets the {@link ConfigurationOptions} for this {@link Configuration}.
@ -80,5 +80,5 @@ public interface Configuration extends ConfigurationSection {
* *
* @return Options for this configuration * @return Options for this configuration
*/ */
public ConfigurationOptions options(); ConfigurationOptions options();
} }

View File

@ -27,7 +27,7 @@ public interface ConfigurationSection {
* list. * list.
* @return Set of keys contained within this ConfigurationSection. * @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. * Gets a Map containing all keys and their values for this section.
@ -43,7 +43,7 @@ public interface ConfigurationSection {
* list. * list.
* @return Map of keys and values of this section. * @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. * Checks if this {@link ConfigurationSection} contains the given path.
@ -56,7 +56,7 @@ public interface ConfigurationSection {
* default or being set. * default or being set.
* @throws IllegalArgumentException Thrown when path is null. * @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 * Checks if this {@link ConfigurationSection} has a value set for the
@ -70,7 +70,7 @@ public interface ConfigurationSection {
* having a default. * having a default.
* @throws IllegalArgumentException Thrown when path is null. * @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 * 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 * @return Path of this section relative to its root
*/ */
public String getCurrentPath(); String getCurrentPath();
/** /**
* Gets the name of this individual {@link ConfigurationSection}, in the * Gets the name of this individual {@link ConfigurationSection}, in the
@ -98,7 +98,7 @@ public interface ConfigurationSection {
* *
* @return Name of this section * @return Name of this section
*/ */
public String getName(); String getName();
/** /**
* Gets the root {@link Configuration} that contains this {@link * Gets the root {@link Configuration} that contains this {@link
@ -112,7 +112,7 @@ public interface ConfigurationSection {
* *
* @return Root configuration containing this section. * @return Root configuration containing this section.
*/ */
public Configuration getRoot(); Configuration getRoot();
/** /**
* Gets the parent {@link ConfigurationSection} that directly contains * Gets the parent {@link ConfigurationSection} that directly contains
@ -125,7 +125,7 @@ public interface ConfigurationSection {
* *
* @return Parent section containing this section. * @return Parent section containing this section.
*/ */
public ConfigurationSection getParent(); ConfigurationSection getParent();
/** /**
* Gets the requested Object by path. * Gets the requested Object by path.
@ -137,7 +137,7 @@ public interface ConfigurationSection {
* @param path Path of the Object to get. * @param path Path of the Object to get.
* @return Requested Object. * @return Requested Object.
*/ */
public Object get(String path); Object get(String path);
/** /**
* Gets the requested Object by path, returning a default value if not * 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. * @param def The default value to return if the path is not found.
* @return Requested Object. * @return Requested Object.
*/ */
public Object get(String path, Object def); Object get(String path, Object def);
/** /**
* Sets the specified path to the given value. * Sets the specified path to the given value.
@ -167,7 +167,7 @@ public interface ConfigurationSection {
* @param path Path of the object to set. * @param path Path of the object to set.
* @param value New value to set the path to. * @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. * Creates an empty {@link ConfigurationSection} at the specified path.
@ -179,7 +179,7 @@ public interface ConfigurationSection {
* @param path Path to create the section at. * @param path Path to create the section at.
* @return Newly created section * @return Newly created section
*/ */
public ConfigurationSection createSection(String path); ConfigurationSection createSection(String path);
/** /**
* Creates a {@link ConfigurationSection} at the specified path, with * Creates a {@link ConfigurationSection} at the specified path, with
@ -193,7 +193,7 @@ public interface ConfigurationSection {
* @param map The values to used. * @param map The values to used.
* @return Newly created section * @return Newly created section
*/ */
public ConfigurationSection createSection(String path, Map<?, ?> map); ConfigurationSection createSection(String path, Map<?, ?> map);
// Primitives // Primitives
/** /**
@ -206,7 +206,7 @@ public interface ConfigurationSection {
* @param path Path of the String to get. * @param path Path of the String to get.
* @return Requested String. * @return Requested String.
*/ */
public String getString(String path); String getString(String path);
/** /**
* Gets the requested String by path, returning a default value if not * Gets the requested String by path, returning a default value if not
@ -221,7 +221,7 @@ public interface ConfigurationSection {
* not a String. * not a String.
* @return Requested 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. * Checks if the specified path is a String.
@ -234,7 +234,7 @@ public interface ConfigurationSection {
* @param path Path of the String to check. * @param path Path of the String to check.
* @return Whether or not the specified path is a String. * @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. * Gets the requested int by path.
@ -246,7 +246,7 @@ public interface ConfigurationSection {
* @param path Path of the int to get. * @param path Path of the int to get.
* @return Requested int. * @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. * Gets the requested int by path, returning a default value if not found.
@ -260,7 +260,7 @@ public interface ConfigurationSection {
* not an int. * not an int.
* @return Requested 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. * Checks if the specified path is an int.
@ -273,7 +273,7 @@ public interface ConfigurationSection {
* @param path Path of the int to check. * @param path Path of the int to check.
* @return Whether or not the specified path is an int. * @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. * Gets the requested boolean by path.
@ -285,7 +285,7 @@ public interface ConfigurationSection {
* @param path Path of the boolean to get. * @param path Path of the boolean to get.
* @return Requested boolean. * @return Requested boolean.
*/ */
public boolean getBoolean(String path); boolean getBoolean(String path);
/** /**
* Gets the requested boolean by path, returning a default value if not * Gets the requested boolean by path, returning a default value if not
@ -300,7 +300,7 @@ public interface ConfigurationSection {
* not a boolean. * not a boolean.
* @return Requested 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. * Checks if the specified path is a boolean.
@ -313,7 +313,7 @@ public interface ConfigurationSection {
* @param path Path of the boolean to check. * @param path Path of the boolean to check.
* @return Whether or not the specified path is a boolean. * @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. * Gets the requested double by path.
@ -325,7 +325,7 @@ public interface ConfigurationSection {
* @param path Path of the double to get. * @param path Path of the double to get.
* @return Requested double. * @return Requested double.
*/ */
public double getDouble(String path); double getDouble(String path);
/** /**
* Gets the requested double by path, returning a default value if not * Gets the requested double by path, returning a default value if not
@ -340,7 +340,7 @@ public interface ConfigurationSection {
* not a double. * not a double.
* @return Requested 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. * Checks if the specified path is a double.
@ -353,7 +353,7 @@ public interface ConfigurationSection {
* @param path Path of the double to check. * @param path Path of the double to check.
* @return Whether or not the specified path is a double. * @return Whether or not the specified path is a double.
*/ */
public boolean isDouble(String path); boolean isDouble(String path);
// PaperSpigot start - Add getFloat // PaperSpigot start - Add getFloat
/** /**
@ -366,7 +366,7 @@ public interface ConfigurationSection {
* @param path Path of the float to get. * @param path Path of the float to get.
* @return Requested float. * @return Requested float.
*/ */
public float getFloat(String path); float getFloat(String path);
/** /**
* Gets the requested float by path, returning a default value if not * Gets the requested float by path, returning a default value if not
@ -381,7 +381,7 @@ public interface ConfigurationSection {
* not a float. * not a float.
* @return Requested 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. * Checks if the specified path is a float.
@ -394,7 +394,7 @@ public interface ConfigurationSection {
* @param path Path of the float to check. * @param path Path of the float to check.
* @return Whether or not the specified path is a float. * @return Whether or not the specified path is a float.
*/ */
public boolean isFloat(String path); boolean isFloat(String path);
// PaperSpigot end // PaperSpigot end
/** /**
@ -407,7 +407,7 @@ public interface ConfigurationSection {
* @param path Path of the long to get. * @param path Path of the long to get.
* @return Requested long. * @return Requested long.
*/ */
public long getLong(String path); long getLong(String path);
/** /**
* Gets the requested long by path, returning a default value if not * Gets the requested long by path, returning a default value if not
@ -422,7 +422,7 @@ public interface ConfigurationSection {
* not a long. * not a long.
* @return Requested 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. * Checks if the specified path is a long.
@ -435,7 +435,7 @@ public interface ConfigurationSection {
* @param path Path of the long to check. * @param path Path of the long to check.
* @return Whether or not the specified path is a long. * @return Whether or not the specified path is a long.
*/ */
public boolean isLong(String path); boolean isLong(String path);
// Java // Java
/** /**
@ -448,7 +448,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List. * @return Requested List.
*/ */
public List<?> getList(String path); List<?> getList(String path);
/** /**
* Gets the requested List by path, returning a default value if not * Gets the requested List by path, returning a default value if not
@ -463,7 +463,7 @@ public interface ConfigurationSection {
* not a List. * not a List.
* @return Requested 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. * Checks if the specified path is a List.
@ -476,7 +476,7 @@ public interface ConfigurationSection {
* @param path Path of the List to check. * @param path Path of the List to check.
* @return Whether or not the specified path is a List. * @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. * Gets the requested List of String by path.
@ -491,7 +491,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of String. * @return Requested List of String.
*/ */
public List<String> getStringList(String path); List<String> getStringList(String path);
/** /**
* Gets the requested List of Integer by path. * Gets the requested List of Integer by path.
@ -506,7 +506,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Integer. * @return Requested List of Integer.
*/ */
public List<Integer> getIntegerList(String path); List<Integer> getIntegerList(String path);
/** /**
* Gets the requested List of Boolean by path. * Gets the requested List of Boolean by path.
@ -521,7 +521,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Boolean. * @return Requested List of Boolean.
*/ */
public List<Boolean> getBooleanList(String path); List<Boolean> getBooleanList(String path);
/** /**
* Gets the requested List of Double by path. * Gets the requested List of Double by path.
@ -536,7 +536,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Double. * @return Requested List of Double.
*/ */
public List<Double> getDoubleList(String path); List<Double> getDoubleList(String path);
/** /**
* Gets the requested List of Float by path. * Gets the requested List of Float by path.
@ -551,7 +551,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Float. * @return Requested List of Float.
*/ */
public List<Float> getFloatList(String path); List<Float> getFloatList(String path);
/** /**
* Gets the requested List of Long by path. * Gets the requested List of Long by path.
@ -566,7 +566,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Long. * @return Requested List of Long.
*/ */
public List<Long> getLongList(String path); List<Long> getLongList(String path);
/** /**
* Gets the requested List of Byte by path. * Gets the requested List of Byte by path.
@ -581,7 +581,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Byte. * @return Requested List of Byte.
*/ */
public List<Byte> getByteList(String path); List<Byte> getByteList(String path);
/** /**
* Gets the requested List of Character by path. * Gets the requested List of Character by path.
@ -596,7 +596,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Character. * @return Requested List of Character.
*/ */
public List<Character> getCharacterList(String path); List<Character> getCharacterList(String path);
/** /**
* Gets the requested List of Short by path. * Gets the requested List of Short by path.
@ -611,7 +611,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Short. * @return Requested List of Short.
*/ */
public List<Short> getShortList(String path); List<Short> getShortList(String path);
/** /**
* Gets the requested List of Maps by path. * Gets the requested List of Maps by path.
@ -626,7 +626,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Maps. * @return Requested List of Maps.
*/ */
public List<Map<?, ?>> getMapList(String path); List<Map<?, ?>> getMapList(String path);
// Bukkit // Bukkit
/** /**
@ -639,7 +639,7 @@ public interface ConfigurationSection {
* @param path Path of the Vector to get. * @param path Path of the Vector to get.
* @return Requested Vector. * @return Requested Vector.
*/ */
public Vector getVector(String path); Vector getVector(String path);
/** /**
* Gets the requested {@link Vector} by path, returning a default value if * Gets the requested {@link Vector} by path, returning a default value if
@ -654,7 +654,7 @@ public interface ConfigurationSection {
* not a Vector. * not a Vector.
* @return Requested 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. * Checks if the specified path is a Vector.
@ -667,7 +667,7 @@ public interface ConfigurationSection {
* @param path Path of the Vector to check. * @param path Path of the Vector to check.
* @return Whether or not the specified path is a Vector. * @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. * Gets the requested OfflinePlayer by path.
@ -680,7 +680,7 @@ public interface ConfigurationSection {
* @param path Path of the OfflinePlayer to get. * @param path Path of the OfflinePlayer to get.
* @return Requested OfflinePlayer. * @return Requested OfflinePlayer.
*/ */
public OfflinePlayer getOfflinePlayer(String path); OfflinePlayer getOfflinePlayer(String path);
/** /**
* Gets the requested {@link OfflinePlayer} by path, returning a default * Gets the requested {@link OfflinePlayer} by path, returning a default
@ -695,7 +695,7 @@ public interface ConfigurationSection {
* not an OfflinePlayer. * not an OfflinePlayer.
* @return Requested 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. * Checks if the specified path is an OfflinePlayer.
@ -708,7 +708,7 @@ public interface ConfigurationSection {
* @param path Path of the OfflinePlayer to check. * @param path Path of the OfflinePlayer to check.
* @return Whether or not the specified path is an OfflinePlayer. * @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. * Gets the requested ItemStack by path.
@ -720,7 +720,7 @@ public interface ConfigurationSection {
* @param path Path of the ItemStack to get. * @param path Path of the ItemStack to get.
* @return Requested ItemStack. * @return Requested ItemStack.
*/ */
public ItemStack getItemStack(String path); ItemStack getItemStack(String path);
/** /**
* Gets the requested {@link ItemStack} by path, returning a default value * Gets the requested {@link ItemStack} by path, returning a default value
@ -735,7 +735,7 @@ public interface ConfigurationSection {
* not an ItemStack. * not an ItemStack.
* @return Requested 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. * Checks if the specified path is an ItemStack.
@ -748,7 +748,7 @@ public interface ConfigurationSection {
* @param path Path of the ItemStack to check. * @param path Path of the ItemStack to check.
* @return Whether or not the specified path is an ItemStack. * @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. * Gets the requested Color by path.
@ -760,7 +760,7 @@ public interface ConfigurationSection {
* @param path Path of the Color to get. * @param path Path of the Color to get.
* @return Requested Color. * @return Requested Color.
*/ */
public Color getColor(String path); Color getColor(String path);
/** /**
* Gets the requested {@link Color} by path, returning a default value if * Gets the requested {@link Color} by path, returning a default value if
@ -775,7 +775,7 @@ public interface ConfigurationSection {
* not a Color. * not a Color.
* @return Requested 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. * Checks if the specified path is a Color.
@ -788,7 +788,7 @@ public interface ConfigurationSection {
* @param path Path of the Color to check. * @param path Path of the Color to check.
* @return Whether or not the specified path is a Color. * @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. * Gets the requested ConfigurationSection by path.
@ -801,7 +801,7 @@ public interface ConfigurationSection {
* @param path Path of the ConfigurationSection to get. * @param path Path of the ConfigurationSection to get.
* @return Requested ConfigurationSection. * @return Requested ConfigurationSection.
*/ */
public ConfigurationSection getConfigurationSection(String path); ConfigurationSection getConfigurationSection(String path);
/** /**
* Checks if the specified path is a ConfigurationSection. * Checks if the specified path is a ConfigurationSection.
@ -815,7 +815,7 @@ public interface ConfigurationSection {
* @param path Path of the ConfigurationSection to check. * @param path Path of the ConfigurationSection to check.
* @return Whether or not the specified path is a ConfigurationSection. * @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 * Gets the equivalent {@link ConfigurationSection} from the default
@ -827,7 +827,7 @@ public interface ConfigurationSection {
* *
* @return Equivalent section in root configuration * @return Equivalent section in root configuration
*/ */
public ConfigurationSection getDefaultSection(); ConfigurationSection getDefaultSection();
/** /**
* Sets the default value in the root at the given path as provided. * 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. * @param value Value to set the default to.
* @throws IllegalArgumentException Thrown if path is null. * @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. * A type of {@link ConfigurationSection} that is stored in memory.
*/ */
public class MemorySection implements ConfigurationSection { 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 Configuration root;
private final ConfigurationSection parent; private final ConfigurationSection parent;
private final String path; private final String path;
@ -69,7 +69,7 @@ public class MemorySection implements ConfigurationSection {
} }
public Set<String> getKeys(boolean deep) { public Set<String> getKeys(boolean deep) {
Set<String> result = new LinkedHashSet<String>(); Set<String> result = new LinkedHashSet<>();
Configuration root = getRoot(); Configuration root = getRoot();
if (root != null && root.options().copyDefaults()) { if (root != null && root.options().copyDefaults()) {
@ -86,7 +86,7 @@ public class MemorySection implements ConfigurationSection {
} }
public Map<String, Object> getValues(boolean deep) { public Map<String, Object> getValues(boolean deep) {
Map<String, Object> result = new LinkedHashMap<String, Object>(); Map<String, Object> result = new LinkedHashMap<>();
Configuration root = getRoot(); Configuration root = getRoot();
if (root != null && root.options().copyDefaults()) { if (root != null && root.options().copyDefaults()) {
@ -388,10 +388,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) { 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) { for (Object object : list) {
if ((object instanceof String) || (isPrimitiveWrapper(object))) { if ((object instanceof String) || (isPrimitiveWrapper(object))) {
@ -406,10 +406,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) { 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) { for (Object object : list) {
if (object instanceof Integer) { if (object instanceof Integer) {
@ -417,10 +417,10 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) { } else if (object instanceof String) {
try { try {
result.add(Integer.valueOf((String) object)); result.add(Integer.valueOf((String) object));
} catch (Exception ex) { } catch (Exception ignored) {
} }
} else if (object instanceof Character) { } else if (object instanceof Character) {
result.add((int) ((Character) object).charValue()); result.add((int) (Character) object);
} else if (object instanceof Number) { } else if (object instanceof Number) {
result.add(((Number) object).intValue()); result.add(((Number) object).intValue());
} }
@ -433,10 +433,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) { 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) { for (Object object : list) {
if (object instanceof Boolean) { if (object instanceof Boolean) {
@ -457,10 +457,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) { 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) { for (Object object : list) {
if (object instanceof Double) { if (object instanceof Double) {
@ -468,10 +468,10 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) { } else if (object instanceof String) {
try { try {
result.add(Double.valueOf((String) object)); result.add(Double.valueOf((String) object));
} catch (Exception ex) { } catch (Exception ignored) {
} }
} else if (object instanceof Character) { } else if (object instanceof Character) {
result.add((double) ((Character) object).charValue()); result.add((double) (Character) object);
} else if (object instanceof Number) { } else if (object instanceof Number) {
result.add(((Number) object).doubleValue()); result.add(((Number) object).doubleValue());
} }
@ -484,10 +484,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) { 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) { for (Object object : list) {
if (object instanceof Float) { if (object instanceof Float) {
@ -495,10 +495,10 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) { } else if (object instanceof String) {
try { try {
result.add(Float.valueOf((String) object)); result.add(Float.valueOf((String) object));
} catch (Exception ex) { } catch (Exception ignored) {
} }
} else if (object instanceof Character) { } else if (object instanceof Character) {
result.add((float) ((Character) object).charValue()); result.add((float) (Character) object);
} else if (object instanceof Number) { } else if (object instanceof Number) {
result.add(((Number) object).floatValue()); result.add(((Number) object).floatValue());
} }
@ -511,10 +511,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) { 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) { for (Object object : list) {
if (object instanceof Long) { if (object instanceof Long) {
@ -522,10 +522,10 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) { } else if (object instanceof String) {
try { try {
result.add(Long.valueOf((String) object)); result.add(Long.valueOf((String) object));
} catch (Exception ex) { } catch (Exception ignored) {
} }
} else if (object instanceof Character) { } else if (object instanceof Character) {
result.add((long) ((Character) object).charValue()); result.add((long) (Character) object);
} else if (object instanceof Number) { } else if (object instanceof Number) {
result.add(((Number) object).longValue()); result.add(((Number) object).longValue());
} }
@ -538,10 +538,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) { 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) { for (Object object : list) {
if (object instanceof Byte) { if (object instanceof Byte) {
@ -549,7 +549,7 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) { } else if (object instanceof String) {
try { try {
result.add(Byte.valueOf((String) object)); result.add(Byte.valueOf((String) object));
} catch (Exception ex) { } catch (Exception ignored) {
} }
} else if (object instanceof Character) { } else if (object instanceof Character) {
result.add((byte) ((Character) object).charValue()); result.add((byte) ((Character) object).charValue());
@ -565,10 +565,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) { 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) { for (Object object : list) {
if (object instanceof Character) { if (object instanceof Character) {
@ -591,10 +591,10 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path); List<?> list = getList(path);
if (list == null) { 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) { for (Object object : list) {
if (object instanceof Short) { if (object instanceof Short) {
@ -602,7 +602,7 @@ public class MemorySection implements ConfigurationSection {
} else if (object instanceof String) { } else if (object instanceof String) {
try { try {
result.add(Short.valueOf((String) object)); result.add(Short.valueOf((String) object));
} catch (Exception ex) { } catch (Exception ignored) {
} }
} else if (object instanceof Character) { } else if (object instanceof Character) {
result.add((short) ((Character) object).charValue()); result.add((short) ((Character) object).charValue());
@ -616,7 +616,7 @@ public class MemorySection implements ConfigurationSection {
public List<Map<?, ?>> getMapList(String path) { public List<Map<?, ?>> getMapList(String path) {
List<?> list = getList(path); List<?> list = getList(path);
List<Map<?, ?>> result = new ArrayList<Map<?, ?>>(); List<Map<?, ?>> result = new ArrayList<>();
if (list == null) { if (list == null) {
return result; return result;

View File

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

View File

@ -52,7 +52,7 @@ public class YamlConfiguration extends FileConfiguration {
Map<?, ?> input; Map<?, ?> input;
try { try {
input = (Map<?, ?>) yaml.load(contents); input = yaml.load(contents);
} catch (YAMLException e) { } catch (YAMLException e) {
throw new InvalidConfigurationException(e); throw new InvalidConfigurationException(e);
} catch (ClassCastException e) { } catch (ClassCastException e) {
@ -178,11 +178,9 @@ public class YamlConfiguration extends FileConfiguration {
try { try {
config.load(file); config.load(file);
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ignored) {
} catch (IOException ex) { } catch (IOException | InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex); Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
} catch (InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file , ex);
} }
return config; return config;
@ -210,9 +208,7 @@ public class YamlConfiguration extends FileConfiguration {
try { try {
config.load(stream); config.load(stream);
} catch (IOException ex) { } catch (IOException | InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
} catch (InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex); Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
} }
@ -238,9 +234,7 @@ public class YamlConfiguration extends FileConfiguration {
try { try {
config.load(reader); config.load(reader);
} catch (IOException ex) { } catch (IOException | InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
} catch (InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", 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); Map<?, ?> raw = (Map<?, ?>) super.construct(node);
if (raw.containsKey(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) { 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()) { for (Map.Entry<?, ?> entry : raw.entrySet()) {
typed.put(entry.getKey().toString(), entry.getValue()); typed.put(entry.getKey().toString(), entry.getValue());
} }

View File

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

View File

@ -31,5 +31,5 @@ public interface ConfigurationSerializable {
* *
* @return Map containing the current state of this class * @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 class ConfigurationSerialization {
public static final String SERIALIZED_TYPE_KEY = "=="; public static final String SERIALIZED_TYPE_KEY = "==";
private final Class<? extends ConfigurationSerializable> clazz; 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 { static {
registerClass(Vector.class); registerClass(Vector.class);
@ -55,9 +55,7 @@ public class ConfigurationSerialization {
} }
return method; return method;
} catch (NoSuchMethodException ex) { } catch (NoSuchMethodException | SecurityException ex) {
return null;
} catch (SecurityException ex) {
return null; return null;
} }
} }
@ -65,9 +63,7 @@ public class ConfigurationSerialization {
protected Constructor<? extends ConfigurationSerializable> getConstructor() { protected Constructor<? extends ConfigurationSerializable> getConstructor() {
try { try {
return clazz.getConstructor(Map.class); return clazz.getConstructor(Map.class);
} catch (NoSuchMethodException ex) { } catch (NoSuchMethodException | SecurityException ex) {
return null;
} catch (SecurityException ex) {
return null; return null;
} }
} }
@ -77,7 +73,7 @@ public class ConfigurationSerialization {
ConfigurationSerializable result = (ConfigurationSerializable) method.invoke(null, args); ConfigurationSerializable result = (ConfigurationSerializable) method.invoke(null, args);
if (result == null) { 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 { } else {
return result; return result;
} }
@ -239,7 +235,6 @@ public class ConfigurationSerialization {
*/ */
public static void unregisterClass(Class<? extends ConfigurationSerializable> clazz) { public static void unregisterClass(Class<? extends ConfigurationSerializable> clazz) {
while (aliases.values().remove(clazz)) { while (aliases.values().remove(clazz)) {
;
} }
} }

View File

@ -18,5 +18,5 @@ public @interface DelegateDeserialization {
* *
* @return Delegate class * @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. * @return Name to serialize the class as.
*/ */
public String value(); String value();
} }

View File

@ -1,7 +1,5 @@
package org.bukkit.conversations; package org.bukkit.conversations;
import org.bukkit.command.CommandSender;
/** /**
* The Conversable interface is used to indicate objects that can have * The Conversable interface is used to indicate objects that can have
* conversations. * conversations.
@ -14,7 +12,7 @@ public interface Conversable {
* *
* @return True if a conversation is in progress * @return True if a conversation is in progress
*/ */
public boolean isConversing(); boolean isConversing();
/** /**
* Accepts input into the active conversation. If no conversation is in * 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 * @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. * 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 * @return True if the conversation should proceed, false if it has been
* enqueued * enqueued
*/ */
public boolean beginConversation(Conversation conversation); boolean beginConversation(Conversation conversation);
/** /**
* Abandons an active conversation. * Abandons an active conversation.
* *
* @param conversation The conversation to abandon * @param conversation The conversation to abandon
*/ */
public void abandonConversation(Conversation conversation); void abandonConversation(Conversation conversation);
/** /**
* Abandons an active conversation. * Abandons an active conversation.
@ -46,12 +44,12 @@ public interface Conversable {
* @param conversation The conversation to abandon * @param conversation The conversation to abandon
* @param details Details about why the conversation was abandoned * @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 * Sends this sender a message raw
* *
* @param message Message to be displayed * @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. * @param firstPrompt The first prompt in the conversation graph.
*/ */
public Conversation(Plugin plugin, Conversable forWhom, Prompt firstPrompt) { 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.modal = true;
this.localEchoEnabled = true; this.localEchoEnabled = true;
this.prefix = new NullConversationPrefix(); this.prefix = new NullConversationPrefix();
this.cancellers = new ArrayList<ConversationCanceller>(); this.cancellers = new ArrayList<>();
this.abandonedListeners = new ArrayList<ConversationAbandonedListener>(); this.abandonedListeners = new ArrayList<>();
} }
/** /**

View File

@ -11,5 +11,5 @@ public interface ConversationAbandonedListener extends EventListener {
* @param abandonedEvent Contains details about the abandoned * @param abandonedEvent Contains details about the abandoned
* conversation. * 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. * @param conversation A conversation.
*/ */
public void setConversation(Conversation conversation); void setConversation(Conversation conversation);
/** /**
* Cancels a conversation based on user input. * Cancels a conversation based on user input.
@ -20,7 +20,7 @@ public interface ConversationCanceller extends Cloneable {
* @param input The input text from the user. * @param input The input text from the user.
* @return True to cancel the conversation, False otherwise. * @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 * Allows the {@link ConversationFactory} to duplicate this
@ -30,5 +30,5 @@ public interface ConversationCanceller extends Cloneable {
* *
* @return A clone. * @return A clone.
*/ */
public ConversationCanceller clone(); ConversationCanceller clone();
} }

View File

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

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