First plugin

Discussion in 'Spigot Plugin Development' started by rockdog66, Jul 12, 2015.

  1. Hey, I've recently just learnt java So I was going to make my own plugin. And I havn't finished it but I wanted to test it so I put it into my server etc and and /pl but my plugin didn't load and here is the error



    Could not load 'plugins\LuckyFish.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
    at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:162) ~[spigot.jar:git-Spigot-f928e7a-f27339c]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot.jar:git-Spigot-f928e7a-f27339c]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:291) [spigot.jar:git-Spigot-f928e7a-f27339c]
    at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [spigot.jar:git-Spigot-f928e7a-f27339c]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:528) [spigot.jar:git-Spigot-f928e7a-f27339c]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_31]
    Caused by: java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method) ~[?:1.8.0_31]
    at java.util.zip.ZipFile.<init>(Unknown Source) ~[?:1.8.0_31]
    at java.util.zip.ZipFile.<init>(Unknown Source) ~[?:1.8.0_31]
    at java.util.jar.JarFile.<init>(Unknown Source) ~[?:1.8.0_31]
    at java.util.jar.JarFile.<init>(Unknown Source) ~[?:1.8.0_31]
    at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:150) ~[spigot.jar:git-Spigot-f928e7a-f27339c]

    Please if you could help me that would be great :)
     
  2. And here is my plugin.yml file As I think it's that


    name: LuckyFish
    version: 1.0
    main: me.yolo.LuckyFish.LuckyFish
     
  3. Your plugin.yml is invalid. While the wiki states that the description is not required, I see you omitted it and are receiving an error regarding it. I would first try adding in a description and see if that fixes it.

    Scratch that. See below.
     
    #3 BillyGalbreath, Jul 12, 2015
    Last edited: Jul 12, 2015
  4. @BillyGalbreath is incorrect. It is caused because the jar file is not properly formatted. How did you create it?
     
    • Agree Agree x 2
  5. There's a problem with your plugin.yml, is your main class pointing to your class that extends JavaPlugin?
     
  6. Okay, when a plugin fails to load because the plugin.yml is wrong it's caused by a YAML Exception, this, if you read the stack trace, is not a YAML exception. The real question is how are you making the plugin?
     
  7. Ah yes, I overlooked that! It could be a bad upload to the server (partial upload, or corrupted copy, etc). Try re-uploading it to the server again. If that fails recompile the jar and try again.
     
  8. Yes after reading what they said ^, looks like there's a problem unzipping the JAR file accessing the plugin.yml(I worded that wrong I bet), anyways are you using an IDE for this, if so what IDE?
     
  9. I'm using eclipse and As I said I'm no where near finished but heres my code.


    package me.yolo.LuckyFish;

    import java.util.logging.Logger;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.YamlConfiguration;
    import org.bukkit.plugin.java.JavaPlugin;

    public class LuckyFish extends JavaPlugin
    {
    public final Logger log = Logger.getLogger("Minecraft");
    public int actionId;
    public int kits;
    public int kits1;
    public int kits2;
    public int kits3;
    public int kits4;
    public int kits5;
    public boolean enabled;
    public YamlConfiguration config;
    public void onEnable()
    {
    log.info("[LuckyFish] Has Been Enabled!");
    getConfig().options().copyDefaults(true);
    saveConfig();

    }

    public void onDisable()
    {
    log.info("[LuckyFish] Has Been Disabled");

    }





    public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args)
    {
    if (sender.hasPermission("lf.reload"))
    if (CommandLabel.equalsIgnoreCase("lfr")) {
    this.saveConfig();
    this.reloadConfig();
    this.saveConfig();
    sender.sendMessage("§b(LuckyFish) Reloaded");
    }
    return true;

    }
    }


    As for IDE I'm noob Idk what an ide is :p
     
  10. Eclipse is an IDE :p, make sure that your plugin.yml is in the source folder of your project.
     
  11. Oh. so it has to be in src? Because I was reading it has to be out side ;o
     
  12. Make sure it is in the src, so if you close the src tab in eclipse the plugin.yml disappears.
     
  13. Hmm, I've saved the plugin.yml into the users/name/workspace/LuckyFish/src but it doesn't show in eclipse src
     
  14. Would you like me to make a video on how I done it so you could see if I done anything wrong?
     
  15. Oh it did show in src I just had to refresh
    But still I got the same error when exporting it etc
     
  16. I have plugin tutorials on my YouTube channel

    http://betanyan.pw/youtube
     
  17. Okay. I'll check it out.
     
  18. Holy wow! Your video help it now works. Thanks for the help :)
     
  19. That's awesome! Glad I could help you out :)