GlowstoneMC / Bukkit2Sponge

An implementation of SpongeAPI for Bukkit servers (Glowstone, Spigot)
https://www.glowstone.net/
Other
18 stars 3 forks source link

SimpleMail fails to load: java.lang.NoSuchMethodError: org.spongepowered.api.service.command.CommandService.register(Ljava/lang/Object;Lorg/spongepowered/api/util/command/CommandCallable;[Ljava/lang/String;)Lcom/google/common/base/Optional; #3

Closed deathcap closed 9 years ago

deathcap commented 9 years ago

Using the SimpleMail plugin (a simple sample plugin for educational use):

https://forums.spongepowered.org/t/example-plugin-for-educational-purposes/6493 https://github.com/boformer/SimpleMail

./gradlew jar
cp build/libs/SimpleMail-0.1.0.jar ../Glowstone++/plugins/Bukkit2Sponge/plugins/

fails with:

19:41:24 [WARNING] [Bukkit2Sponge] Event errorjava.lang.NoSuchMethodError: org.spongepowered.api.service.command.CommandService.register(Ljava/lang/Object;Lorg/spongepowered/api/util/command/CommandCallable;[Ljava/lang/String;)Lcom/google/common/base/Optional;

I do see this method in the CommandService interface:

    Optional<CommandMapping> register(Object plugin, CommandCallable callable, String... alias);

Maybe related to https://github.com/deathcap/Bukkit2Sponge/issues/1 java.lang.SecurityException: sealing violation: package javax.annotation is sealed

deathcap commented 9 years ago

After fixing GH-1 now fails with a different error, but also about a method signature including an Optional:

17:53:05 [WARNING] [Bukkit2Sponge] Event errorjava.lang.AbstractMethodError: io.github.deathcap.bukkit2sponge.plugin.ShinyPluginManager.fromInstance(Ljava/lang/Object;)Lcom/google/common/base/Optional;

deathcap commented 9 years ago

Caused by the Guava 17 relocation. To not conflict with Guava 10 in Glowstone, Bukkit2Sponge bundles its own Guava (version 17), relocated in the pom.xml:

              <relocations>
                <relocation>
                  <pattern>com.google.common</pattern>
                  <shadedPattern>io.github.deathcap.bukkit2sponge.libs.guava17.com.google.common</shadedPattern>
                </relocation>

ShinyPluginManager does implement the interface method:

   public Optional fromInstance(Object instance) {
      return Optional.fromNullable(this.instanceMap.get(instance));^M
   }

but the import is changed to:

import io.github.deathcap.bukkit2sponge.libs.guava17.com.google.common.base.Optional;

so the plugin can't find it, since it expects com.google.common.base.Optional. Tricky problem, how to solve this, hmm..

Drop Glowstone support? (until/if https://github.com/GlowstoneMC/Glowkit/pull/68 Update to Guava 17). Easiest "fix", albeit reduces compatibility. Will still be able to use Glowstone++ now that GH-1 is solved.

Somehow relocate the Guava package dynamically on plugin load? Rewrite com.google.common -> io.github.deathcap.bukkit2sponge.libs.guava17.com.google.common in the Sponge plugin classes, so it finds the correct signatures. Reminiscent of another proposal to add Guava version rewriting to the Bukkit plugin loader to support both versions.