lucko / commodore

Utility for using Minecraft's 1.13 'brigadier' library in Bukkit plugins.
MIT License
176 stars 15 forks source link

More clean maven plugin. #17

Closed portlek closed 2 years ago

portlek commented 4 years ago

Also, I didn't see any reason to relocate to our package. Am I right?

conclube commented 3 years ago

Also, I didn't see any reason to relocate to our package. Am I right?

Well generally we relocate because of safety issues. Assume you're using version alpha of dependency x which you shade without any relocation. Now let's say the server runs another plugin which isn't yours that also shades the dependency with no relocation but uses version beta instead. Let's for instance also say that the changes between version alpha and beta are significant but they both contain the method somepackage.SomeClass#get although in version alpha the method returns Integer and in version beta the method instead returns int. In this case only one version of the dependency x and the class somepackage.SomeClass would be loaded into the classpath. Now if you depend on the Integer return of, for example you call Integer#hashCode from it, and the version beta gets loaded before your plugin has the chance to load in version alpha it could result in LinkageError. So to "prevent" this we relocate it such that the qualified name of a should-be-shaded dependency wont interfere with any other plugins that also depend on the same dependency. So for each plugin that depends on the dependency x they instead load in their own version they depend on with the relocated package name as it is a part of the qualified name of a class.