Automatic update class for your plugin - very lightweight

Discussion in 'Resources' started by Luloak2, Jul 30, 2012.

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


    I want to show you my automatic update class which I use in my plugins.

    It is very simple, just download the <Edit by Moderator: Redacted mediafire url>

    Then you have to change two things:
    * The first line of code must be changed to your package (that package where you dropped the in). For example, if my package is called "me. Luloak2.FirstPlugin", then there must stand:
    package me.Luloak2.FirstPlugin;
    * After all "import" lines you see this line:
    public class Updater extends FirstPlugin
    You must change the "extends" to your main plugin class ( or wherever you are calling my Updater class from). For example, if I want to call it from "", the line looks so:
    public class Updater extends YourPlugin
    Now you have to load up your finished plugin somewhere where my Updater can directly acces it, and you must load up a version.txt which you can change, thats important because the link in your plugin stays the same, so a new version must be set in the same file. Only write the version in your version.txt, here is an examplehow it should look like.
    My Updater can only handle simple doubles like in the example.

    Then, from where you want to update it, call it with this simple lines of code:
    String version_location = "";
    String plugin_location = "";
    Updater Updater = new Updater();
    Updater.update(version_location, plugin_location);
    In "version_location" has to be the direct link to your version.txt, in "plugin_location" the direct link to your plugin.

    I hope this tiny class will help you a lot if you want to update your plugins automatically.
    Last edited by a moderator: Nov 10, 2016
  2. Offline


    This rly works?

    FileOutputStream fos1 = new FileOutputStream("plugins/" + plugin_name + ".jar");
    Can you rly update a plugin while its running?

    Whats about disable the old plugin -> delete the old file -> download the file -> reload the plugin or the server ?
  3. Offline


    Yes you can and that without any problems :)
    At the next restart of the server the new plugin is load, it works fine.
  4. Offline


    For any project to be approved on BukkitDev, auto updaters must point to for their downloads. This is to ensure the community is always presented with code that has been checked over and proven to be safe.

    Seeing as your example does not look like it works this way, I thought I'd mention that in a reply. Also, I locked your duplicate thread.
  5. Offline


    Nope this will cause problems...
  6. Offline



    Have you tried it!? I am using it in all of my plugin, and it is working;)
    So test it, you will see it works!
  7. Offline


    Seeing as you have already replied to this thread and it is relevant to the content, we as developers would be EXTREMELY happy if you can add a method of unloading a plugin from the server while it is running so we can do the updates without having to restart. Everything else (enable, disable, load) is present, just not that.
  8. Offline


    If a plugin (and this can happen) loads a class at runn-time so after the server started this will cause a ClasNotFoundException. If it works its ok :p but as far as I can say it that it can cause problems :p
  9. Offline


    Where would i make my version.txt file?
  10. (Source: )

    Think about it that way: If the server containing the txt file is offline for some reason your class would freeze the game till the network timeout happens (30 secons IIRC).
    It has a reason other auto updaters work asynchronous. ;)

    And I think it's not easy to figure out the newest download link from bukkitDev, at least nobody is able just drag&drop the class into the project and call the update function with pre-defined links (impossible to know the link of the new version while compiling the old).
Thread Status:
Not open for further replies.

Share This Page