diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PluginVerifier.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PluginVerifier.java
index ebb98a26..2e66cf5d 100644
--- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PluginVerifier.java
+++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PluginVerifier.java
@@ -83,7 +83,7 @@ class PluginVerifier {
* @throws PluginNotFoundException If a plugin with the given name cannot be found.
*/
private Plugin getPlugin(String pluginName) {
- Plugin plugin = Bukkit.getPluginManager().getPlugin(pluginName);
+ Plugin plugin = getPluginOrDefault(pluginName);
// Ensure that the plugin exists
if (plugin != null)
@@ -92,6 +92,15 @@ class PluginVerifier {
throw new PluginNotFoundException("Cannot find plugin " + pluginName);
}
+ /**
+ * Retrieve a plugin by name.
+ * @param pluginName - the non-null name of the plugin to retrieve.
+ * @return The retrieved plugin, or NULL if not found.
+ */
+ private Plugin getPluginOrDefault(String pluginName) {
+ return Bukkit.getPluginManager().getPlugin(pluginName);
+ }
+
/**
* Performs simple verifications on the given plugin.
*
@@ -183,15 +192,15 @@ class PluginVerifier {
return Sets.newHashSet(list);
}
- // Avoid cycles
- private boolean hasDependency(Plugin plugin, Plugin dependency, Set checked) {
+ // Avoid cycles. DFS.
+ private boolean hasDependency(Plugin plugin, Plugin dependency, Set checking) {
Set childNames = Sets.union(
safeConversion(plugin.getDescription().getDepend()),
safeConversion(plugin.getDescription().getSoftDepend())
);
// Ensure that the same plugin isn't processed twice
- if (!checked.add(plugin.getName())) {
+ if (!checking.add(plugin.getName())) {
throw new IllegalStateException("Cycle detected in dependency graph: " + plugin);
}
// Look for the dependency in the immediate children
@@ -201,13 +210,16 @@ class PluginVerifier {
// Recurse through their dependencies
for (String childName : childNames) {
- Plugin childPlugin = getPlugin(childName);
+ Plugin childPlugin = getPluginOrDefault(childName);
- if (hasDependency(childPlugin, dependency, checked)) {
+ if (childPlugin != null && hasDependency(childPlugin, dependency, checking)) {
return true;
}
}
+ // Cross edges are permitted
+ checking.remove(plugin.getName());
+
// No dependency found!
return false;
}
diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedArrayList.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedArrayList.java
index bc4cf76f..4884dce0 100644
--- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedArrayList.java
+++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedArrayList.java
@@ -1,194 +1,193 @@
-/*
- * 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
- * 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.
- * 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
- * 02111-1307 USA
- */
-
-package com.comphenix.protocol.injector.player;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-import com.comphenix.protocol.Packets;
-import com.comphenix.protocol.ProtocolLibrary;
-import com.comphenix.protocol.error.Report;
-import com.comphenix.protocol.error.ReportType;
-import com.comphenix.protocol.injector.ListenerInvoker;
-import com.comphenix.protocol.injector.player.NetworkFieldInjector.FakePacket;
-import com.comphenix.protocol.utility.MinecraftReflection;
-import com.google.common.collect.MapMaker;
-
-import net.sf.cglib.proxy.Callback;
-import net.sf.cglib.proxy.Enhancer;
-import net.sf.cglib.proxy.MethodInterceptor;
-import net.sf.cglib.proxy.MethodProxy;
-
-/**
- * The array list that notifies when packets are sent by the server.
- *
- * @author Kristian
- */
-class InjectedArrayList extends ArrayList