Can anyone help me ?

Discussion in 'Spigot Plugin Help' started by NewKaD, May 27, 2015.

Thread Status:
Not open for further replies.
  1. Hello :)

    I've just started coding plugins but the first (and the only) i've made doesn't works, i don't know where are the errors, can anyone tell me :) ? thanks!

    Here is the eclipse code,

    Code (Text):

    package me.spigot.newkad;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;

    public class myfirstplugin extends JavaPlugin {
        public void onEnable() {
            getLogger().info("onEnable Fonctionne bien!");
        public void onDisable() {
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (cmd.getName().equalsIgnoreCase("hello") && sender instanceof Player) {
                Player player = (Player) sender;
                player.sendMessage("Salut, " + player.getName() + "!");
                return true;
            return false;


    And here is the plugin.yml,

    Code (Text):

    name: PluginTestNewKaD
    main: me.spigot.newkad
    version: 1.0
          description: Cela repondra avec un message au joueur.
          usage: /hello
  2. It looks like you didn't write the right main in the plugin.yml, it should me your package and the class, eg. you class is called "Main", you will have to write in the plugin.yml, main: me.spigot.newkad.Main
  3. @AgentLV It says :(
    Code (Text):
     [13:53:09 ERROR]: Could not load 'plugins/NewKaD.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.spigot.newkad.Main'
    There is no errors in the plugin.yml :)
  4. From the looks of your code, you named your main class myfirstplugin, so you should use me.spigot.newkad.myfirstplugin in the plugin.yml instead of me.spigot.newkad.Main
    • Agree Agree x 1
  5. Thanks @iPyronic for your help, i don't have the old error anymore but now i've this :/
    Code (Text):

    [17:13:12 ERROR]: Could not load 'plugins/NewKaDPlug.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: me/spigot/newkad/myfirstplugin : Unsupported major.minor version 52.0
            at ~[craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin( ~[craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins( [craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugins( [craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.<init>( [craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at net.minecraft.server.v1_8_R1.PlayerList.<init>( [craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at net.minecraft.server.v1_8_R1.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at net.minecraft.server.v1_8_R1.DedicatedServer.init( [craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at [craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at [?:1.7.0_79]
    Caused by: java.lang.UnsupportedClassVersionError: me/spigot/newkad/myfirstplugin : Unsupported major.minor version 52.0
            at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.7.0_79]
            at java.lang.ClassLoader.defineClass( ~[?:1.7.0_79]
            at ~[?:1.7.0_79]
            at ~[?:1.7.0_79]
            at$100( ~[?:1.7.0_79]
            at$ ~[?:1.7.0_79]
            at$ ~[?:1.7.0_79]
            at Method) ~[?:1.7.0_79]
            at ~[?:1.7.0_79]
            at ~[craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at ~[craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at java.lang.ClassLoader.loadClass( ~[?:1.7.0_79]
            at java.lang.ClassLoader.loadClass( ~[?:1.7.0_79]
            at java.lang.Class.forName0(Native Method) ~[?:1.7.0_79]
            at java.lang.Class.forName( ~[?:1.7.0_79]
            at<init>( ~[craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at ~[craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            ... 9 more
  6. Your using the wrong java version.
  7. Inkzzz

    Resource Staff

    Your using Java 8, however your server doesn't support Java 8.
    • Agree Agree x 1
  8. @Inkzzzmc > Oh okay, and if I have a server who supports Java 8, it will works? (obviously)
  9. Inkzzz

    Resource Staff

    • Informative Informative x 1
  10. Just a suggestion if you don't want your code stolen after your problem has been fixed maybe edit your post and remove the parts showing your code :p
  11. Cldfire

    Cldfire Retired Moderator

    Paranoid much? :p
  12. Okay ;)

    Oh thanks for the suggestion :) but if anybody stole it, it isn't a problem ;)
    They can, there is nothing special :p
  13. I'd just like to point out a naming convention error. That way you can catch and correct them early before forming habits. You call your class myfirstplugin when instead you should call it MyFirstPlugin. I suggest you give this a read.
    • Informative Informative x 1
  14. @john01dav Thanks i'm gonna read it :) But is it really important if i don't do it ?

    And a little question ^^
    How do you have a redstone under your name :p ?

    EDIT: I just had to click on it, sorry!
  15. It is very important.
  16. Is it possible to change a class name?

    Edit: It's Okay
  17. Of course, what IDE do you use? Otherwise rename the file to and rename the 'class OldName {' to 'class NewName {'.

    You should also insert @Override where possible (e.g. OnEnable, onDisable, onCommand). This and the naming conventions are very important, although they don't affect your plugin technically.
    • Informative Informative x 1
  18. Thanks for your help :D
    But I just right-clicked the class > Refactor > Rename :)
    (And I'm using Eclipse)
  19. Yeah, that's better as it's easier, less time consuming and it updates all references automatically. That's why I asked for your IDE, thought you were just using notepad or so for a sec.
    • Like Like x 1
  20. Oh okay ;)
    And you, which IDE are you using :) ?
    (Notepad? Hahaha xD)
Thread Status:
Not open for further replies.