I’ve tried to revisit an early command-handling demo program to share as requested with a bugfixer working on one of the github errors…
I’ve struggled and struggled with java.lang.reflect.InvocationTargetException error messages Caused by: java.lang.NoSuchMethodError: org.spongepowered.api.util.command.spec.CommandSpec$Builder.setDescription(Lorg/spongepowered/api/text/Text;)Lorg/spongepowered/api/util/command/spec/CommandSpec$Builder;
Which after a bunch of failed attempts to create even new projects, and rewrite the code from scratch, gives me the same results.
Then I noticed what was happening with new projects: I would click-import the command-hander classes to remove the squiggles, all good. Then when I saved the files, the cleaner/formatting system would remove the imports for my command handling classes, yet the red squiggles are gone.
If I comment out the command handling parts, the plugin loads fine, i can even add other code and event handlers. Uncomment the command registration code, plugin craps out with the errors above, with no import to my classes used.
package com.prennet.boomod.demo;
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.spongepowered.api.Game;
import org.spongepowered.api.event.Subscribe;
import org.spongepowered.api.event.state.PostInitializationEvent;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.service.scheduler.SynchronousScheduler;
import org.spongepowered.api.text.Texts;
import org.spongepowered.api.util.command.args.GenericArguments;
import org.spongepowered.api.util.command.spec.CommandSpec;
@Plugin(id = "Demo", name = "Demo", version = "1.0.0")
public class Demo {
@Inject Logger logger;
public static Game game;
public SynchronousScheduler scheduler;
@Subscribe
public void preInit(PostInitializationEvent event) {
game = event.getGame();
scheduler = game.getSyncScheduler();
game.getCommandDispatcher().register(this, CommandSpec.builder()
.setDescription(Texts.of("Display a list of warps"))
.setExecutor(new CmdWarps())
.build()
, "warps");
game.getCommandDispatcher().register(this, CommandSpec.builder()
.setDescription(Texts.of("Warp to a destination name"))
.setExecutor(new CmdWarp(this))
.setArguments(GenericArguments.onlyOne(GenericArguments.string(Texts.of("warpname"))))
.build(), "warp");
}
}
I’ve tried to disable the "Removed unused imports " and “oganize imports” part of the clean-up /formatter, it still wipes out even when I manually add the import. I have closed and opened exclipse many times, no change, opened or closed projects when shutting down, no matter.
======
I am at a total loss of what to do, or even if I am barking up the right tree on this - I dont doubt that there may be some other missing thing that I am overlooking in my project setup or such that is really responsible, and this other stuff is not relevant. I’ve also spent ages trying to clear a “add } to complete class” or whatever such error, when no } was requried, which eventually cleared by exporting the jar file with errors, then the error cleared from the file.
Eclipse Juno, Sponge profile for cleanup/formatting routines (with or without toggles mentioned above). Forge forge-1.8-11.14.3.1446-universal Sponge sponge-1.8-1446-2.1DEV-482
Compiling with 1.7 compatibility, running server with 1.7 java