Archiviert
13
0

Fix a ton of JavaDoc errors

Dieser Commit ist enthalten in:
Dan Mulloy 2015-06-17 14:25:39 -04:00
Ursprung 241003b56a
Commit bba1054f97
64 geänderte Dateien mit 529 neuen und 466 gelöschten Zeilen

Datei anzeigen

@ -295,7 +295,7 @@ public class CommandFilter extends CommandBase {
@Override
public boolean handle(PacketEvent event, Filter filter, Exception ex) {
reporter.reportMinimal(plugin, "filterEvent(PacketEvent)", ex, event);
reporter.reportWarning(this,
reporter.reportWarning(this,
Report.newBuilder(REPORT_FILTER_REMOVED_FOR_ERROR).messageParam(filter.getName(), ex.getClass().getSimpleName())
);
return false;
@ -321,7 +321,7 @@ public class CommandFilter extends CommandBase {
* @param event - the event.
* @param handler - failure handler.
* @return TRUE if we should, FALSE otherwise.
* @throws FilterFailedException If one of the filters failed.
* @throws ScriptException If one of the filters failed.
*/
public boolean filterEvent(PacketEvent event, FilterFailedHandler handler) {
for (Iterator<Filter> it = filters.iterator(); it.hasNext(); ) {
@ -389,7 +389,7 @@ public class CommandFilter extends CommandBase {
// Make sure we can use the conversable interface
if (sender instanceof Conversable) {
final MultipleLinesPrompt prompt =
final MultipleLinesPrompt prompt =
new MultipleLinesPrompt(new CompilationSuccessCanceller(), "function(event, packet) {");
new ConversationFactory(plugin).
@ -424,7 +424,7 @@ public class CommandFilter extends CommandBase {
whom.sendRawMessage(ChatColor.RED + "Cancelled filter.");
}
} catch (Exception e) {
reporter.reportDetailed(this,
reporter.reportDetailed(this,
Report.newBuilder(REPORT_CANNOT_HANDLE_CONVERSATION).error(e).callerParam(event)
);
}

Datei anzeigen

@ -823,6 +823,7 @@ public class PacketType implements Serializable, Comparable<PacketType> {
* Construct a legacy packet type.
* @param sender - client or server.
* @param legacyId - the legacy packet ID.
* @return Legacy packet type
*/
public static PacketType newLegacy(Sender sender, int legacyId) {
return new PacketType(Protocol.LEGACY, sender, PacketType.UNKNOWN_PACKET, legacyId, MinecraftVersion.WORLD_UPDATE);

Datei anzeigen

@ -423,7 +423,7 @@ public class ProtocolConfig {
/**
* Set the starting injection method to use.
* @return Injection method.
* @param hook Injection method
*/
public void setInjectionMethod(PlayerInjectHooks hook) {
setConfig(global, INJECTION_METHOD, hook.name());

Datei anzeigen

@ -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
*/
@ -53,7 +53,7 @@ public interface ProtocolManager extends PacketStream {
/**
* Send a packet to the given player.
* <p>
* Re-sending a previously cancelled packet is discouraged. Use {@link AsyncMarker#incrementProcessingDelay()}
* Re-sending a previously cancelled packet is discouraged. Use {@link AsyncMarker#incrementProcessingDelay()}
* to delay a packet until a certain condition has been met.
*
* @param receiver - the receiver.
@ -62,13 +62,13 @@ public interface ProtocolManager extends PacketStream {
* @throws InvocationTargetException - if an error occurred when sending the packet.
*/
@Override
public void sendServerPacket(Player receiver, PacketContainer packet, boolean filters)
public void sendServerPacket(Player receiver, PacketContainer packet, boolean filters)
throws InvocationTargetException;
/**
* Simulate receiving a certain packet from a given player.
* <p>
* Receiving a previously cancelled packet is discouraged. Use {@link AsyncMarker#incrementProcessingDelay()}
* Receiving a previously cancelled packet is discouraged. Use {@link AsyncMarker#incrementProcessingDelay()}
* to delay a packet until a certain condition has been met.
*
* @param sender - the sender.
@ -78,7 +78,7 @@ public interface ProtocolManager extends PacketStream {
* @throws IllegalAccessException If the underlying method caused an error.
*/
@Override
public void recieveClientPacket(Player sender, PacketContainer packet, boolean filters)
public void recieveClientPacket(Player sender, PacketContainer packet, boolean filters)
throws IllegalAccessException, InvocationTargetException;
/**
@ -89,9 +89,9 @@ public interface ProtocolManager extends PacketStream {
public void broadcastServerPacket(PacketContainer packet);
/**
* Broadcast a packet to every player that is receiving information about a given entity.
* Broadcast a packet to every player that is receiving information about a given entity.
* <p>
* This is usually every player in the same world within an observable distance. If the entity is a
* This is usually every player in the same world within an observable distance. If the entity is a
* player, it will only be included if <i>includeTracker</i> is TRUE.
* @param packet - the packet to broadcast.
* @param entity - the entity whose trackers we will inform.
@ -115,17 +115,17 @@ public interface ProtocolManager extends PacketStream {
public ImmutableSet<PacketListener> getPacketListeners();
/**
* Adds a packet listener.
* Adds a packet listener.
* <p>
* Adding an already registered listener has no effect. If you need to change the packets
* the current listener is observing, you must first remove the packet listener before you
* Adding an already registered listener has no effect. If you need to change the packets
* the current listener is observing, you must first remove the packet listener before you
* can register it again.
* @param listener - new packet listener.
*/
public void addPacketListener(PacketListener listener);
/**
* Removes a given packet listener.
* Removes a given packet listener.
* <p>
* Attempting to remove a listener that doesn't exist has no effect.
* @param listener - the packet listener to remove.
@ -158,7 +158,7 @@ public interface ProtocolManager extends PacketStream {
/**
* Constructs a new encapsulated Minecraft packet with the given ID.
* <p>
* If set to true, the <i>forceDefaults</i> option will force the system to automatically
* If set to true, the <i>forceDefaults</i> option will force the system to automatically
* give non-primitive fields in the packet sensible default values. For instance, certain
* packets - like Packet60Explosion - require a List or Set to be non-null. If the
* forceDefaults option is true, the List or Set will be automatically created.
@ -175,7 +175,7 @@ public interface ProtocolManager extends PacketStream {
/**
* Constructs a new encapsulated Minecraft packet with the given ID.
* <p>
* If set to true, the <i>forceDefaults</i> option will force the system to automatically
* If set to true, the <i>forceDefaults</i> option will force the system to automatically
* give non-primitive fields in the packet sensible default values. For instance, certain
* packets - like Packet60Explosion - require a List or Set to be non-null. If the
* forceDefaults option is true, the List or Set will be automatically created.
@ -199,7 +199,7 @@ public interface ProtocolManager extends PacketStream {
/**
* Construct a packet using the special builtin Minecraft constructors.
* @param id - the packet type.
* @param type - the packet type.
* @param arguments - arguments that will be passed to the constructor.
* @return The packet constructor.
*/
@ -208,7 +208,7 @@ public interface ProtocolManager extends PacketStream {
/**
* Completely resend an entity to a list of clients.
* <p>
* Note that this method is NOT thread safe. If you call this method from anything
* Note that this method is NOT thread safe. If you call this method from anything
* but the main thread, it will throw an exception.
* @param entity - entity to refresh.
* @param observers - the clients to update.
@ -269,7 +269,7 @@ public interface ProtocolManager extends PacketStream {
public MinecraftVersion getMinecraftVersion();
/**
* Determines whether or not this protocol manager has been disabled.
* Determines whether or not this protocol manager has been disabled.
* @return TRUE if it has, FALSE otherwise.
*/
public boolean isClosed();

Datei anzeigen

@ -373,7 +373,6 @@ public class AsyncFilterManager implements AsynchronousManager {
/**
* Construct an async marker with the given sending priority delta and timeout delta.
* @param sendingDelta - how many packets we're willing to wait.
* @param timeoutDelta - how long (in ms) until the packet expire.
* @return An async marker.
*/
@ -473,6 +472,8 @@ public class AsyncFilterManager implements AsynchronousManager {
/**
* Send any due packets, or clean up packets that have expired.
* @param tickCounter Tick counter
* @param onMainThread Whether or not to execute on the main thread
*/
public void sendProcessedPackets(int tickCounter, boolean onMainThread) {
// The server queue is unlikely to need checking that often

Datei anzeigen

@ -402,6 +402,7 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
/**
* Determine if Minecraft allows asynchronous processing of this packet.
* @return TRUE if it does, FALSE otherwise.
* @throws FieldAccessException If determining fails for some reasaon
*/
public boolean isMinecraftAsync(PacketEvent event) throws FieldAccessException {
if (isMinecraftAsync == null && !alwaysSync) {

Datei anzeigen

@ -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
*/
@ -35,6 +35,7 @@ public interface AsyncRunnable extends Runnable {
* <p>
* This may not occur right away.
* @return TRUE if the thread was stopped, FALSE if it was already stopped.
* @throws InterruptedException if it is interrupted
*/
public boolean stop() throws InterruptedException;

Datei anzeigen

@ -18,6 +18,7 @@ public class IntegerMap<T> {
/**
* Construct a new integer map.
* @param <T> Parameter type
* @return A new integer map.
*/
public static <T> IntegerMap<T> newMap() {
@ -51,7 +52,7 @@ public class IntegerMap<T> {
public T put(int key, T value) {
ensureCapacity(key);
T old = array[key];
T old = array[key];
array[key] = Preconditions.checkNotNull(value, "value cannot be NULL");
if (old == null)

Datei anzeigen

@ -149,6 +149,7 @@ public abstract class AbstractIntervalTree<TKey extends Comparable<TKey>, TValue
* @param lowerBound - lowest value to remove.
* @param upperBound - highest value to remove.
* @param preserveDifference - whether or not to preserve the intervals that are partially outside.
* @return Intervals that were removed
*/
public Set<Entry> remove(TKey lowerBound, TKey upperBound, boolean preserveDifference) {
checkBounds(lowerBound, upperBound);

Datei anzeigen

@ -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,6 +48,8 @@ public class BlockingHashMap<TKey, TValue> {
/**
* Retrieve a cache loader that will always throw an exception.
* @param <TKey> Type of the key
* @param <TValue> Type of the value
* @return An invalid cache loader.
*/
public static <TKey, TValue> CacheLoader<TKey, TValue> newInvalidCacheLoader() {
@ -83,6 +85,8 @@ public class BlockingHashMap<TKey, TValue> {
/**
* Initialize a new map.
* @param <TKey> Type of the key
* @param <TValue> Type of the value
* @return The created map.
*/
public static <TKey, TValue> BlockingHashMap<TKey, TValue> create() {
@ -91,7 +95,7 @@ public class BlockingHashMap<TKey, TValue> {
/**
* Waits until a value has been associated with the given key, and then retrieves that value.
* @param key - the key whose associated value is to be returned
* @param key - the key whose associated value is to be returned
* @return The value to which the specified key is mapped.
* @throws InterruptedException If the current thread got interrupted while waiting.
*/
@ -118,7 +122,7 @@ public class BlockingHashMap<TKey, TValue> {
/**
* Waits until a value has been associated with the given key, and then retrieves that value.
* @param key - the key whose associated value is to be returned
* @param key - the key whose associated value is to be returned
* @param timeout - the amount of time to wait until an association has been made.
* @param unit - unit of timeout.
* @return The value to which the specified key is mapped, or NULL if the timeout elapsed.
@ -133,7 +137,7 @@ public class BlockingHashMap<TKey, TValue> {
* <p>
* If timeout is zero, this method will return immediately if it can't find an socket injector.
*
* @param key - the key whose associated value is to be returned
* @param key - the key whose associated value is to be returned
* @param timeout - the amount of time to wait until an association has been made.
* @param unit - unit of timeout.
* @param ignoreInterrupted - TRUE if we should ignore the thread being interrupted, FALSE otherwise.

Datei anzeigen

@ -6,7 +6,6 @@ import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -70,6 +69,7 @@ public class ConcurrentPlayerMap<TValue> extends AbstractMap<Player, TValue> imp
/**
* Construct a new concurrent player map that uses each player's address as key.
* @param <T> Parameter type
* @return Concurrent player map.
*/
public static <T> ConcurrentPlayerMap<T> usingAddress() {
@ -78,6 +78,7 @@ public class ConcurrentPlayerMap<TValue> extends AbstractMap<Player, TValue> imp
/**
* Construct a new concurrent player map that uses each player's name as key.
* @param <T> Parameter type
* @return Concurrent player map.
*/
public static <T> ConcurrentPlayerMap<T> usingName() {
@ -177,7 +178,6 @@ public class ConcurrentPlayerMap<TValue> extends AbstractMap<Player, TValue> imp
* Lookup a player by key in the cache, optionally searching every online player.
* @param key - the key of the player we are locating.
* @return The player, or NULL if not found.
* @throws ExecutionException
*/
protected Player lookupPlayer(Object key) {
try {
@ -293,7 +293,7 @@ public class ConcurrentPlayerMap<TValue> extends AbstractMap<Player, TValue> imp
private Iterator<Entry<Player, TValue>> entryIterator() {
// Skip entries with stale data
final Iterator<Entry<Object, TValue>> source = valueLookup.entrySet().iterator();
final AbstractIterator<Entry<Player,TValue>> filtered =
final AbstractIterator<Entry<Player,TValue>> filtered =
new AbstractIterator<Entry<Player,TValue>>() {
@Override
protected Entry<Player, TValue> computeNext() {
@ -315,12 +315,15 @@ public class ConcurrentPlayerMap<TValue> extends AbstractMap<Player, TValue> imp
// We can't return AbstractIterator directly, as it doesn't permitt the remove() method
return new Iterator<Entry<Player, TValue>>() {
@Override
public boolean hasNext() {
return filtered.hasNext();
}
@Override
public Entry<Player, TValue> next() {
return filtered.next();
}
@Override
public void remove() {
source.remove();
}

Datei anzeigen

@ -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
*/
@ -25,7 +25,7 @@ import java.util.Set;
/**
* Represents a very quick integer set that uses a lookup table to store membership.
* <p>
* This class is intentionally missing a size method.
* This class is intentionally missing a size method.
* @author Kristian
*/
public class IntegerSet {
@ -67,7 +67,7 @@ public class IntegerSet {
/**
* Add the given element to the set, or do nothing if it already exists.
* @param element - element to add.
* @throws OutOfBoundsException If the given element is not in the range [0, count).
* @throws ArrayIndexOutOfBoundsException If the given element is not in the range [0, count).
*/
public void add(int element) {
array[element] = true;

Datei anzeigen

@ -65,7 +65,7 @@ public class PacketTypeSet {
/**
* Remove the given types from the set.
* @param type - the types to remove.
* @param types Types to remove
*/
public synchronized void removeAll(Iterable<? extends PacketType> types) {
for (PacketType type : types) {
@ -101,7 +101,7 @@ public class PacketTypeSet {
}
/**
* Determine if the type of a packet is in the current set.
* Determine if the type of a packet is in the current set.
* @param packet - the packet.
* @return TRUE if it is, FALSE otherwise.
*/

Datei anzeigen

@ -93,6 +93,7 @@ public class DetailedErrorReporter implements ErrorReporter {
/**
* Create a default error reporting system.
* @param plugin - the plugin owner.
*/
public DetailedErrorReporter(Plugin plugin) {
this(plugin, DEFAULT_PREFIX, DEFAULT_SUPPORT_URL);

Datei anzeigen

@ -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
*/
@ -56,20 +56,20 @@ public interface ErrorReporter {
/**
* Prints a debug message from the current sender.
* @param sender - the sender.
* @param report - the report builder.
* @param builder - the report builder.
*/
public abstract void reportDebug(Object sender, ReportBuilder builder);
/**
* Prints a warning message from the current plugin.
* @param sender - the object containing the caller method.
* @param sender - the object containing the caller method.
* @param report - an error report to include.
*/
public abstract void reportWarning(Object sender, Report report);
/**
* Prints a warning message from the current plugin.
* @param sender - the object containing the caller method.
* @param sender - the object containing the caller method.
* @param reportBuilder - an error report builder that will be used to get the report.
*/
public abstract void reportWarning(Object sender, ReportBuilder reportBuilder);

Datei anzeigen

@ -10,7 +10,7 @@ import javax.annotation.Nullable;
*
* @author Kristian
*/
public class Report {
public class Report {
private final ReportType type;
private final Throwable exception;
private final Object[] messageParameters;
@ -76,7 +76,7 @@ public class Report {
}
/**
* Set the minimum number of nanoseconds to wait until a report of equal type and parameters
* Set the minimum number of nanoseconds to wait until a report of equal type and parameters
* is allowed to be printed again.
* @param rateLimit - number of nanoseconds, or 0 to disable. Cannot be negative.
* @return This builder, for chaining.
@ -122,8 +122,8 @@ public class Report {
* @param type - the report type that will be used to construct the message.
* @param messageParameters - parameters used to construct the report message.
* @param callerParameters - parameters from the caller method.
*/
protected Report(ReportType type, @Nullable Throwable exception,
*/
protected Report(ReportType type, @Nullable Throwable exception,
@Nullable Object[] messageParameters, @Nullable Object[] callerParameters) {
this(type, exception, messageParameters, callerParameters, 0);
}
@ -135,8 +135,8 @@ public class Report {
* @param messageParameters - parameters used to construct the report message.
* @param callerParameters - parameters from the caller method.
* @param rateLimit - minimum number of nanoseconds to wait until a report of equal type and parameters is allowed to be printed again.
*/
protected Report(ReportType type, @Nullable Throwable exception,
*/
protected Report(ReportType type, @Nullable Throwable exception,
@Nullable Object[] messageParameters, @Nullable Object[] callerParameters, long rateLimit) {
if (type == null)
throw new IllegalArgumentException("type cannot be NULL.");
@ -157,7 +157,7 @@ public class Report {
/**
* Retrieve the message parameters that will be used to construc the report message.
* <p<
* <p>
* This should not be confused with the method parameters of the caller method.
* @return Message parameters.
*/
@ -231,8 +231,8 @@ public class Report {
return true;
if (obj instanceof Report) {
Report other = (Report) obj;
return type == other.type &&
Arrays.equals(callerParameters, other.callerParameters) &&
return type == other.type &&
Arrays.equals(callerParameters, other.callerParameters) &&
Arrays.equals(messageParameters, other.messageParameters);
}
return false;

Datei anzeigen

@ -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
*/
@ -47,7 +47,7 @@ public enum ListenerPriority {
HIGHEST(4),
/**
* Event is listened to purely for monitoring the outcome of an event.
* <p/>
* <p>
* No modifications to the event should be made under this priority.
*/
MONITOR(5);

Datei anzeigen

@ -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
*/
@ -32,7 +32,7 @@ import com.google.common.collect.Sets;
/**
* Determines which packets will be observed by a listener, and with what priority.
* @author Kristian
* @author Kristian
*/
public class ListeningWhitelist {
/**
@ -60,7 +60,7 @@ public class ListeningWhitelist {
* <p>
* Deprecated: Use {@link #newBuilder()} instead.
* @param priority - the listener priority.
* @param whitelist - set of IDs to observe/enable.
* @param whitelist - set of IDs to observe/enable.
*/
@Deprecated
public ListeningWhitelist(ListenerPriority priority, Set<Integer> whitelist) {
@ -192,7 +192,7 @@ public class ListeningWhitelist {
/**
* Determine if any of the given IDs can be found in the whitelist.
* @param whitelist - whitelist to test.
* @param idList - list of packet IDs to find.
* @param idList - list of packet IDs to find.
* @return TRUE if any of the packets in the list can be found in the whitelist, FALSE otherwise.
*/
public static boolean containsAny(ListeningWhitelist whitelist, int... idList) {
@ -442,7 +442,7 @@ public class ListeningWhitelist {
/**
* Set the options to copy when constructing new whitelists.
* @param options - the options array.
* @param serverOptions - the options array.
* @return This builder, for chaining.
*/
public Builder options(ListenerOptions[] serverOptions) {
@ -452,7 +452,7 @@ public class ListeningWhitelist {
/**
* Options to merge into the current set of options.
* @param options - the options array.
* @param serverOptions - the options array.
* @return This builder, for chaining.
*/
public Builder mergeOptions(ListenerOptions... serverOptions) {
@ -461,7 +461,7 @@ public class ListeningWhitelist {
/**
* Options to merge into the current set of options.
* @param options - the options array.
* @param serverOptions - the options array.
* @return This builder, for chaining.
*/
public Builder mergeOptions(Collection<ListenerOptions> serverOptions) {

Datei anzeigen

@ -24,12 +24,12 @@ import com.google.common.collect.Lists;
import com.google.common.primitives.Ints;
/**
* Marker containing the serialized packet data seen from the network,
* Marker containing the serialized packet data seen from the network,
* or output handlers that will serialize the current packet.
*
* @author Kristian
*/
public abstract class NetworkMarker {
public abstract class NetworkMarker {
public static class EmptyBufferMarker extends NetworkMarker {
public EmptyBufferMarker(@Nonnull ConnectionSide side) {
super(side, (byte[]) null, null);
@ -48,7 +48,7 @@ public abstract class NetworkMarker {
@Override
protected DataInputStream addHeader(DataInputStream input, PacketType type) {
throw new IllegalStateException("Buffer is empty.");
}
}
}
// Custom network handler
@ -68,8 +68,9 @@ public abstract class NetworkMarker {
/**
* Construct a new network marker.
* @param side - whether or not this marker belongs to a client or server packet.
* @param side - which side this marker belongs to.
* @param inputBuffer - the read serialized packet data.
* @param type - packet type
*/
public NetworkMarker(@Nonnull ConnectionSide side, ByteBuffer inputBuffer, PacketType type) {
this.side = Preconditions.checkNotNull(side, "side cannot be NULL.");
@ -81,9 +82,9 @@ public abstract class NetworkMarker {
* Construct a new network marker.
* <p>
* The input buffer is only non-null for client-side packets.
* @param side - whether or not this marker belongs to a client or server packet.
* @param side - which side this marker belongs to.
* @param inputBuffer - the read serialized packet data.
* @param handler - handle skipping headers.
* @param type - packet type
*/
public NetworkMarker(@Nonnull ConnectionSide side, byte[] inputBuffer, PacketType type) {
this.side = Preconditions.checkNotNull(side, "side cannot be NULL.");
@ -115,7 +116,7 @@ public abstract class NetworkMarker {
/**
* Retrieve the serialized packet data (excluding the header by default) from the network input stream.
* <p>
* The returned buffer is read-only. If the parent event is a server side packet this
* The returned buffer is read-only. If the parent event is a server side packet this
* method throws {@link IllegalStateException}.
* <p>
* It returns NULL if the packet was transmitted by a plugin locally.
@ -128,7 +129,7 @@ public abstract class NetworkMarker {
/**
* Retrieve the serialized packet data from the network input stream.
* <p>
* The returned buffer is read-only. If the parent event is a server side packet this
* The returned buffer is read-only. If the parent event is a server side packet this
* method throws {@link IllegalStateException}.
* <p>
* It returns NULL if the packet was transmitted by a plugin locally.
@ -143,7 +144,7 @@ public abstract class NetworkMarker {
ByteBuffer result = inputBuffer.asReadOnlyBuffer();
try {
if (excludeHeader)
if (excludeHeader)
result = skipHeader(result);
else
result = addHeader(result, type);
@ -158,7 +159,7 @@ public abstract class NetworkMarker {
/**
* Retrieve the serialized packet data (excluding the header by default) as an input stream.
* <p>
* The data is exactly the same as in {@link #getInputBuffer()}.
* The data is exactly the same as in {@link #getInputBuffer()}.
* @see #getInputBuffer()
* @return The incoming serialized packet data as a stream, or NULL if the packet was transmitted locally.
*/
@ -169,7 +170,7 @@ public abstract class NetworkMarker {
/**
* Retrieve the serialized packet data as an input stream.
* <p>
* The data is exactly the same as in {@link #getInputBuffer()}.
* The data is exactly the same as in {@link #getInputBuffer()}.
* @see #getInputBuffer()
* @param excludeHeader - whether or not to exclude the packet ID header.
* @return The incoming serialized packet data as a stream, or NULL if the packet was transmitted locally.
@ -186,7 +187,7 @@ public abstract class NetworkMarker {
);
try {
if (excludeHeader)
if (excludeHeader)
input = skipHeader(input);
else
input = addHeader(input, type);
@ -207,7 +208,7 @@ public abstract class NetworkMarker {
/**
* Enqueue the given output handler for managing how the current packet will be written to the network stream.
* <p>
* Note that output handlers are not serialized, as most consumers will probably implement them using anonymous classes.
* Note that output handlers are not serialized, as most consumers will probably implement them using anonymous classes.
* It is not safe to serialize anonymous classes, as their name depend on the order in which they are declared in the parent class.
* <p>
* This can only be invoked on server side packet events.
@ -261,10 +262,10 @@ public abstract class NetworkMarker {
}
/**
* Add a listener that is invoked after a packet has been successfully sent to the client, or received
* by the server.
* Add a listener that is invoked after a packet has been successfully sent to the client, or received
* by the server.
* <p>
* Received packets are not guarenteed to have been fully processed, but packets passed
* Received packets are not guarenteed to have been fully processed, but packets passed
* to {@link ProtocolManager#recieveClientPacket(Player, PacketContainer)} will be processed after the
* current packet event.
* <p>
@ -324,7 +325,9 @@ public abstract class NetworkMarker {
* Return a byte buffer without the header in the current packet.
* <p>
* It's safe to modify the position of the buffer.
* @param buffer - a read-only byte source.
* @param buffer - a read-only byte source.
* @return A byte buffer without the header in the current packet.
* @throws IOException If integer reading fails
*/
protected ByteBuffer skipHeader(ByteBuffer buffer) throws IOException {
skipHeader(new DataInputStream(new ByteBufferInputStream(buffer)));
@ -335,13 +338,14 @@ public abstract class NetworkMarker {
* Return an input stream without the header in the current packet.
* <p>
* It's safe to modify the input stream.
* @throws IOException If integer reading fails
*/
protected abstract DataInputStream skipHeader(DataInputStream input) throws IOException;
/**
* Return the byte buffer prepended with the packet header.
* @param buffer - the read-only byte buffer.
* @param type - the current packet.
* @param buffer - the read-only byte buffer.
* @param type - the current packet.
* @return The byte buffer.
*/
protected abstract ByteBuffer addHeader(ByteBuffer buffer, PacketType type);
@ -349,7 +353,7 @@ public abstract class NetworkMarker {
/**
* Return the input stream prepended with the packet header.
* @param input - the input stream.
* @param type - the current packet.
* @param type - the current packet.
* @return The byte buffer.
*/
protected abstract DataInputStream addHeader(DataInputStream input, PacketType type);

Datei anzeigen

@ -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
*/
@ -50,7 +50,7 @@ public abstract class PacketAdapter implements PacketListener {
*/
public PacketAdapter(@Nonnull AdapterParameteters params) {
this(
checkValidity(params).plugin, params.connectionSide, params.listenerPriority,
checkValidity(params).plugin, params.connectionSide, params.listenerPriority,
params.gamePhase, params.options, params.packets
);
}
@ -58,7 +58,6 @@ public abstract class PacketAdapter implements PacketListener {
/**
* Initialize a packet listener with the given parameters.
* @param plugin - the plugin.
* @param listenerPriority - the priority.
* @param types - the packet types.
*/
public PacketAdapter(Plugin plugin, PacketType... types) {
@ -241,7 +240,7 @@ public abstract class PacketAdapter implements PacketListener {
*/
@Deprecated
public PacketAdapter(
Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority,
Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority,
GamePhase gamePhase, ListenerOptions[] options, Integer... packets) {
this(plugin, connectionSide, listenerPriority, gamePhase, options,
@ -251,7 +250,7 @@ public abstract class PacketAdapter implements PacketListener {
// For internal use only
private PacketAdapter(
Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority,
Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority,
GamePhase gamePhase, ListenerOptions[] options, PacketType... packets) {
if (plugin == null)
@ -272,7 +271,7 @@ public abstract class PacketAdapter implements PacketListener {
// Special case that allows us to specify optionIntercept().
if (connectionSide == ConnectionSide.BOTH) {
serverOptions = except(serverOptions, new ListenerOptions[0],
serverOptions = except(serverOptions, new ListenerOptions[0],
ListenerOptions.INTERCEPT_INPUT_BUFFER);
}
@ -360,10 +359,10 @@ public abstract class PacketAdapter implements PacketListener {
}
@Override
public String toString() {
// This is used by the error reporter
return String.format("PacketAdapter[plugin=%s, sending=%s, receiving=%s]",
getPluginName(this),
public String toString() {
// This is used by the error reporter
return String.format("PacketAdapter[plugin=%s, sending=%s, receiving=%s]",
getPluginName(this),
sendingWhitelist,
receivingWhitelist);
}
@ -441,7 +440,7 @@ public abstract class PacketAdapter implements PacketListener {
}
/**
* Set this adapter to also look for client-side packets.
* Set this adapter to also look for client-side packets.
* @return This builder, for chaining.
*/
public AdapterParameteters clientSide() {
@ -449,7 +448,7 @@ public abstract class PacketAdapter implements PacketListener {
}
/**
* Set this adapter to also look for server-side packets.
* Set this adapter to also look for server-side packets.
* @return This builder, for chaining.
*/
public AdapterParameteters serverSide() {
@ -457,7 +456,7 @@ public abstract class PacketAdapter implements PacketListener {
}
/**
* Set the the event priority, where the execution is in ascending order from lowest to highest.
* Set the the event priority, where the execution is in ascending order from lowest to highest.
* <p>
* Default is {@link ListenerPriority#NORMAL}.
* @param listenerPriority - the new event priority.

Datei anzeigen

@ -164,10 +164,9 @@ public class PacketContainer implements Serializable {
/**
* Creates a packet container for an existing packet.
* <p>
* Deprecated: Use {@link #PacketContainer(PacketType, Object))} instead.
* @param id - ID of the given packet.
* @param handle - contained packet.
* @deprecated Use {@link #PacketContainer(PacketType, Object)} instead
*/
@Deprecated
public PacketContainer(int id, Object handle) {
@ -176,11 +175,10 @@ public class PacketContainer implements Serializable {
/**
* Creates a packet container for an existing packet.
* <p>
* Deprecated: Use {@link #PacketContainer(PacketType, Object, StructureModifier))} instead.
* @param id - ID of the given packet.
* @param handle - contained packet.
* @param structure - structure modifier.
* @deprecated Use {@link #PacketContainer(PacketType, Object, StructureModifier)} instead
*/
@Deprecated
public PacketContainer(int id, Object handle, StructureModifier<Object> structure) {
@ -197,7 +195,7 @@ public class PacketContainer implements Serializable {
/**
* Creates a packet container for an existing packet.
* @param id - ID of the given packet.
* @param type - Type of the given packet.
* @param handle - contained packet.
*/
public PacketContainer(PacketType type, Object handle) {
@ -206,7 +204,7 @@ public class PacketContainer implements Serializable {
/**
* Creates a packet container for an existing packet.
* @param id - ID of the given packet.
* @param type - Type of the given packet.
* @param handle - contained packet.
* @param structure - structure modifier.
*/
@ -255,6 +253,7 @@ public class PacketContainer implements Serializable {
/**
* Retrieves a read/write structure for every field with the given type.
* @param <T> Type
* @param primitiveType - the type to find.
* @return A modifier for this specific type.
*/
@ -681,7 +680,7 @@ public class PacketContainer implements Serializable {
/**
* Retrieve a read/write structure for the PlayerInfoData list fields in the following packet: <br>
* <ul>
* <li>{@link PacketType.Play.Server.PLAYER_INFO}</li>
* <li>{@link PacketType.Play.Server#PLAYER_INFO}
* </ul>
* @return A modifier for PlayerInfoData list fields.
*/

Datei anzeigen

@ -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
*/
@ -34,7 +34,7 @@ public interface PacketListener {
* <p>
* This method is executed on the main thread in 1.6.4 and earlier, and thus the Bukkit API is safe to use.
* <p>
* In Minecraft 1.7.2 and later, this method MAY be executed asynchronously, but only if {@link ListenerOptions#ASYNC}
* In Minecraft 1.7.2 and later, this method MAY be executed asynchronously, but only if {@link ListenerOptions#ASYNC}
* have been specified in the listener. This is off by default.
* @param event - the packet that should be sent.
*/
@ -43,9 +43,9 @@ public interface PacketListener {
/**
* Invoked right before a received packet from a client is being processed.
* <p>
* <b>WARNING</b>: </br>
* This method will be called <i>asynchronously</i>! You should synchronize with the main
* thread using {@link org.bukkit.scheduler.BukkitScheduler#scheduleSyncDelayedTask(Plugin, Runnable, long) scheduleSyncDelayedTask}
* <b>WARNING</b>: <br>
* This method will be called <i>asynchronously</i>! You should synchronize with the main
* thread using {@link org.bukkit.scheduler.BukkitScheduler#scheduleSyncDelayedTask(Plugin, Runnable, long) scheduleSyncDelayedTask}
* if you need to call the Bukkit API.
* @param event - the packet that has been received.
*/

Datei anzeigen

@ -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
*/
@ -38,8 +38,8 @@ import com.google.common.primitives.Primitives;
* <p>
* Typical conversions include:
* <ul>
* <li>org.bukkit.entity.Player -> net.minecraft.server.EntityPlayer</li>
* <li>org.bukkit.World -> net.minecraft.server.WorldServer</li>
* <li>org.bukkit.entity.Player to net.minecraft.server.EntityPlayer</li>
* <li>org.bukkit.World to net.minecraft.server.WorldServer</li>
* </ul>
*
* @author Kristian
@ -91,7 +91,7 @@ public class BukkitUnwrapper implements Unwrapper {
@Override
public Object unwrapItem(Object wrappedObject) {
// Special case
if (wrappedObject == null)
if (wrappedObject == null)
return null;
Class<?> currentClass = PacketConstructor.getClass(wrappedObject);
@ -149,7 +149,7 @@ public class BukkitUnwrapper implements Unwrapper {
try {
final Method find = type.getMethod("getHandle");
// It's thread safe, as getMethod should return the same handle
// It's thread safe, as getMethod should return the same handle
Unwrapper methodUnwrapper = new Unwrapper() {
@Override
public Object unwrapItem(Object wrappedObject) {
@ -159,7 +159,7 @@ public class BukkitUnwrapper implements Unwrapper {
return find.invoke(wrappedObject);
} catch (IllegalArgumentException e) {
reporter.reportDetailed(this,
reporter.reportDetailed(this,
Report.newBuilder(REPORT_ILLEGAL_ARGUMENT).error(e).callerParam(wrappedObject, find)
);
} catch (IllegalAccessException e) {
@ -178,7 +178,7 @@ public class BukkitUnwrapper implements Unwrapper {
return methodUnwrapper;
} catch (SecurityException e) {
reporter.reportDetailed(this,
reporter.reportDetailed(this,
Report.newBuilder(REPORT_SECURITY_LIMITATION).error(e).callerParam(type)
);
} catch (NoSuchMethodException e) {
@ -188,7 +188,7 @@ public class BukkitUnwrapper implements Unwrapper {
if (fieldUnwrapper != null)
return fieldUnwrapper;
else
reporter.reportDetailed(this,
reporter.reportDetailed(this,
Report.newBuilder(REPORT_CANNOT_FIND_UNWRAP_METHOD).error(e).callerParam(type));
}
@ -214,7 +214,7 @@ public class BukkitUnwrapper implements Unwrapper {
return checkClass((Class<?>) wrappedObject, type, find.getType());
return FieldUtils.readField(find, wrappedObject, true);
} catch (IllegalAccessException e) {
reporter.reportDetailed(this,
reporter.reportDetailed(this,
Report.newBuilder(REPORT_CANNOT_READ_FIELD_HANDLE).error(e).callerParam(wrappedObject, find)
);
return null;
@ -227,7 +227,7 @@ public class BukkitUnwrapper implements Unwrapper {
} else {
// Inform about this too
reporter.reportDetailed(this,
reporter.reportDetailed(this,
Report.newBuilder(REPORT_CANNOT_READ_FIELD_HANDLE).callerParam(find)
);
return null;

Datei anzeigen

@ -36,7 +36,7 @@ public class NetworkProcessor {
*/
public byte[] processOutput(PacketEvent event, NetworkMarker marker, final byte[] input) {
// Bit of a hack - but we need the performance
PriorityQueue<PacketOutputHandler> handlers = (PriorityQueue<PacketOutputHandler>)
PriorityQueue<PacketOutputHandler> handlers = (PriorityQueue<PacketOutputHandler>)
marker.getOutputHandlers();
byte[] output = input;
@ -66,6 +66,7 @@ public class NetworkProcessor {
/**
* Invoke the post listeners and packet transmission, if any.
* @param event - PacketEvent
* @param marker - the network marker, or NULL.
*/
public void invokePostEvent(PacketEvent event, NetworkMarker marker) {

Datei anzeigen

@ -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
*/
@ -38,7 +38,7 @@ import com.google.common.primitives.Primitives;
*/
public class PacketConstructor {
/**
* A packet constructor that automatically converts Bukkit types to their NMS conterpart.
* A packet constructor that automatically converts Bukkit types to their NMS conterpart.
* <p>
* Remember to call withPacket().
*/
@ -59,7 +59,7 @@ public class PacketConstructor {
private PacketConstructor(Constructor<?> constructorMethod) {
this.constructorMethod = constructorMethod;
this.unwrappers = Lists.newArrayList((Unwrapper) new BukkitUnwrapper(new RethrowErrorReporter() ));
this.unwrappers.addAll(BukkitConverters.getUnwrappers());
this.unwrappers.addAll(BukkitConverters.getUnwrappers());
}
private PacketConstructor(PacketType type, Constructor<?> constructorMethod, List<Unwrapper> unwrappers, Unwrapper[] paramUnwrapper) {
@ -104,7 +104,7 @@ public class PacketConstructor {
/**
* Create a packet constructor that creates packets using the given ID.
* <p>
* Note that if you pass a Class<?> as a value, it will use its type directly.
* Note that if you pass a Class as a value, it will use its type directly.
* <p>
* Deprecated: Use {@link #withPacket(PacketType, Object[])} instead.
* @param id - legacy (1.6.4) packet ID.
@ -120,7 +120,7 @@ public class PacketConstructor {
/**
* Create a packet constructor that creates packets using the given types.
* <p>
* Note that if you pass a Class<?> as a value, it will use its type directly.
* Note that if you pass a Class as a value, it will use its type directly.
* @param type - the type of the packet to create.
* @param values - the values that will match each parameter in the desired constructor.
* @return A packet constructor with these types.
@ -129,7 +129,7 @@ public class PacketConstructor {
public PacketConstructor withPacket(PacketType type, Object[] values) {
Class<?>[] types = new Class<?>[values.length];
Throwable lastException = null;
Unwrapper[] paramUnwrapper = new Unwrapper[values.length];
Unwrapper[] paramUnwrapper = new Unwrapper[values.length];
for (int i = 0; i < types.length; i++) {
// Default type
@ -258,7 +258,7 @@ public class PacketConstructor {
/**
* Convert the given wrapped object to the equivalent net.minecraft.server object.
* <p>
* Note that we may pass in a class instead of object - in that case, the unwrapper should
* Note that we may pass in a class instead of object - in that case, the unwrapper should
* return the equivalent NMS class.
* @param wrappedObject - wrapped object or class.
* @return The equivalent net.minecraft.server object or class.

Datei anzeigen

@ -223,7 +223,8 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
private boolean debug;
/**
* Only create instances of this class if protocol lib is disabled.
* Only create instances of this class if ProtocolLib is disabled.
* @param builder - PacketFilterBuilder
*/
public PacketFilterManager(PacketFilterBuilder builder) {
// Used to determine if injection is needed

Datei anzeigen

@ -201,7 +201,7 @@ public class NettyProtocolInjector implements ChannelListener {
/**
* Inject our packet handling into a specific player.
* @param player
* @param player Player to inject into
*/
public void injectPlayer(Player player) {
injectionFactory.fromPlayer(player, this).inject();

Datei anzeigen

@ -116,7 +116,10 @@ public class InterceptWritePacket {
/**
* Construct a new instance of the proxy object.
* @return New instance of proxy, or NULL if we failed.
* @param proxyObject - Object to construct proxy of
* @param event - Packet event
* @param marker - Network marker
* @return New instance of the proxy, or null if we failed.
*/
@SuppressWarnings("deprecation")
public Object constructProxy(Object proxyObject, PacketEvent event, NetworkMarker marker) {

Datei anzeigen

@ -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
*/
@ -96,7 +96,7 @@ public class PacketRegistry {
return NETTY.getPacketTypeLookup().containsKey(type);
// Look up the correct type
return type.isClient() ?
return type.isClient() ?
LEGACY.getClientPackets().contains(type.getLegacyId()) :
LEGACY.getServerPackets().contains(type.getLegacyId());
}
@ -120,7 +120,7 @@ public class PacketRegistry {
);
}
} catch (CannotFindTroveNoEntryValue e) {
ProtocolLibrary.getErrorReporter().reportWarning(PacketRegistry.class,
ProtocolLibrary.getErrorReporter().reportWarning(PacketRegistry.class,
Report.newBuilder(REPORT_CANNOT_CORRECT_TROVE_MAP).error(e.getCause()));
}
}
@ -139,6 +139,7 @@ public class PacketRegistry {
if (NETTY != null) {
@SuppressWarnings("unchecked")
Map<Class, Integer> result = (Map)Maps.transformValues(NETTY.getPacketClassLookup(), new Function<PacketType, Integer>() {
@Override
public Integer apply(PacketType type) {
return type.getLegacyId();
};
@ -161,6 +162,7 @@ public class PacketRegistry {
return result;
}
return Maps.transformValues(LEGACY.getPacketToID(), new Function<Integer, PacketType>() {
@Override
public PacketType apply(Integer packetId) {
return PacketType.findLegacy(packetId);
};
@ -288,7 +290,7 @@ public class PacketRegistry {
* @param types - packet type.
* @return Set of integers.
*/
public static Set<Integer> toLegacy(Set<PacketType> types) {
public static Set<Integer> toLegacy(Set<PacketType> types) {
Set<Integer> result = Sets.newHashSet();
for (PacketType type : types)
@ -298,20 +300,20 @@ public class PacketRegistry {
/**
* Convert a set of legacy packet IDs to packet types.
* @param types - legacy packet IDs.
* @param ids - legacy packet IDs.
* @return Set of packet types.
*/
public static Set<PacketType> toPacketTypes(Set<Integer> ids) {
public static Set<PacketType> toPacketTypes(Set<Integer> ids) {
return toPacketTypes(ids, null);
}
/**
* Convert a set of legacy packet IDs to packet types.
* @param types - legacy packet IDs.
* @param ids - legacy packet IDs.
* @param preference - the sender preference, if any.
* @return Set of packet types.
*/
public static Set<PacketType> toPacketTypes(Set<Integer> ids, Sender preference) {
public static Set<PacketType> toPacketTypes(Set<Integer> ids, Sender preference) {
Set<PacketType> result = Sets.newHashSet();
for (int id : ids)
@ -417,7 +419,7 @@ public class PacketRegistry {
} else {
final int id = LEGACY.getPacketID(packet);
return PacketType.hasLegacy(id) ?
return PacketType.hasLegacy(id) ?
PacketType.fromLegacy(id, sender) : null;
}
}

Datei anzeigen

@ -129,7 +129,7 @@ public interface PlayerInjectionHandler {
* Send the given packet to the given receiver.
* @param receiver - the player receiver.
* @param packet - the packet to send.
* @param marker
* @param marker - network marker.
* @param filters - whether or not to invoke the packet filters.
* @throws InvocationTargetException If an error occurred during sending.
*/

Datei anzeigen

@ -156,6 +156,7 @@ public abstract class PlayerInjector implements SocketInjector {
/**
* Initialize all fields for this player injector, if it hasn't already.
* @param injectionSource - Injection source
* @throws IllegalAccessException An error has occured.
*/
public void initialize(Object injectionSource) throws IllegalAccessException {
@ -442,6 +443,7 @@ public abstract class PlayerInjector implements SocketInjector {
/**
* Retrieves the current net handler for this player.
* @boolean refresh - Whether or not to refresh
* @return Current net handler.
* @throws IllegalAccessException Unable to find or retrieve net handler.
*/
@ -562,6 +564,7 @@ public abstract class PlayerInjector implements SocketInjector {
/**
* Determine if this inject method can even be attempted.
* @param GamePhase - Game phase
* @return TRUE if can be attempted, though possibly with failure, FALSE otherwise.
*/
public abstract boolean canInject(GamePhase state);

Datei anzeigen

@ -42,11 +42,12 @@ public interface SocketInjector {
* @param filtered - whether or not the packet will be filtered by our listeners.
* @throws InvocationTargetException If an error occured when sending the packet.
*/
public abstract void sendServerPacket(Object packet, NetworkMarker marker, boolean filtered)
public abstract void sendServerPacket(Object packet, NetworkMarker marker, boolean filtered)
throws InvocationTargetException;
/**
* Retrieve the hooked player.
* @return The hooked player.
*/
public abstract Player getPlayer();
@ -57,7 +58,7 @@ public interface SocketInjector {
public abstract Player getUpdatedPlayer();
/**
* Invoked when a delegated socket injector transfers the state of one injector to the next.
* Invoked when a delegated socket injector transfers the state of one injector to the next.
* @param delegate - the new injector.
*/
public abstract void transferState(SocketInjector delegate);

Datei anzeigen

@ -268,7 +268,7 @@ public class Metrics {
/**
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
*
* @throws java.io.IOException
* @throws IOException If configuration saving fails
*/
public void enable() throws IOException {
// This has to be synchronized or it can collide with the check in the task.
@ -289,7 +289,7 @@ public class Metrics {
/**
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
*
* @throws java.io.IOException
* @throws IOException If configuration saving fails
*/
public void disable() throws IOException {
// This has to be synchronized or it can collide with the check in the task.
@ -327,6 +327,8 @@ public class Metrics {
/**
* Generic method that posts a plugin to the metrics website
*
* @throws IOException If posting fails
*/
private void postPlugin(final boolean isPing) throws IOException {
// Server software specific section
@ -496,8 +498,8 @@ public class Metrics {
/**
* GZip compress a string of bytes
*
* @param input
* @return
* @param input Input to compress
* @return Compressed string
*/
public static byte[] gzip(String input) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -532,14 +534,7 @@ public class Metrics {
}
}
/**
* Appends a json encoded key/value pair to the given string builder.
*
* @param json
* @param key
* @param value
* @throws UnsupportedEncodingException
*/
// Appends a json encoded key/value pair to the given string builder.
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false;
@ -566,12 +561,7 @@ public class Metrics {
}
}
/**
* Escape a string to create a valid JSON string
*
* @param text
* @return
*/
// Escape a string to create a valid JSON string
private static String escapeJSON(String text) {
StringBuilder builder = new StringBuilder();
@ -612,12 +602,7 @@ public class Metrics {
return builder.toString();
}
/**
* Encode text as UTF-8
*
* @param text the text to encode
* @return the encoded text, as UTF-8
*/
// Encode text as UTF-8
private static String urlEncode(final String text) throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8");
}

Datei anzeigen

@ -14,7 +14,7 @@ import com.comphenix.protocol.reflect.compiler.EmptyClassVisitor;
import com.comphenix.protocol.reflect.compiler.EmptyMethodVisitor;
import com.google.common.collect.Lists;
public class ClassAnalyser {
public class ClassAnalyser {
/**
* Represents a method in ASM.
* <p>
@ -68,7 +68,7 @@ public class ClassAnalyser {
/**
* Retrieve the associated owner class.
* @return The owner class.
* @throws ClassNotFoundException
* @throws ClassNotFoundException If the class was not found
*/
public Class<?> getOwnerClass() throws ClassNotFoundException {
return AsmMethod.class.getClassLoader().loadClass(getOwnerName().replace('/', '.'));

Datei anzeigen

@ -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
*/
@ -93,6 +93,7 @@ public class FuzzyReflection {
/**
* Retrieve the value of the first field of the given type.
* @param <T> Type
* @param instance - the instance to retrieve from.
* @param fieldClass - type of the field to retrieve.
* @param forceAccess - whether or not to look for private and protected fields.
@ -107,6 +108,7 @@ public class FuzzyReflection {
/**
* Retrieves the underlying class.
* @return The underlying class.
*/
public Class<?> getSource() {
return source;
@ -117,7 +119,7 @@ public class FuzzyReflection {
* @return The singleton instance.
* @throws IllegalStateException If the class has no singleton.
*/
public Object getSingleton() {
public Object getSingleton() {
Method method = null;
Field field = null;
@ -203,12 +205,12 @@ public class FuzzyReflection {
for (Method method : getMethods()) {
if (match.matcher(method.getName()).matches()) {
// Right - this is probably it.
// Right - this is probably it.
return method;
}
}
throw new IllegalArgumentException("Unable to find a method with the pattern " +
throw new IllegalArgumentException("Unable to find a method with the pattern " +
nameRegex + " in " + source.getName());
}
@ -341,13 +343,13 @@ public class FuzzyReflection {
for (Field field : getFields()) {
if (match.matcher(field.getName()).matches()) {
// Right - this is probably it.
// Right - this is probably it.
return field;
}
}
// Looks like we're outdated. Too bad.
throw new IllegalArgumentException("Unable to find a field with the pattern " +
throw new IllegalArgumentException("Unable to find a field with the pattern " +
nameRegex + " in " + source.getName());
}
@ -428,7 +430,7 @@ public class FuzzyReflection {
/**
* Retrieves a field by type.
* <p>
* Note that the type is matched using the full canonical representation, i.e.:
* Note that the type is matched using the full canonical representation, i.e.:
* <ul>
* <li>java.util.List</li>
* <li>net.comphenix.xp.ExperienceMod</li>
@ -451,14 +453,14 @@ public class FuzzyReflection {
}
// Looks like we're outdated. Too bad.
throw new IllegalArgumentException("Unable to find a field with the type " +
throw new IllegalArgumentException("Unable to find a field with the type " +
typeRegex + " in " + source.getName());
}
/**
* Retrieves a field by type.
* <p>
* Note that the type is matched using the full canonical representation, i.e.:
* Note that the type is matched using the full canonical representation, i.e.:
* <ul>
* <li>java.util.List</li>
* <li>net.comphenix.xp.ExperienceMod</li>
@ -483,7 +485,7 @@ public class FuzzyReflection {
}
// Looks like we're outdated. Too bad.
throw new IllegalArgumentException("Unable to find a field with the type " +
throw new IllegalArgumentException("Unable to find a field with the type " +
typeRegex + " in " + source.getName());
}
@ -505,7 +507,7 @@ public class FuzzyReflection {
}
/**
* Retrieve every method as a map over names.
* Retrieve every method as a map over names.
* <p>
* Note that overloaded methods will only occur once in the resulting map.
* @param methods - every method.

Datei anzeigen

@ -38,10 +38,10 @@ import org.bukkit.Bukkit;
* Reflection locates these methods fine and correctly assigns them as public.
* However, an <code>IllegalAccessException</code> is thrown if the method is invoked.</p>
*
* <p><code>MethodUtils</code> contains a workaround for this situation.
* <p><code>MethodUtils</code> contains a workaround for this situation.
* It will attempt to call <code>setAccessible</code> on this method.
* If this call succeeds, then the method can be invoked as normal.
* This call will only succeed when the application has sufficient security privilages.
* This call will only succeed when the application has sufficient security privilages.
* If this call fails then a warning will be logged and the method may fail.</p>
*
* @author Craig R. McClanahan
@ -58,7 +58,7 @@ public class MethodUtils {
// --------------------------------------------------------- Private Methods
/**
/**
* Only log warning about accessibility work around once.
* <p>
* Note that this is broken when this class is deployed via a shared
@ -71,7 +71,7 @@ public class MethodUtils {
*/
private static boolean loggedAccessibleWarning = false;
/**
/**
* Indicates whether methods should be cached for improved performance.
* <p>
* Note that when this class is deployed via a shared classloader in
@ -91,9 +91,9 @@ public class MethodUtils {
* <p>
* The keys into this map only ever exist as temporary variables within
* methods of this class, and are never exposed to users of this class.
* This means that the WeakHashMap is used only as a mechanism for
* This means that the WeakHashMap is used only as a mechanism for
* limiting the size of the cache, ie a way to tell the garbage collector
* that the contents of the cache can be completely garbage-collected
* that the contents of the cache can be completely garbage-collected
* whenever it needs the memory. Whether this is a good approach to
* this problem is doubtful; something like the commons-collections
* LRUMap may be more appropriate (though of course selecting an
@ -140,12 +140,12 @@ public class MethodUtils {
/**
* <p>Invoke a named method whose parameter type matches the object type.</p>
*
* <p>The behaviour of this method is less deterministic
* <p>The behaviour of this method is less deterministic
* than <code>invokeExactMethod()</code>.
* It loops through all methods with names that match
* and then executes the first it finds with compatable parameters.</p>
*
* <p>This method supports calls to methods taking primitive parameters
* <p>This method supports calls to methods taking primitive parameters
* via passing in wrapping classes. So, for example, a <code>Boolean</code> class
* would match a <code>boolean</code> primitive.</p>
*
@ -182,12 +182,12 @@ public class MethodUtils {
/**
* <p>Invoke a named method whose parameter type matches the object type.</p>
*
* <p>The behaviour of this method is less deterministic
* than {@link #invokeExactMethod(Object object,String methodName,Object [] args)}.
* <p>The behaviour of this method is less deterministic
* than {@link #invokeExactMethod(Object object,String methodName,Object [] args)}.
* It loops through all methods with names that match
* and then executes the first it finds with compatable parameters.</p>
*
* <p>This method supports calls to methods taking primitive parameters
* <p>This method supports calls to methods taking primitive parameters
* via passing in wrapping classes. So, for example, a <code>Boolean</code> class
* would match a <code>boolean</code> primitive.</p>
*
@ -217,7 +217,7 @@ public class MethodUtils {
if (args == null) {
args = EMPTY_OBJECT_ARRAY;
}
}
int arguments = args.length;
Class[] parameterTypes = new Class[arguments];
for (int i = 0; i < arguments; i++) {
@ -231,13 +231,13 @@ public class MethodUtils {
/**
* <p>Invoke a named method whose parameter type matches the object type.</p>
*
* <p>The behaviour of this method is less deterministic
* than {@link
* #invokeExactMethod(Object object,String methodName,Object [] args,Class[] parameterTypes)}.
* <p>The behaviour of this method is less deterministic
* than {@link
* #invokeExactMethod(Object object,String methodName,Object [] args,Class[] parameterTypes)}.
* It loops through all methods with names that match
* and then executes the first it finds with compatable parameters.</p>
*
* <p>This method supports calls to methods taking primitive parameters
* <p>This method supports calls to methods taking primitive parameters
* via passing in wrapping classes. So, for example, a <code>Boolean</code> class
* would match a <code>boolean</code> primitive.</p>
*
@ -266,10 +266,10 @@ public class MethodUtils {
if (parameterTypes == null) {
parameterTypes = EMPTY_CLASS_PARAMETERS;
}
}
if (args == null) {
args = EMPTY_OBJECT_ARRAY;
}
}
Method method = getMatchingAccessibleMethod(
object.getClass(),
@ -345,7 +345,7 @@ public class MethodUtils {
InvocationTargetException {
if (args == null) {
args = EMPTY_OBJECT_ARRAY;
}
}
int arguments = args.length;
Class[] parameterTypes = new Class[arguments];
for (int i = 0; i < arguments; i++) {
@ -387,7 +387,7 @@ public class MethodUtils {
if (args == null) {
args = EMPTY_OBJECT_ARRAY;
}
}
if (parameterTypes == null) {
parameterTypes = EMPTY_CLASS_PARAMETERS;
@ -437,7 +437,7 @@ public class MethodUtils {
if (args == null) {
args = EMPTY_OBJECT_ARRAY;
}
}
if (parameterTypes == null) {
parameterTypes = EMPTY_CLASS_PARAMETERS;
@ -458,12 +458,12 @@ public class MethodUtils {
/**
* <p>Invoke a named static method whose parameter type matches the object type.</p>
*
* <p>The behaviour of this method is less deterministic
* than {@link #invokeExactMethod(Object, String, Object[], Class[])}.
* <p>The behaviour of this method is less deterministic
* than {@link #invokeExactMethod(Object, String, Object[], Class[])}.
* It loops through all methods with names that match
* and then executes the first it finds with compatable parameters.</p>
*
* <p>This method supports calls to methods taking primitive parameters
* <p>This method supports calls to methods taking primitive parameters
* via passing in wrapping classes. So, for example, a <code>Boolean</code> class
* would match a <code>boolean</code> primitive.</p>
*
@ -501,12 +501,12 @@ public class MethodUtils {
/**
* <p>Invoke a named static method whose parameter type matches the object type.</p>
*
* <p>The behaviour of this method is less deterministic
* than {@link #invokeExactMethod(Object object,String methodName,Object [] args)}.
* <p>The behaviour of this method is less deterministic
* than {@link #invokeExactMethod(Object object,String methodName,Object [] args)}.
* It loops through all methods with names that match
* and then executes the first it finds with compatable parameters.</p>
*
* <p>This method supports calls to methods taking primitive parameters
* <p>This method supports calls to methods taking primitive parameters
* via passing in wrapping classes. So, for example, a <code>Boolean</code> class
* would match a <code>boolean</code> primitive.</p>
*
@ -537,7 +537,7 @@ public class MethodUtils {
if (args == null) {
args = EMPTY_OBJECT_ARRAY;
}
}
int arguments = args.length;
Class[] parameterTypes = new Class[arguments];
for (int i = 0; i < arguments; i++) {
@ -551,13 +551,13 @@ public class MethodUtils {
/**
* <p>Invoke a named static method whose parameter type matches the object type.</p>
*
* <p>The behaviour of this method is less deterministic
* than {@link
* #invokeExactStaticMethod(Class objectClass,String methodName,Object [] args,Class[] parameterTypes)}.
* <p>The behaviour of this method is less deterministic
* than {@link
* #invokeExactStaticMethod(Class objectClass,String methodName,Object [] args,Class[] parameterTypes)}.
* It loops through all methods with names that match
* and then executes the first it finds with compatable parameters.</p>
*
* <p>This method supports calls to methods taking primitive parameters
* <p>This method supports calls to methods taking primitive parameters
* via passing in wrapping classes. So, for example, a <code>Boolean</code> class
* would match a <code>boolean</code> primitive.</p>
*
@ -587,10 +587,10 @@ public class MethodUtils {
if (parameterTypes == null) {
parameterTypes = EMPTY_CLASS_PARAMETERS;
}
}
if (args == null) {
args = EMPTY_OBJECT_ARRAY;
}
}
Method method = getMatchingAccessibleMethod(
objectClass,
@ -668,7 +668,7 @@ public class MethodUtils {
InvocationTargetException {
if (args == null) {
args = EMPTY_OBJECT_ARRAY;
}
}
int arguments = args.length;
Class[] parameterTypes = new Class[arguments];
for (int i = 0; i < arguments; i++) {
@ -890,16 +890,16 @@ public class MethodUtils {
/**
* <p>Find an accessible method that matches the given name and has compatible parameters.
* Compatible parameters mean that every method parameter is assignable from
* Compatible parameters mean that every method parameter is assignable from
* the given parameters.
* In other words, it finds a method with the given name
* that will take the parameters given.<p>
* In other words, it finds a method with the given name
* that will take the parameters given.</p>
*
* <p>This method is slightly undeterminstic since it loops
* <p>This method is slightly undeterminstic since it loops
* through methods names and return the first matching method.</p>
*
* <p>This method is used by
* {@link
* <p>This method is used by
* {@link
* #invokeMethod(Object object,String methodName,Object [] args,Class[] parameterTypes)}.
*
* <p>This method can match primitive parameter by passing in wrapper classes.
@ -908,7 +908,7 @@ public class MethodUtils {
*
* @param clazz find method in this class
* @param methodName find method with this name
* @param parameterTypes find method with compatible parameters
* @param parameterTypes find method with compatible parameters
* @return The accessible method
*/
@SuppressWarnings("unchecked")
@ -938,19 +938,19 @@ public class MethodUtils {
} catch (NoSuchMethodException e) { /* SWALLOW */ }
// search through all methods
// search through all methods
int paramSize = parameterTypes.length;
Method bestMatch = null;
Method[] methods = clazz.getMethods();
float bestMatchCost = Float.MAX_VALUE;
float myCost = Float.MAX_VALUE;
for (int i = 0, size = methods.length; i < size ; i++) {
if (methods[i].getName().equals(methodName)) {
if (methods[i].getName().equals(methodName)) {
// compare parameters
Class[] methodsParams = methods[i].getParameterTypes();
int methodParamSize = methodsParams.length;
if (methodParamSize == paramSize) {
if (methodParamSize == paramSize) {
boolean match = true;
for (int n = 0 ; n < methodParamSize; n++) {
if (!isAssignmentCompatible(methodsParams[n], parameterTypes[n])) {
@ -986,7 +986,7 @@ public class MethodUtils {
}
}
return bestMatch;
return bestMatch;
}
/**
@ -1018,7 +1018,7 @@ public class MethodUtils {
// modifer is public.
//
// The following workaround solves the problem but will only
// work from sufficiently privilages code.
// work from sufficiently privilages code.
//
// Better workarounds would be greatfully accepted.
//
@ -1032,7 +1032,7 @@ public class MethodUtils {
boolean vulnerableJVM = false;
try {
String specVersion = System.getProperty("java.specification.version");
if (specVersion.charAt(0) == '1' &&
if (specVersion.charAt(0) == '1' &&
(specVersion.charAt(2) == '0' ||
specVersion.charAt(2) == '1' ||
specVersion.charAt(2) == '2' ||
@ -1074,8 +1074,8 @@ public class MethodUtils {
}
/**
* Gets the number of steps required needed to turn the source class into the
* destination class. This represents the number of steps in the object hierarchy
* Gets the number of steps required needed to turn the source class into the
* destination class. This represents the number of steps in the object hierarchy
* graph.
* @param srcClass The source class
* @param destClass The destination class
@ -1085,9 +1085,9 @@ public class MethodUtils {
float cost = 0.0f;
while (destClass != null && !destClass.equals(srcClass)) {
if (destClass.isInterface() && isAssignmentCompatible(destClass,srcClass)) {
// slight penalty for interface match.
// we still want an exact match to override an interface match, but
// an interface match should override anything where we have to get a
// slight penalty for interface match.
// we still want an exact match to override an interface match, but
// an interface match should override anything where we have to get a
// superclass.
cost += 0.25f;
break;
@ -1097,7 +1097,7 @@ public class MethodUtils {
}
/*
* If the destination class is null, we've travelled all the way up to
* If the destination class is null, we've travelled all the way up to
* an Object match. We'll penalize this by adding 1.5 to the cost.
*/
if (destClass == null) {
@ -1121,7 +1121,7 @@ public class MethodUtils {
* For example, a <code>Long</code> will not match a <code>int</code>.
*
* @param parameterType the type of parameter accepted by the method
* @param parameterization the type of parameter being tested
* @param parameterization the type of parameter being tested
*
* @return true if the assignement is compatible.
*/
@ -1148,7 +1148,7 @@ public class MethodUtils {
* Gets the wrapper object class for the given primitive type class.
* For example, passing <code>boolean.class</code> returns <code>Boolean.class</code>
* @param primitiveType the primitive type class for which a match is to be found
* @return the wrapper type associated with the given primitive
* @return the wrapper type associated with the given primitive
* or null if no match is found
*/
public static Class getPrimitiveWrapper(Class primitiveType) {
@ -1177,8 +1177,8 @@ public class MethodUtils {
/**
* Gets the class for the primitive type corresponding to the primitive wrapper class given.
* For example, an instance of <code>Boolean.class</code> returns a <code>boolean.class</code>.
* @param wrapperType the
* For example, an instance of <code>Boolean.class</code> returns a <code>boolean.class</code>.
* @param wrapperType the
* @return the primitive type class corresponding to the given wrapper class,
* null if no match is found
*/
@ -1214,7 +1214,7 @@ public class MethodUtils {
public static Class toNonPrimitiveClass(Class clazz) {
if (clazz.isPrimitive()) {
Class primitiveClazz = MethodUtils.getPrimitiveWrapper(clazz);
// the above method returns
// the above method returns
if (primitiveClazz != null) {
return primitiveClazz;
} else {
@ -1298,7 +1298,8 @@ public class MethodUtils {
* @param obj object to be tested for equality
* @return true, if the object describes the same Method.
*/
public boolean equals(Object obj) {
@Override
public boolean equals(Object obj) {
if (!(obj instanceof MethodDescriptor)) {
return false;
}
@ -1318,7 +1319,8 @@ public class MethodUtils {
* determine equality.
* @return the string length of method name.
*/
public int hashCode() {
@Override
public int hashCode() {
return hashCode;
}
}

Datei anzeigen

@ -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
*/
@ -36,16 +36,18 @@ import com.google.common.collect.HashBiMap;
public class ObjectEnum<T> implements Iterable<T> {
// Used to convert between IDs and names
protected BiMap<T, String> members = HashBiMap.create();
/**
* Registers every declared integer field.
* @param fieldType Field type
*/
public ObjectEnum(Class<T> fieldType) {
registerAll(fieldType);
}
/**
* Registers every public assignable static field as a member.
* @param fieldType Field type
*/
@SuppressWarnings("unchecked")
protected void registerAll(Class<T> fieldType) {
@ -56,7 +58,7 @@ public class ObjectEnum<T> implements Iterable<T> {
T value = (T) entry.get(null);
if (value == null)
throw new IllegalArgumentException("Field " + entry + " was NULL. Remember to " +
throw new IllegalArgumentException("Field " + entry + " was NULL. Remember to " +
"construct the object after the field has been declared.");
registerMember(value, entry.getName());
}
@ -77,7 +79,7 @@ public class ObjectEnum<T> implements Iterable<T> {
*/
public boolean registerMember(T instance, String name) {
if (!members.containsKey(instance)) {
members.put(instance, name);
members.put(instance, name);
return true;
}
return false;

Datei anzeigen

@ -62,10 +62,10 @@ public class PrettyPrinter {
public final static int RECURSE_DEPTH = 3;
/**
* Print the content of an object.
* Print the contents of an object.
* @param object - the object to serialize.
* @return String representation of the class.
* @throws IllegalAccessException
* @throws IllegalAccessException If the object is null
*/
public static String printObject(Object object) throws IllegalAccessException {
if (object == null)
@ -75,11 +75,12 @@ public class PrettyPrinter {
}
/**
* Print the content of an object.
* Print the contents of an object.
* @param object - the object to serialize.
* @param start - class to start at.
* @param stop - superclass that will stop the process.
* @return String representation of the class.
* @throws IllegalAccessException
* @return String representation of the class
* @throws IllegalAccessException If the object is null
*/
public static String printObject(Object object, Class<?> start, Class<?> stop) throws IllegalAccessException {
if (object == null)
@ -89,24 +90,27 @@ public class PrettyPrinter {
}
/**
* Print the content of an object.
* Print the contents of an object.
* @param object - the object to serialize.
* @param start - class to start at.
* @param stop - superclass that will stop the process.
* @param hierachyDepth - maximum recursion level.
* @return String representation of the class.
* @throws IllegalAccessException
* @throws IllegalAccessException If the object is null
*/
public static String printObject(Object object, Class<?> start, Class<?> stop, int hierachyDepth) throws IllegalAccessException {
return printObject(object, start, stop, hierachyDepth, ObjectPrinter.DEFAULT);
}
/**
* Print the content of an object.
* Print the contents of an object.
* @param object - the object to serialize.
* @param start - class to start at.
* @param stop - superclass that will stop the process.
* @param hierachyDepth - maximum recursion level.
* @param printer - a generic object printer.
* @return String representation of the class.
* @throws IllegalAccessException
* @throws IllegalAccessException If the object is null
*/
public static String printObject(Object object, Class<?> start, Class<?> stop, int hierachyDepth, ObjectPrinter printer) throws IllegalAccessException {
if (object == null)

Datei anzeigen

@ -393,6 +393,7 @@ public class StructureModifier<TField> {
/**
* Retrieves a structure modifier that only reads and writes fields of a given type.
* @param <T> Type
* @param fieldType - the type, or supertype, of every field to modify.
* @return A structure modifier for fields of this type.
*/
@ -424,6 +425,7 @@ public class StructureModifier<TField> {
/**
* Retrieves a structure modifier that only reads and writes fields of a given type.
* @param <T> Type
* @param fieldType - the type, or supertype, of every field to modify.
* @param converter - converts objects into the given type.
* @return A structure modifier for fields of this type.
@ -507,10 +509,10 @@ public class StructureModifier<TField> {
/**
* Create a new structure modifier for the new field type.
* @param <T> Type
* @param fieldType - common type of each field.
* @param filtered - list of fields after filtering the original modifier.
* @param defaults - list of default values after filtering the original.
* @param converter - the new converter
* @return A new structure modifier.
*/
protected <T> StructureModifier<T> withFieldType(
@ -520,6 +522,7 @@ public class StructureModifier<TField> {
/**
* Create a new structure modifier for the new field type.
* @param <T> Type
* @param fieldType - common type of each field.
* @param filtered - list of fields after filtering the original modifier.
* @param defaults - list of default values after filtering the original.

Datei anzeigen

@ -200,6 +200,7 @@ public class VolatileField {
/**
* Determine whether or not we'll need to revert the value.
* @return True if it is set, false if not.
*/
public boolean isCurrentSet() {
return currentSet;

Datei anzeigen

@ -78,7 +78,7 @@ public final class Accessors {
/**
* Retrieve an accessor for the first field of the given type.
* @param instanceClass - the type of the instance to retrieve.
* @param fieldClass - type of the field to retrieve.
* @param fieldName - name of the field to retrieve.
* @param forceAccess - whether or not to look for private and protected fields.
* @return The value of that field.
* @throws IllegalArgumentException If the field cannot be found.

Datei anzeigen

@ -26,6 +26,7 @@ public class SerializableCloner implements Cloner {
/**
* Clone the given object using serialization.
* @param <T> Type
* @param obj - the object to clone.
* @return The cloned object.
* @throws RuntimeException If we were unable to clone the object.

Datei anzeigen

@ -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
*/
@ -158,6 +158,7 @@ public class BackgroundCompiler {
/**
* Ensure that the given structure modifier is eventually compiled.
* @param <TKey> Type
* @param uncompiled - structure modifier to compile.
* @param listener - listener responsible for responding to the compilation.
*/
@ -181,7 +182,7 @@ public class BackgroundCompiler {
List list = listeners.get(key);
if (!listeners.containsKey(key)) {
listeners.put(key, (List) Lists.newArrayList(listener));
listeners.put(key, (List) Lists.newArrayList(listener));
} else {
// We're currently compiling
list.add(listener);
@ -261,8 +262,8 @@ public class BackgroundCompiler {
}
} catch (RejectedExecutionException e) {
// Occures when the underlying queue is overflowing. Since the compilation
// is only an optmization and not really essential we'll just log this failure
// Occures when the underlying queue is overflowing. Since the compilation
// is only an optmization and not really essential we'll just log this failure
// and move on.
reporter.reportWarning(this, Report.newBuilder(REPORT_CANNOT_SCHEDULE_COMPILATION).error(e));
}
@ -271,6 +272,7 @@ public class BackgroundCompiler {
/**
* Add a compile listener if we are still waiting for the structure modifier to be compiled.
* @param <TKey> Type
* @param uncompiled - the structure modifier that may get compiled.
* @param listener - the listener to invoke in that case.
*/
@ -280,7 +282,7 @@ public class BackgroundCompiler {
StructureKey key = new StructureKey(uncompiled);
@SuppressWarnings("rawtypes")
List list = listeners.get(key);
List list = listeners.get(key);
if (list != null) {
list.add(listener);

Datei anzeigen

@ -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
*/
@ -40,9 +40,9 @@ import com.google.common.base.Objects;
import com.google.common.primitives.Primitives;
// public class CompiledStructureModifierPacket20<TField> extends CompiledStructureModifier<TField> {
//
//
// private Packet20NamedEntitySpawn typedTarget;
//
//
// public CompiledStructureModifierPacket20(StructureModifier<TField> other, StructureCompiler compiler) {
// super();
// initialize(other);
@ -50,12 +50,12 @@ import com.google.common.primitives.Primitives;
// this.typedTarget = (Packet20NamedEntitySpawn) target;
// this.compiler = compiler;
// }
//
//
// @Override
// protected Object readGenerated(int fieldIndex) throws FieldAccessException {
//
//
// Packet20NamedEntitySpawn target = typedTarget;
//
//
// switch (fieldIndex) {
// case 0: return (Object) target.a;
// case 1: return (Object) target.b;
@ -69,12 +69,12 @@ import com.google.common.primitives.Primitives;
// throw new FieldAccessException("Invalid index " + fieldIndex);
// }
// }
//
//
// @Override
// protected StructureModifier<TField> writeGenerated(int index, Object value) throws FieldAccessException {
//
//
// Packet20NamedEntitySpawn target = typedTarget;
//
//
// switch (index) {
// case 0: target.a = (Integer) value; break;
// case 1: target.b = (String) value; break;
@ -87,7 +87,7 @@ import com.google.common.primitives.Primitives;
// default:
// throw new FieldAccessException("Invalid index " + index);
// }
//
//
// // Chaining
// return this;
// }
@ -157,6 +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 source - the structure modifier to look up.
* @return TRUE if we successfully found a previously generated class, FALSE otherwise.
*/
@ -179,7 +180,7 @@ public final class StructureCompiler {
return true;
}
} catch (ClassNotFoundException e) {
// That's ok.
// That's ok.
}
// We need to compile the class
@ -189,7 +190,7 @@ public final class StructureCompiler {
/**
* Compiles the given structure modifier.
* <p>
* WARNING: Do NOT call this method in the main thread. Compiling may easily take 10 ms, which is already
* 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 source - structure modifier to compile.
* @return A compiled structure modifier.
@ -233,7 +234,7 @@ public final class StructureCompiler {
throw new RuntimeException("Error occured while instancing generated class.", e);
} catch (NoSuchMethodException e) {
throw new IllegalStateException("Cannot happen.", e);
}
}
}
/**
@ -254,8 +255,8 @@ public final class StructureCompiler {
Class<?> targetType = source.getTargetType();
// Concat class and field type
return "CompiledStructure$" +
getSafeTypeName(targetType) + "$" +
return "CompiledStructure$" +
getSafeTypeName(targetType) + "$" +
getSafeTypeName(source.getFieldType());
}
@ -274,7 +275,7 @@ public final class StructureCompiler {
String targetName = targetType.getName().replace('.', '/');
// Define class
cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, PACKAGE_NAME + "/" + className,
cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, PACKAGE_NAME + "/" + className,
null, COMPILED_CLASS, null);
createFields(cw, targetSignature);
@ -288,7 +289,7 @@ public final class StructureCompiler {
// Call the define method
try {
if (defineMethod == null) {
Method defined = ClassLoader.class.getDeclaredMethod("defineClass",
Method defined = ClassLoader.class.getDeclaredMethod("defineClass",
new Class<?>[] { String.class, byte[].class, int.class, int.class });
// Awesome. Now, create and return it.
@ -351,7 +352,7 @@ public final class StructureCompiler {
String methodDescriptor = "(ILjava/lang/Object;)L" + SUPER_CLASS + ";";
String methodSignature = "(ILjava/lang/Object;)L" + SUPER_CLASS + "<Ljava/lang/Object;>;";
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PROTECTED, "writeGenerated", methodDescriptor, methodSignature,
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PROTECTED, "writeGenerated", methodDescriptor, methodSignature,
new String[] { FIELD_EXCEPTION_CLASS });
BoxingHelper boxingHelper = new BoxingHelper(mv);
@ -437,7 +438,7 @@ public final class StructureCompiler {
}
private void createReadMethod(ClassWriter cw, String className, List<Field> fields, String targetSignature, String targetName) {
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PROTECTED, "readGenerated", "(I)Ljava/lang/Object;", null,
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PROTECTED, "readGenerated", "(I)Ljava/lang/Object;", null,
new String[] { "com/comphenix/protocol/reflect/FieldAccessException" });
BoxingHelper boxingHelper = new BoxingHelper(mv);
@ -508,8 +509,8 @@ public final class StructureCompiler {
}
private void createConstructor(ClassWriter cw, String className, String targetSignature, String targetName) {
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>",
"(L" + SUPER_CLASS + ";L" + PACKAGE_NAME + "/StructureCompiler;)V",
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>",
"(L" + SUPER_CLASS + ";L" + PACKAGE_NAME + "/StructureCompiler;)V",
"(L" + SUPER_CLASS + "<Ljava/lang/Object;>;L" + PACKAGE_NAME + "/StructureCompiler;)V", null);
String fullClassName = PACKAGE_NAME + "/" + className;

Datei anzeigen

@ -87,7 +87,7 @@ public abstract class AbstractFuzzyMember<T extends Member> extends AbstractFuzz
/**
* Set the exact name of the member we are matching.
* <p<
* <p>
* This will overwrite the regular expression rule.
* @param name - exact name.
* @return This builder, for chaining.
@ -137,7 +137,7 @@ public abstract class AbstractFuzzyMember<T extends Member> extends AbstractFuzz
}
/**
* Construct a new instance of the current type.
* Construct a new instance of the current type.
* @return New instance.
*/
@Nonnull
@ -232,7 +232,7 @@ public abstract class AbstractFuzzyMember<T extends Member> extends AbstractFuzz
@Override
protected int calculateRoundNumber() {
// Sanity check
if (!sealed)
if (!sealed)
throw new IllegalStateException("Cannot calculate round number during construction.");
// NULL is zero
@ -255,7 +255,7 @@ public abstract class AbstractFuzzyMember<T extends Member> extends AbstractFuzz
// Build our representation
if (modifiersRequired != Integer.MAX_VALUE || modifiersBanned != 0) {
map.put("modifiers", String.format("[required: %s, banned: %s]",
map.put("modifiers", String.format("[required: %s, banned: %s]",
getBitView(modifiersRequired, 16),
getBitView(modifiersBanned, 16))
);
@ -298,7 +298,7 @@ public abstract class AbstractFuzzyMember<T extends Member> extends AbstractFuzz
@Override
public int hashCode() {
return Objects.hashCode(modifiersBanned, modifiersRequired,
return Objects.hashCode(modifiersBanned, modifiersRequired,
nameRegex != null ? nameRegex.pattern() : null, declaringMatcher);
}
}

Datei anzeigen

@ -26,7 +26,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo> {
private final Integer indexMatch;
/**
* Construct a new parameter class matcher.
* Construct a new parameter class matcher.
* @param typeMatcher - class type matcher.
*/
public ParameterClassMatcher(@Nonnull AbstractFuzzyMatcher<Class<?>> typeMatcher) {
@ -34,7 +34,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo> {
}
/**
* Construct a new parameter class matcher.
* Construct a new parameter class matcher.
* @param typeMatcher - class type matcher.
* @param indexMatch - parameter index to match, or NULL for anything.
*/
@ -49,7 +49,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo> {
/**
* See if there's a match for this matcher.
* @param used - parameters that have been matched before.
* @param parent - the container (member) that holds a reference to this parameter.
* @param parent - the container (member) that holds a reference to this parameter.
* @param params - the type of each parameter.
* @return TRUE if this matcher matches any of the given parameters, FALSE otherwise.
*/
@ -93,8 +93,9 @@ public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo> {
* @author Kristian
*/
public static class Builder extends AbstractFuzzyMember.Builder<FuzzyMethodContract> {
@Override
public Builder requireModifier(int modifier) {
super.requireModifier(modifier);
super.requireModifier(modifier);
return this;
}
@ -106,49 +107,49 @@ public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo> {
@Override
public Builder banModifier(int modifier) {
super.banModifier(modifier);
super.banModifier(modifier);
return this;
}
@Override
public Builder nameRegex(String regex) {
super.nameRegex(regex);
super.nameRegex(regex);
return this;
}
@Override
public Builder nameRegex(Pattern pattern) {
super.nameRegex(pattern);
super.nameRegex(pattern);
return this;
}
@Override
public Builder nameExact(String name) {
super.nameExact(name);
super.nameExact(name);
return this;
}
@Override
public Builder declaringClassExactType(Class<?> declaringClass) {
super.declaringClassExactType(declaringClass);
super.declaringClassExactType(declaringClass);
return this;
}
@Override
public Builder declaringClassSuperOf(Class<?> declaringClass) {
super.declaringClassSuperOf(declaringClass);
super.declaringClassSuperOf(declaringClass);
return this;
}
@Override
public Builder declaringClassDerivedOf(Class<?> declaringClass) {
super.declaringClassDerivedOf(declaringClass);
super.declaringClassDerivedOf(declaringClass);
return this;
}
@Override
public Builder declaringClassMatching(AbstractFuzzyMatcher<Class<?>> classMatcher) {
super.declaringClassMatching(classMatcher);
super.declaringClassMatching(classMatcher);
return this;
}
@ -209,7 +210,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo> {
/**
* Add a new required parameters by type and order for any matching method.
* @param type - the types of every parameters in order.
* @param types - the types of every parameters in order.
* @return This builder, for chaining.
*/
public Builder parameterExactArray(Class<?>... types) {
@ -270,7 +271,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo> {
/**
* Require a void method.
* @return This builder, for chaining.
* @return This builder, for chaining.
*/
public Builder returnTypeVoid() {
return returnTypeExact(Void.TYPE);
@ -287,7 +288,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo> {
}
/**
* Set the expected super class of the return type for every matching method.
* Set the expected super class of the return type for every matching method.
* @param type - the return type, or a super class of it.
* @return This builder, for chaining.
*/
@ -429,7 +430,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo> {
/**
* Retrieve an immutable list of every parameter matcher for this method.
* @return Immutable list of every parameter matcher.
* @return Immutable list of every parameter matcher.
*/
public ImmutableList<ParameterClassMatcher> getParamMatchers() {
if (paramMatchers instanceof ImmutableList)
@ -440,7 +441,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo> {
/**
* Retrieve an immutable list of every exception matcher for this method.
* @return Immutable list of every exception matcher.
* @return Immutable list of every exception matcher.
*/
public List<ParameterClassMatcher> getExceptionMatchers() {
if (exceptionMatchers instanceof ImmutableList)
@ -478,7 +479,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo> {
return false;
// Finally, check parameters and exceptions
return matchParameters(params, value, paramMatchers) &&
return matchParameters(params, value, paramMatchers) &&
matchParameters(exceptions, value, exceptionMatchers);
}
// No match
@ -572,7 +573,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember<MethodInfo> {
} else if (obj instanceof FuzzyMethodContract && super.equals(obj)) {
FuzzyMethodContract other = (FuzzyMethodContract) obj;
return Objects.equal(paramCount, other.paramCount) &&
return Objects.equal(paramCount, other.paramCount) &&
Objects.equal(returnMatcher, other.returnMatcher) &&
Objects.equal(paramMatchers, other.paramMatchers) &&
Objects.equal(exceptionMatchers, other.exceptionMatchers);

Datei anzeigen

@ -156,8 +156,8 @@ public class DefaultInstances implements InstanceProvider {
* <li>Enums. Returns the first declared element.</li>
* <li>Collection interfaces, such as List and Set. Returns the most appropriate empty container.</li>
* <li>Any type with a public constructor that has parameters with defaults.</li>
* </ul>
* </ul>
* @param <T> Type
* @param type - the type to construct a default value.
* @return A default value/instance, or NULL if not possible.
*/
@ -167,6 +167,7 @@ public class DefaultInstances implements InstanceProvider {
/**
* Retrieve the constructor with the fewest number of parameters.
* @param <T> Type
* @param type - type to construct.
* @return A constructor with the fewest number of parameters, or NULL if the type has no constructors.
*/
@ -239,8 +240,8 @@ public class DefaultInstances implements InstanceProvider {
* <li>Enums. Returns the first declared element.</li>
* <li>Collection interfaces, such as List and Set. Returns the most appropriate empty container.</li>
* <li>Any type with a public constructor that has parameters with defaults.</li>
* </ul>
* </ul>
* @param <T> Type
* @param type - the type to construct a default value.
* @param providers - instance providers used during the construction.
* @return A default value/instance, or NULL if not possible.
@ -319,6 +320,7 @@ public class DefaultInstances implements InstanceProvider {
/**
* Used by the default instance provider to create a class from a given constructor.
* The default method uses reflection.
* @param <T> Type
* @param type - the type to create.
* @param constructor - the constructor to use.
* @param types - type of each parameter in order.

Datei anzeigen

@ -1,7 +1,7 @@
package com.comphenix.protocol.reflect.instances;
/**
* Invoked when a instance provider indicates that a given type cannot or should not be
* Invoked when a instance provider indicates that a given type cannot or should not be
* constructed under any circumstances.
*
* @author Kristian
@ -21,6 +21,7 @@ public class NotConstructableException extends IllegalArgumentException {
/**
* Construct a new not constructable exception with a custom message.
* @param message - detail message
*/
public NotConstructableException(String message) {
super(message);
@ -28,6 +29,8 @@ public class NotConstructableException extends IllegalArgumentException {
/**
* Construct a new not constructable exception with a custom message and cause.
* @param message - detail message
* @param cause - cause
*/
public NotConstructableException(String message, Throwable cause) {
super(message, cause);
@ -35,6 +38,7 @@ public class NotConstructableException extends IllegalArgumentException {
/**
* Construct a new not constructable exception with a custom cause.
* @param cause - cause
*/
public NotConstructableException(Throwable cause) {
super( cause);

Datei anzeigen

@ -6,7 +6,7 @@ package com.comphenix.protocol.timing;
*/
public class StatisticsStream extends OnlineComputation {
// This algorithm is due to Donald Knuth, as described in:
// Donald E. Knuth (1998). The Art of Computer Programming, volume 2:
// Donald E. Knuth (1998). The Art of Computer Programming, volume 2:
// Seminumerical Algorithms, 3rd edn., p. 232. Boston: Addison-Wesley.
private int count = 0;
@ -51,7 +51,7 @@ public class StatisticsStream extends OnlineComputation {
// As per Knuth
count++;
mean += delta / count;
m2 += delta * (value - mean);
m2 += delta * (value - mean);
// Update extremes
if (value < minimum)
@ -107,6 +107,7 @@ public class StatisticsStream extends OnlineComputation {
/**
* Combine the two statistics.
* @param other - the other statistics.
* @return Combined statistics
*/
public StatisticsStream add(StatisticsStream other) {
// Special cases
@ -147,8 +148,8 @@ public class StatisticsStream extends OnlineComputation {
if (count == 0)
return "StatisticsStream [Nothing recorded]";
return String.format("StatisticsStream [Average: %.3f, SD: %.3f, Min: %.3f, Max: %.3f, Count: %s]",
getMean(), getStandardDeviation(),
return String.format("StatisticsStream [Average: %.3f, SD: %.3f, Min: %.3f, Max: %.3f, Count: %s]",
getMean(), getStandardDeviation(),
getMinimum(), getMaximum(), getCount());
}
}

Datei anzeigen

@ -10,7 +10,7 @@ import com.google.common.collect.Maps;
* Tracks the invocation time for a particular plugin against a list of packets.
* @author Kristian
*/
public class TimedTracker {
public class TimedTracker {
// Table of packets and invocations
private Map<PacketType, StatisticsStream> packets = Maps.newHashMap();
private int observations;
@ -26,7 +26,7 @@ public class TimedTracker {
/**
* Stop and record the execution time since the creation of the given tracking token.
* @param trackingToken - the tracking token.
* @param packetId - the packet ID.
* @param type - the packet type.
*/
public synchronized void endTracking(long trackingToken, PacketType type) {
StatisticsStream stream = packets.get(type);
@ -57,7 +57,7 @@ public class TimedTracker {
for (Entry<PacketType, StatisticsStream> entry : packets.entrySet()) {
clone.put(
entry.getKey(),
entry.getKey(),
new StatisticsStream(entry.getValue())
);
}

Datei anzeigen

@ -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
*/
@ -66,7 +66,7 @@ public class ChatExtensions {
* @param message - the message to send.
* @throws InvocationTargetException If we were unable to send the message.
*/
public void sendMessageSilently(CommandSender receiver, String message) throws InvocationTargetException {
public void sendMessageSilently(CommandSender receiver, String message) throws InvocationTargetException {
if (receiver == null)
throw new IllegalArgumentException("receiver cannot be NULL.");
if (message == null)
@ -172,6 +172,7 @@ public class ChatExtensions {
* @param marginChar - the character to use as margin.
* @param marginWidth - the width (in characters) of the left and right margin.
* @param marginHeight - the height (in characters) of the top and buttom margin.
* @return Flowerboxed message
*/
public static String[] toFlowerBox(String[] message, String marginChar, int marginWidth, int marginHeight) {
String[] output = new String[message.length + marginHeight * 2];

Datei anzeigen

@ -23,6 +23,7 @@ public class HexDumper {
/**
* Retrieve a hex dumper tuned for lines of 80 characters:
* <table border="1">
* <caption>Values</caption>
* <tr>
* <th>Property</th>
* <th>Value</th>
@ -118,7 +119,7 @@ public class HexDumper {
* Set the number of groups in each line. This is limited by the supply of bytes in the byte array.
* <p>
* Use {@link Integer#MAX_VALUE} to effectively disable lines.
* @param groupLength - the length of each group.
* @param groupCount - the count of groups.
* @return This instance, for chaining.
*/
public HexDumper groupCount(int groupCount) {
@ -132,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 start - the starting index of the data.
* @param length - the number of bytes to dump.
* @throws IOException Any underlying IO exception.
*/
@ -158,8 +158,6 @@ public class HexDumper {
* Append the hex dump of the given data to the string builder, using the current formatting settings.
* @param builder - the builder.
* @param data - the data to dump.
* @param start - the starting index of the data.
* @param length - the number of bytes to dump.
*/
public void appendTo(StringBuilder builder, byte[] data) {
appendTo(builder, data, 0, data.length);

Datei anzeigen

@ -1752,12 +1752,14 @@ public class MinecraftReflection {
}
private static MethodAccessor asCraftMirror;
private static MethodAccessor asCraftCopy;
private static MethodAccessor asNMSCopy;
/**
* Retrieve a CraftItemStack from a given ItemStack.
* @param bukkitItemStack - the Bukkit ItemStack to convert.
* @return A CraftItemStack as an ItemStack.
* Retrieve a CraftItemStack from a given NMS ItemStack.
*
* @param nmsItem - the NMS ItemStack to convert.
* @return A CraftItemStack as a NMS ItemStack.
*/
public static ItemStack getBukkitItemStack(Object nmsItem) {
if (asCraftMirror == null) {
@ -1768,9 +1770,24 @@ public class MinecraftReflection {
}
/**
* Retrieve the Bukkit ItemStack from a given net.minecraft.server ItemStack.
* @param minecraftItemStack - the NMS ItemStack to wrap.
* @return The wrapped ItemStack.
* Retrieve a CraftItemStack from a given ItemStack.
*
* @param stack - the Bukkit ItemStack to convert.
* @return A CraftItemStack as an ItemStack.
*/
public static ItemStack getCraftItemStack(ItemStack stack) {
if (asCraftCopy == null) {
asCraftCopy = Accessors.getMethodAccessor(getCraftItemStackClass(), "asCraftCopy", ItemStack.class);
}
return (ItemStack) asCraftCopy.invoke(null, stack);
}
/**
* Retrieve the NMS ItemStack from a given ItemStack.
*
* @param stack - the ItemStack to convert.
* @return The NMS ItemStack.
*/
public static Object getMinecraftItemStack(ItemStack stack) {
if (asNMSCopy == null) {

Datei anzeigen

@ -28,6 +28,8 @@ public class SafeCacheBuilder<K, V> {
/**
* Construct a new safe cache builder.
* @param <K> Key type
* @param <V> Value type
*
* @return A new cache builder.
*/
@ -54,9 +56,12 @@ public class SafeCacheBuilder<K, V> {
* <b>Note:</b>The default may change in the future. If you care about this
* value, you should always choose it explicitly.
*
* @param concurrencyLevel New concurrency level
* @return This for chaining
*
* @throws IllegalArgumentException if {@code concurrencyLevel} is
* nonpositive
* @throws IllegalStateException if a concurrency level was already set
* nonpositive
* @throws IllegalStateExeption if a concurrency level was already set
*/
public SafeCacheBuilder<K, V> concurrencyLevel(int concurrencyLevel) {
builder.concurrencyLevel(concurrencyLevel);
@ -66,8 +71,7 @@ public class SafeCacheBuilder<K, V> {
/**
* Specifies that each entry should be automatically removed from the cache
* once a fixed duration has elapsed after the entry's creation, or last
* access. Access time is reset by {@link com.google.common.cache.Cache#get Cache.get()} and
* {@link com.google.common.cache.Cache#getUnchecked Cache.getUnchecked()},
* access. Access time is reset by {@link com.google.common.cache.Cache#get Cache.get()},
* but not by operations on the view returned by
* {@link com.google.common.cache.Cache#asMap() Cache.asMap()}.
*
@ -86,6 +90,8 @@ public class SafeCacheBuilder<K, V> {
* @param duration the length of time after an entry is last accessed 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 idle or time to live was
* already set
@ -280,7 +286,7 @@ public class SafeCacheBuilder<K, V> {
/**
* Returns the cache wrapped as a ConcurrentMap.
* <>
* <p>
* We can't return the direct Cache instance as it changed in Guava 13.
* @return The cache as a map.
*/

Datei anzeigen

@ -12,7 +12,7 @@ public abstract class AbstractWrapper {
/**
* Construct a new NMS wrapper.
* @param handle - the wrapped NMS object.
* @param handleType - the NMS handle type.
*/
public AbstractWrapper(Class<?> handleType) {
this.handleType = Preconditions.checkNotNull(handleType, "handleType cannot be NULL");

Datei anzeigen

@ -210,8 +210,8 @@ public class BukkitConverters {
/**
* Retrieve an equivalent converter for a map of generic keys and primitive values.
* @param genericItemType - the generic item type.
* @param itemConverter - an equivalent converter for the generic type.
* @param genericKeyType - the generic key type.
* @param keyConverter - an equivalent converter for the generic type.
* @return An equivalent converter.
*/
public static <T, U> EquivalentConverter<Map<T, U>> getMapConverter(
@ -1006,7 +1006,7 @@ public class BukkitConverters {
}
/**
* Retrieve every NMS <-> Bukkit converter as unwrappers.
* Retrieve every NMS to/from Bukkit converter as unwrappers.
* @return Every unwrapper.
*/
public static List<Unwrapper> getUnwrappers() {

Datei anzeigen

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

Datei anzeigen

@ -175,7 +175,7 @@ public class WrappedServerPing extends AbstractWrapper {
/**
* Set the message of the day.
* @param description - the message.
* @param message - the message.
*/
public void setMotD(String message) {
setMotD(WrappedChatComponent.fromText(message));
@ -200,9 +200,9 @@ public class WrappedServerPing extends AbstractWrapper {
/**
* Retrieve the displayed number of online players.
* @see {@link #setPlayersOnline(int)} for more information.
* @return The displayed number.
* @throws IllegalStateException If the player count has been hidden via {@link #setPlayersVisible(boolean)}.
* @see #setPlayersOnline(int)
*/
public int getPlayersOnline() {
if (players == null)
@ -225,9 +225,9 @@ public class WrappedServerPing extends AbstractWrapper {
/**
* Retrieve the displayed maximum number of players.
* @see {@link #setPlayersMaximum(int)} for more information.
* @return The maximum number.
* @throws IllegalStateException If the player maximum has been hidden via {@link #setPlayersVisible(boolean)}.
* @see #setPlayersMaximum(int)
*/
public int getPlayersMaximum() {
if (players == null)

Datei anzeigen

@ -15,7 +15,6 @@ public class WrappedSignedProperty extends AbstractWrapper {
* @param name - the name of the property.
* @param value - the value of the property.
* @param signature - the BASE64-encoded signature of the value.
* @return The signed property.
*/
public WrappedSignedProperty(String name, String value, String signature) {
this(new Property(name, value, signature));

Datei anzeigen

@ -36,7 +36,7 @@ public class WrappedStatistic extends AbstractWrapper {
}
/**
* Construct a new wrapper from a given underlying statistics.
* Construct a new wrapper from a given underlying statistics.
* @param handle - the statistics.
* @return The wrapped statistics.
*/
@ -46,7 +46,7 @@ public class WrappedStatistic extends AbstractWrapper {
/**
* Construct a wrapper around an existing game profile.
* @param profile - the underlying profile.
* @param name - statistic name.
* @return The wrapped statistics, or NULL if not found.
*/
public static WrappedStatistic fromName(String name) {
@ -60,9 +60,10 @@ public class WrappedStatistic extends AbstractWrapper {
*/
public static Iterable<WrappedStatistic> values() {
@SuppressWarnings("unchecked")
Map<Object, Object> map = (Map<Object, Object>) MAP_ACCESSOR.get(null);
Map<Object, Object> map = (Map<Object, Object>) MAP_ACCESSOR.get(null);
return Iterables.transform(map.values(), new Function<Object, WrappedStatistic>() {
@Override
public WrappedStatistic apply(Object handle) {
return fromHandle(handle);
};

Datei anzeigen

@ -186,6 +186,7 @@ public class WrappedWatchableObject extends AbstractWrapper {
* Retrieve the type ID of a watchable object.
* <p>
* <table border=1>
* <caption>Type to Value</caption>
* <tbody>
* <tr>
* <th>Type ID</th>
@ -230,9 +231,9 @@ public class WrappedWatchableObject extends AbstractWrapper {
/**
* Set the type ID of a watchable object.
* @see {@link #getTypeID()} for more information.
* @param id - the new ID.
* @throws FieldAccessException Reflection failed.
* @see #getTypeID()
*/
public void setTypeID(int id) throws FieldAccessException {
modifier.<Integer>withType(int.class).write(0, id);

Datei anzeigen

@ -19,18 +19,18 @@ import javax.annotation.Nonnull;
*/
public interface NbtCompound extends NbtBase<Map<String, NbtBase<?>>>, Iterable<NbtBase<?>> {
@Override
@Deprecated()
@Deprecated
public Map<String, NbtBase<?>> getValue();
/**
* Determine if an entry with the given key exists or not.
* @param key - the key to lookup.
* @param key - the key to lookup.
* @return TRUE if an entry with the given key exists, FALSE otherwise.
*/
public abstract boolean containsKey(String key);
/**
* Retrieve a Set view of the keys of each entry in this compound.
* Retrieve a Set view of the keys of each entry in this compound.
* @return The keys of each entry.
*/
public abstract Set<String> getKeys();
@ -260,7 +260,7 @@ public interface NbtCompound extends NbtBase<Map<String, NbtBase<?>>>, Iterable<
public abstract NbtCompound put(String key, int[] value);
/**
* Associates a given Java primitive value, list, map or NbtBase<?> with a certain key.
* Associates a given Java primitive value, list, map or NbtBase with a certain key.
* <p>
* If the value is NULL, the corresponding key is removed. Any Map or List will be converted
* to a corresponding NbtCompound or NbtList.
@ -341,5 +341,6 @@ public interface NbtCompound extends NbtBase<Map<String, NbtBase<?>>>, Iterable<
* Retrieve an iterator view of the NBT tags stored in this compound.
* @return The tags stored in this compound.
*/
@Override
public abstract Iterator<NbtBase<?>> iterator();
}

Datei anzeigen

@ -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
*/
@ -130,8 +130,8 @@ public class NbtFactory {
/**
* Set the NBT compound tag of a given item stack.
* <p>
* The item stack must be a wrapper for a CraftItemStack. Use
* {@link MinecraftReflection#getBukkitItemStack(ItemStack)} if not.
* The item stack must be a wrapper for a CraftItemStack. Use
* {@link MinecraftReflection#getCraftItemStack(ItemStack)} if not.
* @param stack - the item stack, cannot be air.
* @param compound - the new NBT compound, or NULL to remove it.
* @throws IllegalArgumentException If the stack is not a CraftItemStack, or it represents air.
@ -148,8 +148,8 @@ public class NbtFactory {
* auxillary data such as enchanting, name and lore is stored. It doesn't include the items
* material, damage value or count.
* <p>
* The item stack must be a wrapper for a CraftItemStack. Use
* {@link MinecraftReflection#getBukkitItemStack(ItemStack)} if not.
* The item stack must be a wrapper for a CraftItemStack. Use
* {@link MinecraftReflection#getCraftItemStack(ItemStack)} if not.
* @param stack - the item stack.
* @return A wrapper for its NBT tag.
*/
@ -189,7 +189,7 @@ public class NbtFactory {
// Would be nice to avoid this, but alas - we have to use Java 6
if (input != null) Closeables.close(input, swallow);
else if (stream != null) Closeables.close(stream, swallow);
}
}
}
/**
@ -214,12 +214,12 @@ public class NbtFactory {
// Note the order
if (output != null) Closeables.close(output, swallow);
else if (stream != null) Closeables.close(stream, swallow);
}
}
}
/**
* Retrieve the NBT tile entity that represents the given block.
* @param state - the block state.
* @param block - the block.
* @return The NBT compound, or NULL if the state doesn't have a tile entity.
*/
public static NbtCompound readBlockState(Block block) {
@ -274,7 +274,7 @@ public class NbtFactory {
// Use the first and best NBT tag
return itemStackModifier.
withTarget(nmsStack).
withType(MinecraftReflection.getNBTBaseClass(),
withType(MinecraftReflection.getNBTBaseClass(),
BukkitConverters.getNbtConverter());
}
@ -332,7 +332,7 @@ public class NbtFactory {
/**
* Constructs a NBT tag of type string.
* @param name - name of the tag.
* @param value - value of the tag.
* @param value - value of the tag.
* @return The constructed NBT tag.
*/
public static NbtBase<String> of(String name, String value) {
@ -342,7 +342,7 @@ public class NbtFactory {
/**
* Constructs a NBT tag of type byte.
* @param name - name of the tag.
* @param value - value of the tag.
* @param value - value of the tag.
* @return The constructed NBT tag.
*/
public static NbtBase<Byte> of(String name, byte value) {
@ -352,7 +352,7 @@ public class NbtFactory {
/**
* Constructs a NBT tag of type short.
* @param name - name of the tag.
* @param value - value of the tag.
* @param value - value of the tag.
* @return The constructed NBT tag.
*/
public static NbtBase<Short> of(String name, short value) {
@ -362,7 +362,7 @@ public class NbtFactory {
/**
* Constructs a NBT tag of type int.
* @param name - name of the tag.
* @param value - value of the tag.
* @param value - value of the tag.
* @return The constructed NBT tag.
*/
public static NbtBase<Integer> of(String name, int value) {
@ -372,7 +372,7 @@ public class NbtFactory {
/**
* Constructs a NBT tag of type long.
* @param name - name of the tag.
* @param value - value of the tag.
* @param value - value of the tag.
* @return The constructed NBT tag.
*/
public static NbtBase<Long> of(String name, long value) {
@ -382,7 +382,7 @@ public class NbtFactory {
/**
* Constructs a NBT tag of type float.
* @param name - name of the tag.
* @param value - value of the tag.
* @param value - value of the tag.
* @return The constructed NBT tag.
*/
public static NbtBase<Float> of(String name, float value) {
@ -392,7 +392,7 @@ public class NbtFactory {
/**
* Constructs a NBT tag of type double.
* @param name - name of the tag.
* @param value - value of the tag.
* @param value - value of the tag.
* @return The constructed NBT tag.
*/
public static NbtBase<Double> of(String name, double value) {
@ -402,7 +402,7 @@ public class NbtFactory {
/**
* Constructs a NBT tag of type byte array.
* @param name - name of the tag.
* @param value - value of the tag.
* @param value - value of the tag.
* @return The constructed NBT tag.
*/
public static NbtBase<byte[]> of(String name, byte[] value) {
@ -412,7 +412,7 @@ public class NbtFactory {
/**
* Constructs a NBT tag of type int array.
* @param name - name of the tag.
* @param value - value of the tag.
* @param value - value of the tag.
* @return The constructed NBT tag.
*/
public static NbtBase<int[]> of(String name, int[] value) {
@ -421,7 +421,7 @@ public class NbtFactory {
/**
* Construct a new NBT compound initialized with a given list of NBT values.
* @param name - the name of the compound wrapper.
* @param name - the name of the compound wrapper.
* @param list - the list of elements to add.
* @return The new wrapped NBT compound.
*/
@ -431,7 +431,7 @@ public class NbtFactory {
/**
* Construct a new NBT compound wrapper.
* @param name - the name of the compound wrapper.
* @param name - the name of the compound wrapper.
* @return The new wrapped NBT compound.
*/
public static NbtCompound ofCompound(String name) {
@ -519,7 +519,7 @@ public class NbtFactory {
if (type == NbtType.TAG_COMPOUND)
return (NbtWrapper<T>) new WrappedCompound(handle);
else if (type == NbtType.TAG_LIST)
return (NbtWrapper<T>) new WrappedList(handle);
return new WrappedList(handle);
else
return new WrappedElement<T>(handle);
}
@ -532,7 +532,7 @@ public class NbtFactory {
if (type == NbtType.TAG_COMPOUND)
return (NbtWrapper<T>) new WrappedCompound(handle, name);
else if (type == NbtType.TAG_LIST)
return (NbtWrapper<T>) new WrappedList(handle, name);
return new WrappedList(handle, name);
else
return new WrappedElement<T>(handle, name);
}

Datei anzeigen

@ -23,7 +23,7 @@ public interface NbtList<TType> extends NbtBase<List<NbtBase<TType>>>, Iterable<
public static String EMPTY_NAME = "";
/**
* Get the type of each element.
* Get the type of each element.
* <p>
* This will be {@link NbtType#TAG_END TAG_END} if the NBT list has just been created.
* @return Element type.
@ -51,56 +51,56 @@ public interface NbtList<TType> extends NbtBase<List<NbtBase<TType>>>, Iterable<
public abstract void add(NbtBase<TType> element);
/**
* Add a new string element to the list.
* Add a new string element to the list.
* @param value - the string element to add.
* @throws IllegalArgumentException If this is not a list of strings.
*/
public abstract void add(String value);
/**
* Add a new byte element to the list.
* Add a new byte element to the list.
* @param value - the byte element to add.
* @throws IllegalArgumentException If this is not a list of bytes.
*/
public abstract void add(byte value);
/**
* Add a new short element to the list.
* Add a new short element to the list.
* @param value - the short element to add.
* @throws IllegalArgumentException If this is not a list of shorts.
*/
public abstract void add(short value);
/**
* Add a new integer element to the list.
* Add a new integer element to the list.
* @param value - the string element to add.
* @throws IllegalArgumentException If this is not a list of integers.
*/
public abstract void add(int value);
/**
* Add a new long element to the list.
* Add a new long element to the list.
* @param value - the string element to add.
* @throws IllegalArgumentException If this is not a list of longs.
*/
public abstract void add(long value);
/**
* Add a new double element to the list.
* Add a new double element to the list.
* @param value - the double element to add.
* @throws IllegalArgumentException If this is not a list of doubles.
*/
public abstract void add(double value);
/**
* Add a new byte array element to the list.
* Add a new byte array element to the list.
* @param value - the byte array element to add.
* @throws IllegalArgumentException If this is not a list of byte arrays.
*/
public abstract void add(byte[] value);
/**
* Add a new int array element to the list.
* Add a new int array element to the list.
* @param value - the int array element to add.
* @throws IllegalArgumentException If this is not a list of int arrays.
*/
@ -116,7 +116,7 @@ public interface NbtList<TType> extends NbtBase<List<NbtBase<TType>>>, Iterable<
* Retrieve an element by index.
* @param index - index of the element to retrieve.
* @return The element to retrieve.
* @throws IndexOutOfBoundsException If the index is out of range (index < 0 || index >= size())
* @throws IndexOutOfBoundsException If the index is out of range
*/
public abstract TType getValue(int index);
@ -135,5 +135,6 @@ public interface NbtList<TType> extends NbtBase<List<NbtBase<TType>>>, Iterable<
/**
* Iterate over all the elements in this list.
*/
@Override
public abstract Iterator<TType> iterator();
}