And a few more

This commit is contained in:
Dan Mulloy 2015-06-17 15:08:58 -04:00
parent bba1054f97
commit 273b470140
26 changed files with 142 additions and 67 deletions

View File

@ -321,7 +321,6 @@ public class CommandFilter extends CommandBase {
* @param event - the event.
* @param handler - failure handler.
* @return TRUE if we should, FALSE otherwise.
* @throws ScriptException If one of the filters failed.
*/
public boolean filterEvent(PacketEvent event, FilterFailedHandler handler) {
for (Iterator<Filter> it = filters.iterator(); it.hasNext(); ) {

View File

@ -2,16 +2,16 @@
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
* Copyright (C) 2012 Kristian S. Stangeland
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*/
@ -48,7 +48,7 @@ import com.google.common.base.Joiner;
*/
public class AsyncListenerHandler {
public static final ReportType REPORT_HANDLER_NOT_STARTED = new ReportType(
"Plugin %s did not start the asynchronous handler %s by calling start() or syncStart().");
"Plugin %s did not start the asynchronous handler %s by calling start() or syncStart().");
/**
* Signal an end to packet processing.
@ -209,6 +209,7 @@ public class AsyncListenerHandler {
* close a specific worker is less efficient than stopping an arbitrary worker.
* <p>
* <b>Warning</b>: Never call the run() method in the main thread.
* @return The listener loop
*/
public AsyncRunnable getListenerLoop() {
return new AsyncRunnable() {
@ -315,7 +316,7 @@ public class AsyncListenerHandler {
* public Void apply(&#64;Nullable AsyncRunnable workerLoop) {
* Thread thread = Thread.currentThread();
* int prevPriority = thread.getPriority();
*
*
* thread.setPriority(Thread.MIN_PRIORITY);
* workerLoop.run();
* thread.setPriority(prevPriority);
@ -357,9 +358,9 @@ public class AsyncListenerHandler {
* @return A friendly thread name.
*/
public String getFriendlyWorkerName(int id) {
return String.format("Protocol Worker #%s - %s - [recv: %s, send: %s]",
id,
PacketAdapter.getPluginName(listener),
return String.format("Protocol Worker #%s - %s - [recv: %s, send: %s]",
id,
PacketAdapter.getPluginName(listener),
fromWhitelist(listener.getReceivingWhitelist()),
fromWhitelist(listener.getSendingWhitelist())
);
@ -383,8 +384,8 @@ public class AsyncListenerHandler {
* This is useful if you need to synchronize with the main thread in your packet listener, but
* you're not performing any expensive processing.
* <p>
* <b>Note</b>: Use a asynchronous worker if the packet listener may use more than 0.5 ms
* of processing time on a single packet. Do as much as possible on the worker thread, and schedule synchronous tasks
* <b>Note</b>: Use a asynchronous worker if the packet listener may use more than 0.5 ms
* of processing time on a single packet. Do as much as possible on the worker thread, and schedule synchronous tasks
* to use the Bukkit API instead.
* @return TRUE if the synchronized processing was successfully started, FALSE if it's already running.
* @throws IllegalStateException If we couldn't start the underlying task.
@ -399,12 +400,12 @@ public class AsyncListenerHandler {
* This is useful if you need to synchronize with the main thread in your packet listener, but
* you're not performing any expensive processing.
* <p>
* The processing time parameter gives the upper bound for the amount of time spent processing pending packets.
* It should be set to a fairly low number, such as 0.5 ms or 1% of a game tick - to reduce the impact
* The processing time parameter gives the upper bound for the amount of time spent processing pending packets.
* It should be set to a fairly low number, such as 0.5 ms or 1% of a game tick - to reduce the impact
* on the main thread. Never go beyond 50 milliseconds.
* <p>
* <b>Note</b>: Use a asynchronous worker if the packet listener may exceed the ideal processing time
* on a single packet. Do as much as possible on the worker thread, and schedule synchronous tasks
* <b>Note</b>: Use a asynchronous worker if the packet listener may exceed the ideal processing time
* on a single packet. Do as much as possible on the worker thread, and schedule synchronous tasks
* to use the Bukkit API instead.
*
* @param time - the amount of processing time alloted per game tick (20 ticks per second).
@ -503,7 +504,7 @@ public class AsyncListenerHandler {
}
/**
* Set the current number of workers.
* Set the current number of workers.
* <p>
* This method can only be called with a count of zero when the listener is closing.
* @param count - new number of workers.
@ -563,7 +564,7 @@ public class AsyncListenerHandler {
*/
private void listenerLoop(int workerID) {
// Danger, danger!
if (Thread.currentThread().getId() == mainThread.getId())
if (Thread.currentThread().getId() == mainThread.getId())
throw new IllegalStateException("Do not call this method from the main thread.");
if (cancelled)
throw new IllegalStateException("Listener has been cancelled. Create a new listener instead.");
@ -584,7 +585,7 @@ public class AsyncListenerHandler {
// This is a bit slow, but it should be safe
synchronized (stopLock) {
// Are we the one who is supposed to stop?
if (stoppedTasks.contains(workerID))
if (stoppedTasks.contains(workerID))
return;
if (waitForStops())
return;
@ -616,7 +617,7 @@ public class AsyncListenerHandler {
AsyncMarker marker = packet.getAsyncMarker();
// Here's the core of the asynchronous processing
try {
try {
synchronized (marker.getProcessingLock()) {
marker.setListenerHandler(this);
marker.setWorkerID(workerID);
@ -624,7 +625,7 @@ public class AsyncListenerHandler {
// We're not THAT worried about performance here
if (timedManager.isTiming()) {
// Retrieve the tracker to use
TimedTracker tracker = timedManager.getTracker(listener,
TimedTracker tracker = timedManager.getTracker(listener,
packet.isServerPacket() ? ListenerType.ASYNC_SERVER_SIDE : ListenerType.ASYNC_CLIENT_SIDE);
long token = tracker.beginTracking();

View File

@ -401,6 +401,7 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
/**
* Determine if Minecraft allows asynchronous processing of this packet.
* @param event - packet event
* @return TRUE if it does, FALSE otherwise.
* @throws FieldAccessException If determining fails for some reasaon
*/

View File

@ -139,6 +139,7 @@ public abstract class AbstractIntervalTree<TKey extends Comparable<TKey>, TValue
* Removes every interval that intersects with the given range.
* @param lowerBound - lowest value to remove.
* @param upperBound - highest value to remove.
* @return Intervals that were removed
*/
public Set<Entry> remove(TKey lowerBound, TKey upperBound) {
return remove(lowerBound, upperBound, false);

View File

@ -339,6 +339,7 @@ public abstract class NetworkMarker {
* <p>
* It's safe to modify the input stream.
* @throws IOException If integer reading fails
* @return An input stream without the header
*/
protected abstract DataInputStream skipHeader(DataInputStream input) throws IOException;

View File

@ -443,9 +443,10 @@ public abstract class PlayerInjector implements SocketInjector {
/**
* Retrieves the current net handler for this player.
* @boolean refresh - Whether or not to refresh
* @param refresh - Whether or not to refresh
* @return Current net handler.
* @throws IllegalAccessException Unable to find or retrieve net handler.
* @return The current net handler for this player
*/
protected Object getNetHandler(boolean refresh) throws IllegalAccessException {
// What a mess
@ -564,7 +565,7 @@ public abstract class PlayerInjector implements SocketInjector {
/**
* Determine if this inject method can even be attempted.
* @param GamePhase - Game phase
* @param state - Game phase
* @return TRUE if can be attempted, though possibly with failure, FALSE otherwise.
*/
public abstract boolean canInject(GamePhase state);

View File

@ -52,7 +52,7 @@ import com.google.common.collect.MapMaker;
import com.google.common.collect.Maps;
/**
* Offload all the work to Spigot, if possible.
* Offload all the work to Spigot, if possible.
*
* @author Kristian
*/
@ -104,11 +104,14 @@ public class SpigotPacketInjector implements SpigotPacketListener {
private PacketInjector proxyPacketInjector;
// Background task
private static final int BACKGROUND_DELAY = 30 * PacketFilterManager.TICKS_PER_SECOND;
private static final int BACKGROUND_DELAY = 30 * PacketFilterManager.TICKS_PER_SECOND;
private int backgroundId;
/**
* Create a new spigot injector.
* @param reporter - error reporter
* @param invoker - listener invoker
* @param server - server
*/
public SpigotPacketInjector(ErrorReporter reporter, ListenerInvoker invoker, Server server) {
this.reporter = reporter;

View File

@ -157,7 +157,7 @@ public final class StructureCompiler {
/**
* Lookup the current class loader for any previously generated classes before we attempt to generate something.
* @param <TKey> Type
* @param <TField> Type
* @param source - the structure modifier to look up.
* @return TRUE if we successfully found a previously generated class, FALSE otherwise.
*/
@ -192,6 +192,7 @@ public final class StructureCompiler {
* <p>
* WARNING: Do NOT call this method in the main thread. Compiling may easily take 10 ms, which is already
* over 1/4 of a tick (50 ms). Let the background thread automatically compile the structure modifiers instead.
* @param <TField> Type
* @param source - structure modifier to compile.
* @return A compiled structure modifier.
*/

View File

@ -133,7 +133,6 @@ public class HexDumper {
* Append the hex dump of the given data to the string builder, using the current formatting settings.
* @param appendable - appendable source.
* @param data - the data to dump.
* @param length - the number of bytes to dump.
* @throws IOException Any underlying IO exception.
*/
public void appendTo(Appendable appendable, byte[] data) throws IOException {

View File

@ -61,7 +61,7 @@ public class SafeCacheBuilder<K, V> {
*
* @throws IllegalArgumentException if {@code concurrencyLevel} is
* nonpositive
* @throws IllegalStateExeption if a concurrency level was already set
* @throws IllegalStateException if a concurrency level was already set
*/
public SafeCacheBuilder<K, V> concurrencyLevel(int concurrencyLevel) {
builder.concurrencyLevel(concurrencyLevel);
@ -121,6 +121,8 @@ public class SafeCacheBuilder<K, V> {
* @param duration the length of time after an entry is created that it
* should be automatically removed
* @param unit the unit that {@code duration} is expressed in
* @return This for chaining
*
* @throws IllegalArgumentException if {@code duration} is negative
* @throws IllegalStateException if the time to live or time to idle was
* already set
@ -138,6 +140,9 @@ public class SafeCacheBuilder<K, V> {
* the need for expensive resizing operations later, but setting this value
* unnecessarily high wastes memory.
*
* @param initialCapacity - initial capacity
* @return This for chaining
*
* @throws IllegalArgumentException if {@code initialCapacity} is negative
* @throws IllegalStateException if an initial capacity was already set
*/
@ -162,6 +167,8 @@ public class SafeCacheBuilder<K, V> {
* without a code change.
*
* @param size the maximum size of the cache
* @return This for chaining
*
* @throws IllegalArgumentException if {@code size} is negative
* @throws IllegalStateException if a maximum size was already set
*/
@ -202,6 +209,9 @@ public class SafeCacheBuilder<K, V> {
* incompatible with the listener, you will likely experience a
* {@link ClassCastException} at some <i>undefined</i> point in the future.
*
* @param listener - removal listener
* @return This for chaining
*
* @throws IllegalStateException if a removal listener was already set
*/
@SuppressWarnings("unchecked")
@ -219,6 +229,9 @@ public class SafeCacheBuilder<K, V> {
* which have been configured with {@link #expireAfterWrite} or
* {@link #expireAfterAccess}.
*
* @param ticker - ticker
* @return This for chaining
*
* @throws IllegalStateException if a ticker was already set
*/
public SafeCacheBuilder<K, V> ticker(Ticker ticker) {
@ -242,6 +255,8 @@ public class SafeCacheBuilder<K, V> {
* <b>Note:</b> when this method is used, the resulting cache will use
* identity ({@code ==}) comparison to determine equality of values.
*
* @return This for chaining
*
* @throws IllegalStateException if the value strength was already set
*/
public SafeCacheBuilder<K, V> softValues() {
@ -257,6 +272,8 @@ public class SafeCacheBuilder<K, V> {
* <b>Warning:</b> when this method is used, the resulting cache will use
* identity ({@code ==}) comparison to determine equality of keys.
*
* @return This for chaining
*
* @throws IllegalStateException if the key strength was already set
*/
public SafeCacheBuilder<K, V> weakKeys() {
@ -277,6 +294,8 @@ public class SafeCacheBuilder<K, V> {
* <b>Note:</b> when this method is used, the resulting cache will use
* identity ({@code ==}) comparison to determine equality of values.
*
* @return This for chaining
*
* @throws IllegalStateException if the value strength was already set
*/
public SafeCacheBuilder<K, V> weakValues() {

View File

@ -50,6 +50,9 @@ public class BlockPosition {
/**
* Construct an immutable 3D vector.
* @param x - x coordinate
* @param y - y coordinate
* @param z - z coordinate
*/
public BlockPosition(int x, int y, int z) {
this.x = x;

View File

@ -210,6 +210,8 @@ public class BukkitConverters {
/**
* Retrieve an equivalent converter for a map of generic keys and primitive values.
* @param <T> Key type
* @param <U> Value type
* @param genericKeyType - the generic key type.
* @param keyConverter - an equivalent converter for the generic type.
* @return An equivalent converter.
@ -264,6 +266,7 @@ public class BukkitConverters {
/**
* Retrieve an equivalent converter for a list of generic items.
* @param <T> Type
* @param genericItemType - the generic item type.
* @param itemConverter - an equivalent converter for the generic type.
* @return An equivalent converter.
@ -320,6 +323,7 @@ public class BukkitConverters {
/**
* Retrieve an equivalent converter for an array of generic items.
* @param <T> Type
* <p>
* The array is wrapped in a list.
* @param genericItemType - the generic item type.
@ -878,6 +882,7 @@ public class BukkitConverters {
/**
* Wraps a given equivalent converter in NULL checks, ensuring that such values are ignored.
* @param <TType> Type
* @param delegate - the underlying equivalent converter.
* @return A equivalent converter that ignores NULL values.
*/

View File

@ -2,16 +2,16 @@
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
* Copyright (C) 2012 Kristian S. Stangeland
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*/
@ -51,6 +51,9 @@ public class ChunkPosition {
/**
* Construct an immutable 3D vector.
* @param x - x coordinate
* @param y - y coordinate
* @param z - z coordinate
*/
public ChunkPosition(int x, int y, int z) {
this.x = x;
@ -173,7 +176,7 @@ public class ChunkPosition {
@Override
public ChunkPosition getSpecific(Object generic) {
if (MinecraftReflection.isChunkPosition(generic)) {
// Use a structure modifier
// Use a structure modifier
intModifier = new StructureModifier<Object>(generic.getClass(), null, false).withType(int.class);
// Damn it all
@ -189,7 +192,7 @@ public class ChunkPosition {
} catch (FieldAccessException e) {
// This is an exeptional work-around, so we don't want to burden the caller with the messy details
throw new RuntimeException("Field access error.", e);
}
}
}
}

View File

@ -51,6 +51,7 @@ public class TroveWrapper {
*/
public static ReadOnlyFieldAccessor wrapMapField(final FieldAccessor accessor, final Function<Integer, Integer> noEntryTransform) {
return new ReadOnlyFieldAccessor() {
@Override
public Object get(Object instance) {
Object troveMap = accessor.get(instance);
@ -59,6 +60,7 @@ public class TroveWrapper {
TroveWrapper.transformNoEntryValue(troveMap, noEntryTransform);
return getDecoratedMap(troveMap);
}
@Override
public Field getField() {
return accessor.getField();
}
@ -72,9 +74,11 @@ public class TroveWrapper {
*/
public static ReadOnlyFieldAccessor wrapSetField(final FieldAccessor accessor) {
return new ReadOnlyFieldAccessor() {
@Override
public Object get(Object instance) {
return getDecoratedSet(accessor.get(instance));
}
@Override
public Field getField() {
return accessor.getField();
}
@ -88,9 +92,11 @@ public class TroveWrapper {
*/
public static ReadOnlyFieldAccessor wrapListField(final FieldAccessor accessor) {
return new ReadOnlyFieldAccessor() {
@Override
public Object get(Object instance) {
return getDecoratedList(accessor.get(instance));
}
@Override
public Field getField() {
return accessor.getField();
}
@ -99,6 +105,8 @@ public class TroveWrapper {
/**
* Retrieve a Java wrapper for the corresponding Trove map.
* @param <TKey> Key type
* @param <TValue> Value type
* @param troveMap - the trove map to wrap.
* @return The wrapped GNU Trove map.
* @throws IllegalStateException If GNU Trove cannot be found in the class map.
@ -113,6 +121,7 @@ public class TroveWrapper {
/**
* Retrieve a Java wrapper for the corresponding Trove set.
* @param <TValue> Type
* @param troveSet - the trove set to wrap.
* @return The wrapped GNU Trove set.
* @throws IllegalStateException If GNU Trove cannot be found in the class map.
@ -127,6 +136,7 @@ public class TroveWrapper {
/**
* Retrieve a Java wrapper for the corresponding Trove list.
* @param <TValue> Type
* @param troveList - the trove list to wrap.
* @return The wrapped GNU Trove list.
* @throws IllegalStateException If GNU Trove cannot be found in the class map.
@ -185,7 +195,7 @@ public class TroveWrapper {
}
/**
* Retrieve the corresponding decorator.
* Retrieve the corresponding decorator.
* @param trove - the trove class.
* @return The wrapped trove class.
*/

View File

@ -121,13 +121,14 @@ public class WrappedAttribute extends AbstractWrapper {
*/
public PacketContainer getParentPacket() {
return new PacketContainer(
PacketType.Play.Server.UPDATE_ATTRIBUTES,
PacketType.Play.Server.UPDATE_ATTRIBUTES,
modifier.withType(MinecraftReflection.getPacketClass()).read(0)
);
}
/**
* Determine if the attribute has a given attribute modifier, identified by UUID.
* @param id - the id to check for.
* @return TRUE if it does, FALSE otherwise.
*/
public boolean hasModifier(UUID id) {
@ -154,13 +155,13 @@ public class WrappedAttribute extends AbstractWrapper {
* Retrieve an immutable set of all the attribute modifiers that will compute the final value of this attribute.
* @return Every attribute modifier.
*/
public Set<WrappedAttributeModifier> getModifiers() {
public Set<WrappedAttributeModifier> getModifiers() {
if (attributeModifiers == null) {
@SuppressWarnings("unchecked")
Collection<Object> collection = (Collection<Object>) modifier.withType(Collection.class).read(0);
// Convert to an equivalent wrapper
ConvertedSet<Object, WrappedAttributeModifier> converted =
ConvertedSet<Object, WrappedAttributeModifier> converted =
new ConvertedSet<Object, WrappedAttributeModifier>(getSetSafely(collection)) {
@Override
protected Object toInner(WrappedAttributeModifier outer) {
@ -197,7 +198,7 @@ public class WrappedAttribute extends AbstractWrapper {
return getBaseValue() == other.getBaseValue() &&
Objects.equal(getAttributeKey(), other.getAttributeKey()) &&
Sets.symmetricDifference(
getModifiers(),
getModifiers(),
other.getModifiers()
).isEmpty();
}
@ -229,7 +230,7 @@ public class WrappedAttribute extends AbstractWrapper {
x += modifier.getAmount();
break;
case 1: // Multiply percentage
y += x * modifier.getAmount();
y += x * modifier.getAmount();
break;
case 2:
y *= 1 + modifier.getAmount();
@ -280,7 +281,7 @@ public class WrappedAttribute extends AbstractWrapper {
}
/**
* Represents a builder for wrapped attributes.
* Represents a builder for wrapped attributes.
* <p>
* Use {@link WrappedAttribute#newBuilder()} to construct it.
* @author Kristian
@ -390,9 +391,9 @@ public class WrappedAttribute extends AbstractWrapper {
try {
Object handle = ATTRIBUTE_CONSTRUCTOR.newInstance(
packet.getHandle(),
attributeKey,
baseValue,
packet.getHandle(),
attributeKey,
baseValue,
getUnwrappedModifiers());
// Create it

View File

@ -322,6 +322,7 @@ public class WrappedDataWatcher extends AbstractWrapper implements Iterable<Wrap
/**
* Retrieve the ID of a given type, if it's allowed to be watched.
* @param clazz - Class to check for.
* @return The ID, or NULL if it cannot be watched.
* @throws FieldAccessException If we cannot initialize the reflection machinery.
*/
@ -609,7 +610,8 @@ public class WrappedDataWatcher extends AbstractWrapper implements Iterable<Wrap
* @param newValue - the new watched value.
* @param secondary - optional secondary value.
* @param update - whether or not to refresh every listening client.
* @throws FieldAccessException Cannot read underlying field.
* @param type - custom type.
* @throws FieldAccessException If we cannot read the underlying field.
*/
public void setObject(int index, Object newValue, Object secondary, boolean update, CustomType type) throws FieldAccessException {
Object created = type.newInstance(newValue, secondary);

View File

@ -148,6 +148,7 @@ public class WrappedGameProfile extends AbstractWrapper {
* Construct a wrapper around an existing game profile.
*
* @param handle - the underlying profile, or NULL.
* @return A wrapper around an existing game profile.
*/
public static WrappedGameProfile fromHandle(Object handle) {
if (handle == null)

View File

@ -445,6 +445,7 @@ public class WrappedServerPing extends AbstractWrapper {
/**
* Retrieve a compressed image from an image.
* @param image - the image.
* @return A compressed image from an image.
* @throws IOException If we were unable to compress the image.
*/
public static CompressedImage fromPng(RenderedImage image) throws IOException {

View File

@ -184,7 +184,6 @@ public class WrappedWatchableObject extends AbstractWrapper {
/**
* Retrieve the type ID of a watchable object.
* <p>
* <table border=1>
* <caption>Type to Value</caption>
* <tbody>

View File

@ -2,16 +2,16 @@
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
* Copyright (C) 2012 Kristian S. Stangeland
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*/
@ -84,6 +84,7 @@ public abstract class ConvertedMap<Key, VInner, VOuter> extends AbstractConverte
/**
* Convert a value from the inner map to the outer visible map.
* @param key - unused value.
* @param inner - the inner value.
* @return The outer value.
*/
@ -93,6 +94,7 @@ public abstract class ConvertedMap<Key, VInner, VOuter> extends AbstractConverte
/**
* Convert a value from the outer map to the internal inner map.
* @param key - unused value.
* @param outer - the outer value.
* @return The inner value.
*/
@ -161,7 +163,8 @@ public abstract class ConvertedMap<Key, VInner, VOuter> extends AbstractConverte
*
* @return a string representation of this map
*/
public String toString() {
@Override
public String toString() {
Iterator<Entry<Key, VOuter>> i = entrySet().iterator();
if (!i.hasNext())
return "{}";
@ -189,7 +192,7 @@ public abstract class ConvertedMap<Key, VInner, VOuter> extends AbstractConverte
* @return The converted set of entries.
*/
static <Key, VInner, VOuter> Set<Entry<Key, VOuter>> convertedEntrySet(
final Collection<Entry<Key, VInner>> entries,
final Collection<Entry<Key, VInner>> entries,
final BiFunction<Key, VOuter, VInner> innerFunction,
final BiFunction<Key, VInner, VOuter> outerFunction) {
@ -209,7 +212,7 @@ public abstract class ConvertedMap<Key, VInner, VOuter> extends AbstractConverte
@Override
public VInner setValue(VInner value) {
return innerFunction.apply(getKey(), outer.setValue(outerFunction.apply(getKey(), value)));
return innerFunction.apply(getKey(), outer.setValue(outerFunction.apply(getKey(), value)));
}
@Override
@ -235,7 +238,7 @@ public abstract class ConvertedMap<Key, VInner, VOuter> extends AbstractConverte
@Override
public VOuter setValue(VOuter value) {
final VInner converted = innerFunction.apply(getKey(), value);
return outerFunction.apply(getKey(), inner.setValue(converted));
return outerFunction.apply(getKey(), inner.setValue(converted));
}
@Override

View File

@ -37,6 +37,7 @@ public interface NbtCompound extends NbtBase<Map<String, NbtBase<?>>>, Iterable<
/**
* Retrieve the value of a given entry.
* @param <T> Type
* @param key - key of the entry to retrieve.
* @return The value of this entry, or NULL if not found.
*/
@ -52,6 +53,7 @@ public interface NbtCompound extends NbtBase<Map<String, NbtBase<?>>>, Iterable<
/**
* Set a entry based on its name.
* @param <T> Type
* @param entry - entry with a name and value.
* @return This compound, for chaining.
* @throws IllegalArgumentException If entry is NULL.
@ -302,6 +304,7 @@ public interface NbtCompound extends NbtBase<Map<String, NbtBase<?>>>, Iterable<
/**
* Retrieve the NBT list value of an entry identified by a given key.
* @param <T> Type
* @param key - the key of the entry.
* @return The NBT list value of the entry.
* @throws IllegalArgumentException If the key doesn't exist.
@ -310,6 +313,7 @@ public interface NbtCompound extends NbtBase<Map<String, NbtBase<?>>>, Iterable<
/**
* Retrieve a NBT list value by its key, or create a new list if it doesn't exist.
* @param <T> Type
* @param key - the key of the entry to find or create.
* @return The compound value that was retrieved or just created.
*/
@ -317,6 +321,7 @@ public interface NbtCompound extends NbtBase<Map<String, NbtBase<?>>>, Iterable<
/**
* Associate a NBT list with the given key.
* @param <T> Type
* @param list - the list value.
* @return This current compound, for chaining.
*/
@ -324,6 +329,7 @@ public interface NbtCompound extends NbtBase<Map<String, NbtBase<?>>>, Iterable<
/**
* Associate a new NBT list with the given key.
* @param <T> Type
* @param key - the key and name of the new NBT list.
* @param list - the list of NBT elements.
* @return This current compound, for chaining.
@ -332,6 +338,7 @@ public interface NbtCompound extends NbtBase<Map<String, NbtBase<?>>>, Iterable<
/**
* Remove the NBT element that is associated with the given key.
* @param <T> Type
* @param key - the key of the element to remove.
* @return The removed element, or NULL if no such element was found.
*/

View File

@ -94,6 +94,8 @@ public class NbtFactory {
* Get a NBT wrapper from a NBT base.
* <p>
* This may clone the content if the NbtBase is not a NbtWrapper.
*
* @param <T> Type
* @param base - the base class.
* @return A NBT wrapper.
*/
@ -282,6 +284,7 @@ public class NbtFactory {
* Initialize a NBT wrapper.
* <p>
* Use {@link #fromNMS(Object, String)} instead.
* @param <T> Type
* @param handle - the underlying net.minecraft.server object to wrap.
* @return A NBT wrapper.
*/
@ -301,6 +304,7 @@ public class NbtFactory {
/**
* Initialize a NBT wrapper with a name.
* @param <T> Type
* @param name - the name of the tag, or NULL if not valid.
* @param handle - the underlying net.minecraft.server object to wrap.
* @return A NBT wrapper.
@ -460,6 +464,7 @@ public class NbtFactory {
/**
* Create a new NBT wrapper from a given type.
* @param <T> Type
* @param type - the NBT type.
* @param name - the name of the NBT tag.
* @return The new wrapped NBT tag.
@ -539,6 +544,7 @@ public class NbtFactory {
/**
* Create a new NBT wrapper from a given type.
* @param <T> Type
* @param type - the NBT type.
* @param name - the name of the NBT tag.
* @param value - the value of the new tag.
@ -555,6 +561,7 @@ public class NbtFactory {
/**
* Create a new NBT wrapper from a given type.
* @param <T> Type
* @param type - type of the NBT value.
* @param name - the name of the NBT tag.
* @param value - the value of the new tag.

View File

@ -46,7 +46,7 @@ public interface NbtList<TType> extends NbtBase<List<NbtBase<TType>>>, Iterable<
/**
* Add a NBT list or NBT compound to the list.
* @param element
* @param element Element to add
*/
public abstract void add(NbtBase<TType> element);

View File

@ -102,6 +102,7 @@ public class NbtBinarySerializer {
/**
* Load an NBT tag from a stream.
* @param <TType> Type
* @param source - the input stream.
* @return An NBT tag.
*/

View File

@ -69,6 +69,7 @@ public class NbtConfigurationSerializer {
/**
* Write the content of a NBT tag to a configuration section.
* @param <TType> Type
* @param value - the NBT tag to write.
* @param destination - the destination section.
*/
@ -143,7 +144,7 @@ public class NbtConfigurationSerializer {
private Integer getNextIndex() {
Integer listIndex = workingIndex.get(current);
if (listIndex != null)
if (listIndex != null)
return workingIndex.put(current, listIndex + 1);
else
return null;
@ -167,7 +168,8 @@ public class NbtConfigurationSerializer {
}
/**
* Read a NBT tag from a root configuration.
* Read a NBT tag from a root configuration.
* @param <TType> Type
* @param root - configuration that contains the NBT tag.
* @param nodeName - name of the NBT tag.
* @return The read NBT tag.
@ -178,7 +180,7 @@ public class NbtConfigurationSerializer {
}
/**
* Read a NBT compound from a root configuration.
* Read a NBT compound from a root configuration.
* @param root - configuration that contains the NBT compound.
* @param nodeName - name of the NBT compound.
* @return The read NBT compound.
@ -188,7 +190,8 @@ public class NbtConfigurationSerializer {
}
/**
* Read a NBT compound from a root configuration.
* Read a NBT compound from a root configuration.
* @param <T> Type
* @param root - configuration that contains the NBT compound.
* @param nodeName - name of the NBT compound.
* @return The read NBT compound.
@ -248,7 +251,7 @@ public class NbtConfigurationSerializer {
ConfigurationSection section = (ConfigurationSection) node;
// As above
for (String key : section.getKeys(false))
for (String key : section.getKeys(false))
compound.put(readNode(section, key));
return (NbtWrapper<?>) compound;
}
@ -315,7 +318,7 @@ public class NbtConfigurationSerializer {
* @return An equivalent byte array.
*/
private static byte[] toByteArray(int[] data) {
ByteBuffer byteBuffer = ByteBuffer.allocate(data.length * 4);
ByteBuffer byteBuffer = ByteBuffer.allocate(data.length * 4);
IntBuffer intBuffer = byteBuffer.asIntBuffer();
intBuffer.put(data);

View File

@ -48,6 +48,7 @@ public class NbtTextSerializer {
/**
* Serialize a NBT tag to a base-64 encoded string.
* @param <TType> Type
* @param value - the NBT tag to serialize.
* @return The NBT tag in base-64 form.
*/
@ -63,6 +64,7 @@ public class NbtTextSerializer {
/**
* Deserialize a NBT tag from a base-64 encoded string.
* @param <TType> Type
* @param input - the base-64 string.
* @return The NBT tag contained in the string.
* @throws IOException If we are unable to parse the input.
@ -87,6 +89,7 @@ public class NbtTextSerializer {
/**
* Deserialize a NBT list from a base-64 encoded string.
* @param <T> Type
* @param input - the base-64 string.
* @return The NBT tag contained in the string.
* @throws IOException If we are unable to parse the input.