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;
    import org.bukkit.plugin.java.JavaPlugin;

    public class myfirstplugin extends JavaPlugin {
       
        @Override
        public void onEnable() {
            getLogger().info("onEnable Fonctionne bien!");
        }
       
        @Override
        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
    commands:
       hello:
          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'
    @JamesTheDev
    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 org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:328) ~[craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugins(CraftServer.java:288) [craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.<init>(CraftServer.java:250) [craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at net.minecraft.server.v1_8_R1.PlayerList.<init>(PlayerList.java:69) [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(DedicatedServer.java:133) [craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:473) [craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at java.lang.Thread.run(Thread.java:745) [?: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(ClassLoader.java:800) ~[?:1.7.0_79]
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.7.0_79]
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) ~[?:1.7.0_79]
            at java.net.URLClassLoader.access$100(URLClassLoader.java:71) ~[?:1.7.0_79]
            at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[?:1.7.0_79]
            at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[?:1.7.0_79]
            at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_79]
            at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[?:1.7.0_79]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:77) ~[craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:62) ~[craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at java.lang.ClassLoader.loadClass(ClassLoader.java:425) ~[?:1.7.0_79]
            at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ~[?:1.7.0_79]
            at java.lang.Class.forName0(Native Method) ~[?:1.7.0_79]
            at java.lang.Class.forName(Class.java:274) ~[?:1.7.0_79]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:40) ~[craftbukkit-1.8.jar:git-Bukkit-15e81cf]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[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

    Yes
     
    • 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
    Retired

    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 NewName.java 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.