13
0
geforkt von Mirrors/Velocity

Cleaned up Java plugin loader

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-09-27 15:52:31 -04:00
Ursprung 8c98395d51
Commit e6c178aae7

Datei anzeigen

@ -43,21 +43,18 @@ public class JavaPluginLoader implements PluginLoader {
throw new InvalidPluginException("Did not find a valid velocity-info.json."); throw new InvalidPluginException("Did not find a valid velocity-info.json.");
} }
SerializedPluginDescription pd = serialized.get();
if (!PluginDescription.ID_PATTERN.matcher(pd.getId()).matches()) {
throw new InvalidPluginException("Plugin ID '" + pd.getId() + "' must match pattern " +
PluginDescription.ID_PATTERN.pattern());
}
PluginClassLoader loader = new PluginClassLoader( PluginClassLoader loader = new PluginClassLoader(
new URL[] {source.toUri().toURL() } new URL[] {source.toUri().toURL() }
); );
Class mainClass = loader.loadClass(serialized.get().getMain()); Class mainClass = loader.loadClass(pd.getMain());
VelocityPluginDescription description = createDescription(serialized.get(), source, mainClass); return createDescription(pd, source, mainClass);
String pluginId = description.getId();
Pattern pattern = PluginDescription.ID_PATTERN;
if (!pattern.matcher(pluginId).matches()) {
throw new InvalidPluginException("Plugin ID '" + pluginId + "' must match pattern " + pattern.pattern());
}
return description;
} }
@Override @Override