Use correct Guava package, fix a few compatibility issues
Dieser Commit ist enthalten in:
Ursprung
b1b5408c53
Commit
e0f7c72e18
@ -22,13 +22,12 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.minecraft.util.com.google.common.io.ByteStreams;
|
|
||||||
import net.minecraft.util.com.google.common.io.InputSupplier;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.google.common.collect.DiscreteDomains;
|
import com.google.common.collect.DiscreteDomains;
|
||||||
import com.google.common.collect.Range;
|
import com.google.common.collect.Range;
|
||||||
import com.google.common.collect.Ranges;
|
import com.google.common.collect.Ranges;
|
||||||
|
import com.google.common.io.ByteStreams;
|
||||||
|
import com.google.common.io.InputSupplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author dmulloy2
|
* @author dmulloy2
|
||||||
|
@ -261,6 +261,8 @@ public class ProtocolLibrary extends JavaPlugin {
|
|||||||
throw e;
|
throw e;
|
||||||
} catch (ThreadDeath e) {
|
} catch (ThreadDeath e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
} catch (LinkageError e) {
|
||||||
|
logger.warning("Failed to register command " + command.name() + ": " + e);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
reporter.reportWarning(this, Report.newBuilder(REPORT_CANNOT_REGISTER_COMMAND)
|
reporter.reportWarning(this, Report.newBuilder(REPORT_CANNOT_REGISTER_COMMAND)
|
||||||
.messageParam(command.name(), e.getMessage()).error(e));
|
.messageParam(command.name(), e.getMessage()).error(e));
|
||||||
|
@ -122,13 +122,21 @@ public class DetailedErrorReporter implements ErrorReporter {
|
|||||||
throw new IllegalArgumentException("Plugin cannot be NULL.");
|
throw new IllegalArgumentException("Plugin cannot be NULL.");
|
||||||
|
|
||||||
this.pluginReference = new WeakReference<Plugin>(plugin);
|
this.pluginReference = new WeakReference<Plugin>(plugin);
|
||||||
this.pluginName = plugin.getName();
|
this.pluginName = getNameSafely(plugin);
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
this.supportURL = supportURL;
|
this.supportURL = supportURL;
|
||||||
this.maxErrorCount = maxErrorCount;
|
this.maxErrorCount = maxErrorCount;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getNameSafely(Plugin plugin) {
|
||||||
|
try {
|
||||||
|
return plugin.getName();
|
||||||
|
} catch (LinkageError e) {
|
||||||
|
return "ProtocolLib";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Attempt to get the logger.
|
// Attempt to get the logger.
|
||||||
private static Logger getBukkitLogger() {
|
private static Logger getBukkitLogger() {
|
||||||
try {
|
try {
|
||||||
|
@ -1166,4 +1166,9 @@ public class PacketContainer implements Serializable {
|
|||||||
return WrappedChatComponent[].class;
|
return WrappedChatComponent[].class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "PacketContainer[type=" + type + ", structureModifier=" + structureModifier + "]";
|
||||||
|
}
|
||||||
|
}
|
@ -2,16 +2,16 @@
|
|||||||
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
|
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
|
||||||
* Copyright (C) 2012 Kristian S. Stangeland
|
* Copyright (C) 2012 Kristian S. Stangeland
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
* 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
|
* GNU General Public License as published by the Free Software Foundation; either version 2 of
|
||||||
* the License, or (at your option) any later version.
|
* 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;
|
* 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.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* 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;
|
* 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
|
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
* 02111-1307 USA
|
* 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ import com.google.common.collect.Multimaps;
|
|||||||
import com.google.common.collect.SetMultimap;
|
import com.google.common.collect.SetMultimap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a packet sending or receiving event. Changes to the packet will be
|
* Represents a packet sending or receiving event. Changes to the packet will be
|
||||||
* reflected in the final version to be sent or received. It is also possible to cancel an event.
|
* reflected in the final version to be sent or received. It is also possible to cancel an event.
|
||||||
* @author Kristian
|
* @author Kristian
|
||||||
*/
|
*/
|
||||||
@ -47,7 +47,7 @@ public class PacketEvent extends EventObject implements Cancellable {
|
|||||||
public static final ReportType REPORT_CHANGING_PACKET_TYPE_IS_CONFUSING = new ReportType(
|
public static final ReportType REPORT_CHANGING_PACKET_TYPE_IS_CONFUSING = new ReportType(
|
||||||
"Plugin %s changed packet type from %s to %s in packet listener. This is confusing for other plugins! (Not an error, though!)");
|
"Plugin %s changed packet type from %s to %s in packet listener. This is confusing for other plugins! (Not an error, though!)");
|
||||||
|
|
||||||
private static final SetMultimap<PacketType, PacketType> CHANGE_WARNINGS =
|
private static final SetMultimap<PacketType, PacketType> CHANGE_WARNINGS =
|
||||||
Multimaps.synchronizedSetMultimap(HashMultimap.<PacketType, PacketType>create());
|
Multimaps.synchronizedSetMultimap(HashMultimap.<PacketType, PacketType>create());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -229,7 +229,7 @@ public class PacketEvent extends EventObject implements Cancellable {
|
|||||||
if (this.packet != null && !Objects.equal(oldType, newType)) {
|
if (this.packet != null && !Objects.equal(oldType, newType)) {
|
||||||
// Only report this once
|
// Only report this once
|
||||||
if (CHANGE_WARNINGS.put(oldType, newType)) {
|
if (CHANGE_WARNINGS.put(oldType, newType)) {
|
||||||
ProtocolLibrary.getErrorReporter().reportWarning(this,
|
ProtocolLibrary.getErrorReporter().reportWarning(this,
|
||||||
Report.newBuilder(REPORT_CHANGING_PACKET_TYPE_IS_CONFUSING).
|
Report.newBuilder(REPORT_CHANGING_PACKET_TYPE_IS_CONFUSING).
|
||||||
messageParam(oldType, newType).
|
messageParam(oldType, newType).
|
||||||
build());
|
build());
|
||||||
@ -261,6 +261,7 @@ public class PacketEvent extends EventObject implements Cancellable {
|
|||||||
* Retrieves whether or not the packet should be cancelled.
|
* Retrieves whether or not the packet should be cancelled.
|
||||||
* @return TRUE if it should be cancelled, FALSE otherwise.
|
* @return TRUE if it should be cancelled, FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
@ -307,6 +308,7 @@ public class PacketEvent extends EventObject implements Cancellable {
|
|||||||
*
|
*
|
||||||
* @param cancel - TRUE if it should be cancelled, FALSE otherwise.
|
* @param cancel - TRUE if it should be cancelled, FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
if (readOnly)
|
if (readOnly)
|
||||||
throw new IllegalStateException("The packet event is read-only.");
|
throw new IllegalStateException("The packet event is read-only.");
|
||||||
@ -354,12 +356,12 @@ public class PacketEvent extends EventObject implements Cancellable {
|
|||||||
return asyncMarker;
|
return asyncMarker;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Set the asynchronous marker.
|
* Set the asynchronous marker.
|
||||||
* <p>
|
* <p>
|
||||||
* If the marker is non-null at the end of an synchronous event processing, the packet will be scheduled
|
* If the marker is non-null at the end of an synchronous event processing, the packet will be scheduled
|
||||||
* to be processed asynchronously with the given settings.
|
* to be processed asynchronously with the given settings.
|
||||||
* <p>
|
* <p>
|
||||||
* Note that if there are no asynchronous events that can receive this packet, the marker should be NULL.
|
* Note that if there are no asynchronous events that can receive this packet, the marker should be NULL.
|
||||||
* @param asyncMarker - the new asynchronous marker, or NULL.
|
* @param asyncMarker - the new asynchronous marker, or NULL.
|
||||||
* @throws IllegalStateException If the current event is asynchronous.
|
* @throws IllegalStateException If the current event is asynchronous.
|
||||||
*/
|
*/
|
||||||
@ -425,7 +427,7 @@ public class PacketEvent extends EventObject implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void writeObject(ObjectOutputStream output) throws IOException {
|
private void writeObject(ObjectOutputStream output) throws IOException {
|
||||||
// Default serialization
|
// Default serialization
|
||||||
output.defaultWriteObject();
|
output.defaultWriteObject();
|
||||||
|
|
||||||
// Write the name of the player (or NULL if it's not set)
|
// Write the name of the player (or NULL if it's not set)
|
||||||
@ -439,10 +441,15 @@ public class PacketEvent extends EventObject implements Cancellable {
|
|||||||
final SerializedOfflinePlayer serialized = (SerializedOfflinePlayer) input.readObject();
|
final SerializedOfflinePlayer serialized = (SerializedOfflinePlayer) input.readObject();
|
||||||
|
|
||||||
// Better than nothing
|
// Better than nothing
|
||||||
if (serialized != null) {
|
if (serialized != null) {
|
||||||
// Store it, to prevent weak reference from cleaning up the reference
|
// Store it, to prevent weak reference from cleaning up the reference
|
||||||
offlinePlayer = serialized.getPlayer();
|
offlinePlayer = serialized.getPlayer();
|
||||||
playerReference = new WeakReference<Player>(offlinePlayer);
|
playerReference = new WeakReference<Player>(offlinePlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "PacketEvent[player=" + getPlayer() + ", packet=" + packet + "]";
|
||||||
|
}
|
||||||
|
}
|
@ -4,10 +4,12 @@ import java.util.Collections;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginLoadOrder;
|
import org.bukkit.plugin.PluginLoadOrder;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,10 +75,16 @@ class PluginVerifier {
|
|||||||
public PluginVerifier(Plugin dependency) {
|
public PluginVerifier(Plugin dependency) {
|
||||||
if (dependency == null)
|
if (dependency == null)
|
||||||
throw new IllegalArgumentException("dependency cannot be NULL.");
|
throw new IllegalArgumentException("dependency cannot be NULL.");
|
||||||
// This would screw with the assumption in hasDependency(Plugin, Plugin)
|
|
||||||
if (safeConversion(dependency.getDescription().getLoadBefore()).size() > 0)
|
try {
|
||||||
throw new IllegalArgumentException("dependency cannot have a load directives.");
|
// This would screw with the assumption in hasDependency(Plugin, Plugin)
|
||||||
|
if (safeConversion(dependency.getDescription().getLoadBefore()).size() > 0)
|
||||||
|
throw new IllegalArgumentException("dependency cannot have a load directives.");
|
||||||
|
} catch (LinkageError e) {
|
||||||
|
// They're probably using an ancient version of Bukkit
|
||||||
|
ProtocolLibrary.log(Level.WARNING, "Failed to determine loadBefore: " + e);
|
||||||
|
}
|
||||||
|
|
||||||
this.dependency = dependency;
|
this.dependency = dependency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +101,7 @@ class PluginVerifier {
|
|||||||
if (plugin != null)
|
if (plugin != null)
|
||||||
return plugin;
|
return plugin;
|
||||||
else
|
else
|
||||||
throw new PluginNotFoundException("Cannot find plugin " + pluginName);
|
throw new PluginNotFoundException("Cannot find plugin " + pluginName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,7 +161,7 @@ class PluginVerifier {
|
|||||||
/**
|
/**
|
||||||
* Determine if a given plugin is guarenteed to be loaded before the other.
|
* Determine if a given plugin is guarenteed to be loaded before the other.
|
||||||
* <p>
|
* <p>
|
||||||
* Note that the before plugin is assumed to have no "load" directives - that is, plugins to be
|
* Note that the before plugin is assumed to have no "load" directives - that is, plugins to be
|
||||||
* loaded after itself. The after plugin may have "load" directives, but it is irrelevant for our purposes.
|
* loaded after itself. The after plugin may have "load" directives, but it is irrelevant for our purposes.
|
||||||
* @param beforePlugin - the plugin that is loaded first.
|
* @param beforePlugin - the plugin that is loaded first.
|
||||||
* @param afterPlugin - the plugin that is loaded last.
|
* @param afterPlugin - the plugin that is loaded last.
|
||||||
@ -166,7 +174,7 @@ class PluginVerifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// No dependency - check the load order
|
// No dependency - check the load order
|
||||||
if (beforePlugin.getDescription().getLoad() == PluginLoadOrder.STARTUP &&
|
if (beforePlugin.getDescription().getLoad() == PluginLoadOrder.STARTUP &&
|
||||||
afterPlugin.getDescription().getLoad() == PluginLoadOrder.POSTWORLD) {
|
afterPlugin.getDescription().getLoad() == PluginLoadOrder.POSTWORLD) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -177,14 +185,14 @@ class PluginVerifier {
|
|||||||
* Determine if a plugin has a given dependency, either directly or indirectly.
|
* Determine if a plugin has a given dependency, either directly or indirectly.
|
||||||
* @param plugin - the plugin to check.
|
* @param plugin - the plugin to check.
|
||||||
* @param dependency - the dependency to find.
|
* @param dependency - the dependency to find.
|
||||||
* @return TRUE if the plugin has the given dependency, FALSE otherwise.
|
* @return TRUE if the plugin has the given dependency, FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
private boolean hasDependency(Plugin plugin, Plugin dependency) {
|
private boolean hasDependency(Plugin plugin, Plugin dependency) {
|
||||||
return hasDependency(plugin, dependency, Sets.<String>newHashSet());
|
return hasDependency(plugin, dependency, Sets.<String>newHashSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a list to a set.
|
* Convert a list to a set.
|
||||||
* <p>
|
* <p>
|
||||||
* A null list will be converted to an empty set.
|
* A null list will be converted to an empty set.
|
||||||
* @param list - the list to convert.
|
* @param list - the list to convert.
|
||||||
|
@ -656,4 +656,9 @@ public class StructureModifier<TField> {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "StructureModifier[fieldType=" + fieldType + ", data=" + data + "]";
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren