Class PluginYmlReader
plugin.yml straight from its class's code source, given only a
bare Class<?> - before any UltiToolsPlugin instance exists (D-12). This is the
third place in the codebase that would otherwise open a JAR to read plugin.yml;
extracting it once here is the point.
Every failure path - null code source, a directory code source with no plugin.yml
(the common case for test/dev classpaths), a missing JAR entry, an unreadable archive, or
malformed YAML - returns PluginYmlReader.PluginYmlInfo.EMPTY rather than throwing, logging at most one
WARNING. This class runs once per plugin class during dependency-graph construction, and a
single bad archive must not take the whole graph down (T-04-20).
- Since:
- 6.3.0
- Author:
- wisdomme
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe subset of a module'splugin.ymlthis framework needs: its declaredname:andmain:(both nullable - absent when the archive has none or reading failed), itsloadAfter:list, and its Bukkit-levelsoftdepend:/depend:lists (all three never null; empty when absent or reading failed), and its declaredversion:andapi-version:as text (both nullable, like name and main), which the load-failure refusal quotes to identify the module. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static PluginYmlReader.PluginYmlInfoparse(InputStream inputStream) Readsplugin.ymlfor the given class's own code source.private static PluginYmlReader.PluginYmlInforeadFromDirectory(File directory) private static PluginYmlReader.PluginYmlInforeadFromJar(URL jarLocation) readFromJarFile(File jarFile) Readsplugin.ymldirectly from a module's own jarFile, without loading any class from it first.private static File
-
Field Details
-
LOGGER
-
PLUGIN_YML_ENTRY
- See Also:
-
-
Constructor Details
-
PluginYmlReader
private PluginYmlReader()
-
-
Method Details
-
read
Readsplugin.ymlfor the given class's own code source.- Parameters:
pluginClass- the class whose containing JAR (or classes directory) should be read; may benull- Returns:
- the module's declared name and
loadAfterlist, orPluginYmlReader.PluginYmlInfo.EMPTYon any failure path - Since:
- 6.3.0
-
readFromJarFile
Readsplugin.ymldirectly from a module's own jarFile, without loading any class from it first.read(Class)above needs an already-loadedClass'sProtectionDomainto find the jar -- which is exactly what is not yet available when a module's main class is still being *discovered*.PluginManager's main-class discovery used to load every class entry in the jar, in entry order, until one happened to be assignable toUltiToolsPlugin-- which meant a class that exists only for an optional soft-dependency plugin (e.g. a PlaceholderAPI expansion) was linked, and failed to link, on every server where that optional plugin is absent, well before the real main class was ever reached. Reading themain:key directly out ofplugin.ymland loading only that one declared class removes the rest of the jar from the discovery path entirely -- the same shape Bukkit/Paper's ownPluginDescriptionFileuses to find a plugin's main class from itsmain:key, never by scanning the jar for a matching type.- Parameters:
jarFile- the module's own jar file; may benullor not a real file- Returns:
- the module's declared
name,mainandloadAfter, orPluginYmlReader.PluginYmlInfo.EMPTYon any failure path (missing file, noplugin.ymlentry, unreadable archive, malformed YAML) - Since:
- 6.3.0
-
toFile
-
readFromDirectory
-
readFromJar
-
parse
-