Permit cross edges when validating dependencies. FIXES 91.
Dieser Commit ist enthalten in:
Ursprung
6af440789c
Commit
02b5dec304
@ -83,7 +83,7 @@ class PluginVerifier {
|
|||||||
* @throws PluginNotFoundException If a plugin with the given name cannot be found.
|
* @throws PluginNotFoundException If a plugin with the given name cannot be found.
|
||||||
*/
|
*/
|
||||||
private Plugin getPlugin(String pluginName) {
|
private Plugin getPlugin(String pluginName) {
|
||||||
Plugin plugin = Bukkit.getPluginManager().getPlugin(pluginName);
|
Plugin plugin = getPluginOrDefault(pluginName);
|
||||||
|
|
||||||
// Ensure that the plugin exists
|
// Ensure that the plugin exists
|
||||||
if (plugin != null)
|
if (plugin != null)
|
||||||
@ -92,6 +92,15 @@ class PluginVerifier {
|
|||||||
throw new PluginNotFoundException("Cannot find plugin " + pluginName);
|
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.
|
* Performs simple verifications on the given plugin.
|
||||||
* <p>
|
* <p>
|
||||||
@ -183,15 +192,15 @@ class PluginVerifier {
|
|||||||
return Sets.newHashSet(list);
|
return Sets.newHashSet(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Avoid cycles
|
// Avoid cycles. DFS.
|
||||||
private boolean hasDependency(Plugin plugin, Plugin dependency, Set<String> checked) {
|
private boolean hasDependency(Plugin plugin, Plugin dependency, Set<String> checking) {
|
||||||
Set<String> childNames = Sets.union(
|
Set<String> childNames = Sets.union(
|
||||||
safeConversion(plugin.getDescription().getDepend()),
|
safeConversion(plugin.getDescription().getDepend()),
|
||||||
safeConversion(plugin.getDescription().getSoftDepend())
|
safeConversion(plugin.getDescription().getSoftDepend())
|
||||||
);
|
);
|
||||||
|
|
||||||
// Ensure that the same plugin isn't processed twice
|
// 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);
|
throw new IllegalStateException("Cycle detected in dependency graph: " + plugin);
|
||||||
}
|
}
|
||||||
// Look for the dependency in the immediate children
|
// Look for the dependency in the immediate children
|
||||||
@ -201,13 +210,16 @@ class PluginVerifier {
|
|||||||
|
|
||||||
// Recurse through their dependencies
|
// Recurse through their dependencies
|
||||||
for (String childName : childNames) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cross edges are permitted
|
||||||
|
checking.remove(plugin.getName());
|
||||||
|
|
||||||
// No dependency found!
|
// No dependency found!
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
import com.comphenix.protocol.Packets;
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.error.Report;
|
import com.comphenix.protocol.error.Report;
|
||||||
import com.comphenix.protocol.error.ReportType;
|
import com.comphenix.protocol.error.ReportType;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren