/PluginDIExample

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

PluginDIExample

Cleaned up version of the orignal repo posted in comments of this Spigot DI plugin example taken from this article about DI with MC plugins by MrDienns on spigotmc.org

Note you should not use the Master branch as it won't work. I will look to maintain develop to ensure it works with the latest release of spigot but don't hold your breath. And if it does fail look for a branch that matches your server version.

Guava is already shaded into bukkit so as pointed out here by xTrollxDudex, so the exception we are getting :

06.08 13:08:38 [Server] INFO java.lang.NoSuchMethodError:
 com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V

appears to be a clash with version bukkit shades and the version our plugin shadows (gradle shading).

This post talks about versions of Guava in Spigot, and we will attempt to use this to work out which version of Guice we should fall back to.

We could consider actually relocating the latest version of Guava to match a version Guice we select but this causes extra work in creating shadow relocation tasks, increases the size of our plugins and still potentially raises compatibility issues that could cause much pain.

The repo we need to inspect is here however it appears that releases are not tagged and are maintained in short lived feature branches.

Versions prior to 1.8.1-R4 don't use but guava-collections (see the pom change in this commit 489d3e31386)

To work it out I used the following info: pom.xml 1.8.8 => guava 17.0 ( April 22, 2014.) => Guice 4.0 (28 Apr 2015) and updated the build file with 1.8-R0.1-SNAPSHOT looking here.