Plugin getting corrupted after download from Dropbox to plugins folder!!

Discussion in 'Plugin Development' started by cwhit0814, Apr 14, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    cwhit0814

    I keep getting this error after downloading the plugin after updating from my Dropbox it uses a command to download the plugin into the plugin folder. I'm not completely sure whats wrong it worked before when I used 1.8.

    Code:
    [19:13:25 ERROR]: Could not load 'plugins\ObsidianCore.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
            at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:162) ~[spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at org.bukkit.craftbukkit.v1_9_R1.CraftServer.loadPlugins(CraftServer.java:296) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at org.bukkit.craftbukkit.v1_9_R1.CraftServer.reload(CraftServer.java:743) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at org.bukkit.Bukkit.reload(Bukkit.java:539) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at org.bukkit.craftbukkit.v1_9_R1.CraftServer.dispatchCommand(CraftServer.java:645) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at net.minecraft.server.v1_9_R1.PlayerConnection.handleCommand(PlayerConnection.java:1350) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at net.minecraft.server.v1_9_R1.PlayerConnection.a(PlayerConnection.java:1185) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at net.minecraft.server.v1_9_R1.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at net.minecraft.server.v1_9_R1.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at net.minecraft.server.v1_9_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_25]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_25]
            at net.minecraft.server.v1_9_R1.SystemUtils.a(SourceFile:45) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at net.minecraft.server.v1_9_R1.MinecraftServer.D(MinecraftServer.java:721) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at net.minecraft.server.v1_9_R1.DedicatedServer.D(DedicatedServer.java:400) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at net.minecraft.server.v1_9_R1.MinecraftServer.C(MinecraftServer.java:660) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at net.minecraft.server.v1_9_R1.MinecraftServer.run(MinecraftServer.java:559) [spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_25]
    Caused by: java.util.zip.ZipException: zip file is empty
            at java.util.zip.ZipFile.open(Native Method) ~[?:1.8.0_25]
            at java.util.zip.ZipFile.<init>(Unknown Source) ~[?:1.8.0_25]
            at java.util.zip.ZipFile.<init>(Unknown Source) ~[?:1.8.0_25]
            at java.util.jar.JarFile.<init>(Unknown Source) ~[?:1.8.0_25]
            at java.util.jar.JarFile.<init>(Unknown Source) ~[?:1.8.0_25]
            at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:150) ~[spigot-1.9.2.jar:git-Spigot-944aa20-420b983]
            ... 20 more
    
    Download Code:
    Code:
    public static void dlFile(String DLURL, String FileName) throws IOException {
    
            URL url = new URL(DLURL);
            InputStream is = null;
            OutputStream os = null;
            try {
                os = new FileOutputStream(new File(FileName));
                is = url.openStream();
            } catch (IOException exp) {
                exp.printStackTrace();
            } finally {
                try {
                    is.close();
                } catch (Exception exp) {
                }
                try {
                    os.close();
                } catch (Exception exp) {
                    exp.printStackTrace();
                }
            }
        }
    
    Command Code:
    Code:
    if (args[0].equalsIgnoreCase("update")) {
                    sender.sendMessage("§2§l** §aUpdating ObsidianCore...");
    
                    Bukkit.getScheduler().scheduleSyncDelayedTask(Core.getInstance(), new Runnable() {
    
                                public void run() {
                                    sender.sendMessage("§2§l* §aObsidianCore has successfully updated, please reload the plugin");
                                }
                            }, 60L);
                    try {
                        FileDownload.dlFile("https://dl.dropbox.com/s/c9849g3ksex0z1p/ObsidianCore.jar", "plugins/ObsidianCore.jar");
                    } catch (IOException e) {
                        sender.sendMessage("§4§l** §ObsidianCore was unable to be updated");
                        Bukkit.getScheduler().cancelTasks(Core.getInstance());
                    }
                }
    
     
  2. Offline

    CeramicTitan

    Lol. There is nothing wrong with the code. The error is from an invalid plugin.yml
     
  3. Offline

    Zombie_Striker

  4. Offline

    cwhit0814

    @Zombie_Striker @CeramicTitan It gets corrupted from dropbox because I have a plugin yml file in it thats not invalid when I test it before I use the file download.
     
  5. Offline

    teej107

    @cwhit0814 It's a problem with your plugin (or how you are exporting the jar?). If it's a problem with Dropbox (which I doubt it is) then it doesn't belong in this section of the forums.
     
  6. Offline

    567legodude

    @cwhit0814 Your method for updating is a bit different from mine. Does that download code actually work? All I see is you opening an input stream. Normally I would have thought that you would open the input stream, read/write the bytes, and use a callback to tell when it's done.
     
    Konato_K likes this.
  7. Offline

    I Al Istannen

    @567legodude @cwhit0814
    Not exactly to the problem, but I think one of the cleanest ways to deal with resources (implementing AutoClosable) is the try-with-resource statement introduced in Java 7. The current try finally try catch is just so much boilerplate code.
     
  8. Offline

    mythbusterma

    No.

    Think carefully about this error cause. This is the zip decoder saying that it found an empty file. Your code never actually downloads the file, it just opens some stuff.

    You need to actually do something with these if you want to download the file, it doesn't just magically do it. Also, you should be doing this asynchronously to the main thread, there's no reason to hang the server while this downloads.
     
  9. Offline

    mcdorli

    I'm not sure if you can legally download anything to the user's computer.
     
  10. Offline

    mythbusterma

    @mcdorli

    I'm not sure that there's anything illegal about it, per se.
     
  11. Offline

    mcdorli

    Quoted from the bukkitdev rules.
     
  12. Offline

    Jeyge

    That would just prevent the plugin from being approved on BukkitDev. But I think they would catch the permissions bypass for a single player before they would find the download location. Either way though, it looks like a private plugin since the welcome message is for a single server name.
     
  13. Offline

    567legodude

    @mcdorli That's for plugins on BukkitDev. You have to download BukkitDev plugins from specifically them. But your own personal plugins not on BD, you can do whatever you want.
     
  14. Offline

    cwhit0814

    @mythbusterma
    I get that but what I don't understand is why it worked on 1.8 and not 1.9
     
  15. Offline

    Zombie_Striker

    @cwhit0814
    This has nothing to do with thew server version. This has to do with how you are exporting the plugin.
     
  16. Offline

    mythbusterma

    @cwhit0814

    The only problem is that that code has never, will never, nor does work. It just flat out does nothing. So I'm not sure why anyone is confused about this.


    @Zombie_Striker

    It has to do with his code doing nothing lol.
     
    Zombie_Striker likes this.
  17. Offline

    mcdorli

    At least it stops the main thread for a few seconds.
     
  18. Offline

    I Al Istannen

    @cwhit0814
    There is a Files.copy method since Java 7 that takes an input stream. You might look into that. But I would highly recommend following the tips given above and learning some more Java / Debugging. I mean, if you would have spelled out loudly what the code does the flaw would be quite obvious.
     
Thread Status:
Not open for further replies.

Share This Page