Good Afternoon,
I have been trying to create a sponge plugin, however every time i compile and put it on a server it gives me a class not found error. I have coded Bukkit plugins before successfully, so im not new at this. Thank you for any help.
tehpredv2
Do you have a class properly annotated with @Plugin?
Yes i have followed tutorials and tried copying from other plugins. Nothing works still.
You’ll have to post your code somewhere for anyone to be able to help you
Here is the code minus the imports
@Plugin(id = “DisableCraftV4”, name = “DisableCraftV4”, version = “1.0”)
public class DisableCraftV4{
static Game game = null;
static ConfigurationNode config = null;
static ConfigurationLoader<CommentedConfigurationNode> configurationManager;
@Inject
private Logger logger;
private void setLogger(Logger logger){
this.logger = logger;
}
public Logger getLogger(){
return logger;
}
@Inject
@DefaultConfig(sharedRoot = true)
private File dConfig;
@Inject
@DefaultConfig(sharedRoot = true)
private ConfigurationLoader<CommentedConfigurationNode> confManager;
@Subscribe
public void onPreInit(PreInitializationEvent event){
game = event.getGame();
setLogger(logger);
try {
if (!dConfig.exists()) {
dConfig.createNewFile();
config = confManager.load();
List<String> itemsList = Arrays.asList("iron_helmet", "iron_leggings", "iron_chestplate", "iron_boots");
config.getNode("config", "items").setValue(itemsList);
confManager.save(config);
}
configurationManager = confManager;
config = confManager.load();
} catch (IOException exception) {
getLogger().error("The default configuration could not be loaded or created!");
}
CommandSpec disableCommandSpec = CommandSpec.builder()
.setDescription(Texts.of("Help Command"))
.setPermission("disable.help")
.setExecutor(new HelpExecutor())
.build();
game.getCommandDispatcher().register(this, disableCommandSpec, "disable help", "test", "derp");
getLogger().info("DisableCraftV4 has been enabled!");
getLogger().info("Created by tehpredv2! The best dev ever on EP");
}
public static ConfigurationLoader<CommentedConfigurationNode> getConfigManager(){
return configurationManager;
}
}
Could you post the stack trace in a paste bin?
I’ve compiled your code on my machine based on what you had on github and it ran fine.
Also what IDE are you using Eclipse? or IntelliJ?
http://pastebin.com/7NYiieP2
This is all that it gives me from the start of the errors
It could be because you didn’t add the compile output to the jar but first what IDE are you using?
When exporting your Jar you selected the compile output right?
Its a maven project. I did the maven install like i did with Bukkit
Tell me how you exported you Jar and ill see if you did anything wrong.
Its a maven project, so i right click the project …go to run as … maven install … and that creates a jar that i use … its exactly what i did with bukkit
Ahh ok well you should start doing this.
Right click the project -> Click Export -> Click Java -> Then Click JAR File -> Click Next -> Then Select your .java files and anything else you want included and click finish
Ah ok i will try that right now. Thank you good sir for the help.
Well there are also some errors in your code. Especially with your CommandSpec, I don’t know if you already fixed these but its
CommandSpec disableCommandSpec = CommandSpec.builder()
.description(Texts.of("Help Command"))
.permission("disable.help")
.executor(new HelpExecutor)
.build();
Its still giving the class not found exception
open up your jar with a decompiler and see if your main class is there.
Its got everything in it.
What i think you didnt see was the ClassUnsupportedVersionError which is when the class was compiled with a JDK more recent than the one used for execution.
INFO Caused by: java.lang.UnsupportedClassVersionError: edu/rit/arc6373/DisableCraftV4/DisableCraftV4 : Unsupported major.minor version 52.0
1 Like