-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
None
-
None
-
CentOS 7.5 3.10.0-862.3.2.el7.x86_64
OpenJDK 1.8.0_171
Spigot 1.13, Build #1690 via BuildTools with default configuration files.
No tests were executed on Spigot 1.12.2 or Minecraft as this is a Spigot 1.13-specific issue.
-
1.13-R0.1-SNAPSHOT
-
Yes
The TagRegistry appears not be initialized or loaded until some time between the plugin LOAD and ENABLE phases. Given the configuration nature of tags one could reasonably expect that such resources are available to plugins at any time once instantiated.
To better demonstrate this issue, I have published my test jig plugin tag_dbg that allows a user to configure an evaluation of tag values during specific plugin phases via JVM arguments. More details in the associated README.
While accessing tag values via Bukkit.getTag() will eventually return correct values, this bug has a side effect when using convenience instances defined by org.bukkit.Tag. In such cases, if any Tag<Material> instance is access during plugin loading, all instances will forever return an empty set when using getValues(), even though TagRegistry eventually is initialized.
The short and sweet solution is to ensure that TagRegistry is properly initialized before any plugins are loaded. While I attempted to find a means of fixing the problem, my knowledge of the overall Minecraft/Spigot initialization process is outdated. I believe someone with the appropriate domain expertise would be able to fix this quickly.
To avoid unnecessary build and referencing, I have attached the test jig. Its README is as follows:
Spigot 1.13 Build 1690 Tag Test
This simple test jig plugin retrieves Material values associated with the wool tag
via org.bukkit.Tag.WOOL and the more generic method Bukkit.getTag()
to demonstrate that said values are not loaded during the plugin load phase
(i.e. onLoad()), but are accessible during the plugin enable phase
(i.e. onEnable()).
It further demonstrates that if any part of the org.Bukkit.Tag interface
is loaded by a class loader during a plugin's load phase, the convenience
instances it defines (e.g. WOOL, PLANKS, etc.) will continue to have no
values, which is to be expected.
All in all, it appears that the Tag Registry is not fully initialized or
populated until some time between the plugin load and enable phases.
This plugin can be used to evaluate tag values during plugin load and enable
phases and via a simple command. The JVM arguments -Dtag-load and -Dtag-enable can be used to select the phase in which to evaluate tag values. For example,
to evaluate tags during load and enable, use.
java -Dtag-load -Dtag-enable -jar spigot-1.13-R0.1-SNAPSHOT.jar
To only evaluate during the plugin load phase, use:
java -Dtag-load -jar spigot-1.13-R0.1-SNAPSHOT.jar
Tag values can be evaluated from the command line via tagtest.