satoshinm / WebSandboxMC

Bukkit plugin providing a web-based interface with an interactive WebGL 3D preview or glimpse of your server 🕷⏳📦 ⛺
https://www.spigotmc.org/resources/websandboxmc.39415/
MIT License
19 stars 5 forks source link

[Bukkit2Sponge] WebSandboxMC fails to load with duplicate class definition errors #77

Open satoshinm opened 7 years ago

satoshinm commented 7 years ago

When loading WebSandboxMC under Bukkit2Sponge https://github.com/GlowstoneMC/Bukkit2Sponge/ build 14 from https://bamboo.gserv.me/browse/GSPP-B2S/ with Glowstone 498, the plugin in plugins/Bukkit2Sponge/plugins to force it to load as Sponge and not as Bukkit, it fails with a bunch of "attempted duplicate class definition for name" errors, starting below:

gs1.11.2 $ ./go.sh 
++ /usr/libexec/java_home -version 1.8
+ /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java -Xms1G -Xmx1G -XX:+UseG1GC -XX:MaxGCPauseMillis=30 -jar glowstone.jar
16:47:15 [INFO] This server is running Glowstone version 2017.5.0.14-SNAPSHOT-MC1.11.2 (Implementing API version 1.11.2-R0.1-SNAPSHOT)
16:47:15 [INFO] Recipes: 299 shaped, 63 shapeless, 26 furnace, 10 dynamic, 28 fuels.
16:47:15 [WARNING] The server is running in offline mode! Only do this if you know what you're doing.
16:47:15 [INFO] Scanning plugins...
16:47:16 [INFO] PluginTypeDetector: found 1 Bukkit, 0 Sponge, 0 Forge, 0 Canary, 0 unknown plugins (total 1)
16:47:16 [INFO] Set PluginClassLoader as parallel capable
16:47:16 [INFO] Preparing spawn for world...
16:47:17 [INFO] Preparing spawn for world: done
16:47:17 [INFO] Preparing spawn for world_nether...
16:47:18 [INFO] Preparing spawn for world_nether: 70%
16:47:18 [INFO] Preparing spawn for world_nether: done
16:47:18 [INFO] Preparing spawn for world_the_end...
16:47:18 [INFO] Preparing spawn for world_the_end: done
16:47:18 [INFO] [Bukkit2Sponge] Enabling Bukkit2Sponge v0.1.0-SNAPSHOT
16:47:18 [INFO] [Bukkit2Sponge] Bukkit2Sponge v0.1.0-SNAPSHOT is loading...
16:47:18 [INFO] [Bukkit2Sponge] Glowstone integration enabled (0 plugins)
16:47:19 [INFO] [Bukkit2Sponge] SpongeAPI version: 6.0.0
16:47:19 [INFO] [Bukkit2Sponge] Loading SpongeAPI plugins...
16:47:19 [WARNING] [Bukkit2Sponge] Error loading gs1.11.2/plugins/Bukkit2Sponge/plugins/WebSandboxMC.jar/io.github.satoshinm.WebSandboxMC.Settings
java.lang.LinkageError: loader (instance of  net/glowstone/bukkit2sponge/plugin/ShinyClassLoader): attempted  duplicate class definition for name: "io/github/satoshinm/WebSandboxMC/Settings"
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at net.glowstone.bukkit2sponge.plugin.ShinyClassLoader.findClass(ShinyClassLoader.java:81)
        at net.glowstone.bukkit2sponge.plugin.PluginLoader.loadJar(PluginLoader.java:67)
        at net.glowstone.bukkit2sponge.plugin.PluginLoader.loadPlugins(PluginLoader.java:45)
        at net.glowstone.bukkit2sponge.plugin.ShinyPluginManager.loadPlugins(ShinyPluginManager.java:60)
        at net.glowstone.bukkit2sponge.Bukkit2Sponge.load(Bukkit2Sponge.java:105)
        at net.glowstone.bukkit2sponge.Bukkit2Sponge.onEnable(Bukkit2Sponge.java:46)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:271)
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:316)
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:415)
        at net.glowstone.GlowServer.enablePlugins(GlowServer.java:929)
        at net.glowstone.GlowServer.start(GlowServer.java:635)
        at net.glowstone.GlowServer.run(GlowServer.java:452)
        at net.glowstone.GlowServer.main(GlowServer.java:322)

This may be a B2S issue, as it isn't fully implemented. But would be nice to have minimal functionality to test WebSandboxMC's incomplete Sponge port (GH-51, GH-65) without having to load up SpongeVanilla or SpongeForge.

Full log: https://gist.github.com/satoshinm/744e0de81ee78459694b3cacb9d4a576

mastercoms commented 7 years ago

Bukkit2Sponge integrates with Glowstone and can use the Glowstone plugins directory instead of its Bukkit2Sponge/plugins folder. The plugins directory is loaded first, so any attempts to reload a plugin from the B2S folder will fail, as the plugin has already been loaded from the main folder. We may add support for an additional option in plugin.yml for plugin requested API priority, so that plugins may be loaded for Sponge instead of Bukkit if requested.

Example:

api-priority: sponge,bukkit

satoshinm commented 7 years ago

An api-priority key sounds good, but note I get the duplicate class definition errors even when placing the plugin only in the Bukkit2Sponge/plugins folder and not the main top-level plugins folder