AutoUpdate - Update your plugins!

Discussion in 'Resources' started by V10lator, Jul 3, 2012.

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

    iKeirNez

    V10lator Could you possibly make a custom version for me that only checks for an update? The user would have to download it manually. This is because my plugin uses a Plugin Builder so that players can choose what features they would like.

    Thanks
    Keir
     
  2. Offline

    V10lator

  3. Offline

    iKeirNez

    Hmm we seem to be getting an ArrayListOutOfBoundsException: 2 on line 306 (rout = COLOR_INFO+out;) on server startup?
     
  4. Offline

    V10lator

    For me line 306 is something different, but anyway... change
    Code:java
    1. String[] rout = new String[3];
    2. for(int i = 0; i < 3; i++)

    to
    Code:java
    1. String[] rout = new String[2];
    2. for(int i = 0; i < 2; i++)
     
  5. Offline

    iKeirNez

    Thanks works now! :D
     
  6. Offline

    p000ison

    Nice :p Ill test this now a bit, but seems to work great. If everything is ok Ill add this to SimpleClans :p
     
  7. Offline

    V10lator

    And if not report it so I can fix it... :)
     
  8. Offline

    iKeirNez

    V10lator Thanks for this! It will be added to CommandsEX when the next version comes out, later today hopefully!

    Hmm, it seems you run your own copy of BukGet on your website because
    http://bukget.v10lator.de/commandsex
    http://bukget.org/api/plugin/commandsex/latest
    Are both different, your website says 1.70 is the latest and BukGet says 1.75 is the latest. I have changed them round so by default it will check BukGet and if BukGet is not available it will fallback onto your version of BukGet.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  9. Offline

    V10lator

    iKeirNez Yes, bukget.v10lator.de caches buget.org. Please don't exchange them as this has a reason:
     
    tyzoid and iKeirNez like this.
  10. Offline

    iKeirNez

    Oh I see, never knew that would be a problem. I'll switch them back then and figure something out
     
  11. Offline

    V10lator

    iKeirNez I don't think you have to figure anything out. After 6 hours the entry at v10lator.bukget.org gets deleted and refreshed from bukget.org (the exact system: If a request is made it checks the old database entry (timestamped) and deletes it if it's to old. Then it checks if a database entry exists and if so it uses it. If not it fetches it from bukget.org and saves it into the database. Also there's a cronjob running every day, deleting all old entries from the database (garbage collecting)).
    So your entry will update, it just needs time.
    ;)
     
  12. Offline

    iKeirNez

    I am editing the updater class to check if the current version is equal or higher to the version in BukGet. :)
     
  13. Offline

    V10lator

    So a real versions check? If you figure something good out (that's able to know that 0.3.2-alpa is lower than 0.3.2-beta, for example) please share it, so I'm able to integrate it. :)
     
  14. Offline

    iKeirNez

    Will do, think I almost have something

    V10lator I think I have it

    FIND "public boolean restartMainTask()" and add this before it
    Code:
      /***
      * This will determine which level the plugin type is
      * this will help decide whether Release is higher than Beta
      * @param string
      */
      public Integer getTypeLevel(String string){
          if (string.contains("Release")){
              return 1;
          } else if (string.contains("Beta")){
              return 2;
          } else if (string.contains("Alpha")){
              return 3;
          } else {
              return -1;
          }
      }
    FIND "nv = bukkitdevPrefix+jo.getString("name")+bukkitdevSuffix;" and add this after
    Code:
    String newVersion = null;
              int nvcounter = 0;
              while (nvcounter < nv.length()){
                  if (String.valueOf(nv.charAt(nvcounter)).matches(CommandsEX.intRegex) || String.valueOf(nv.charAt(nvcounter)).equals(".")){
                      newVersion = (newVersion != null ? newVersion : "") + nv.charAt(nvcounter);
                  }
                 
                  nvcounter++;
              }
              double nv1 = Double.parseDouble(newVersion);
             
              String currentVersion = null;
              String version = CommandsEX.pdfFile.getVersion();
              int cvcounter = 0;
              while (cvcounter < version.length()){
                  if (String.valueOf(version.charAt(cvcounter)).matches(CommandsEX.intRegex) || String.valueOf(version.charAt(cvcounter)).equals(".")){
                      currentVersion = (currentVersion != null ? currentVersion : "") + version.charAt(cvcounter);
                  }
                 
                  cvcounter++;
              }
             
              double cv = Double.parseDouble(currentVersion);
              int nvTypeLevel = getTypeLevel(nv);
              int cvTypeLevel = getTypeLevel(version);
              boolean newVersionHigher;
              if (cvTypeLevel == -1){
                  newVersionHigher = true;
              } else if (nvTypeLevel == cvTypeLevel){
                  if (nv1 == cv){
                      newVersionHigher = false;
                  } else if (nv1 > cv){
                      newVersionHigher = true;
                  } else {
                      newVersionHigher = false;
                  }
              } else if (nvTypeLevel < cvTypeLevel){
                  newVersionHigher = true;
              } else {
                  newVersionHigher = false;
              }
    FIND "if(av.equals(nv) || (updateVersion != null && updateVersion.equals(nv)))" replace it with
    Code:
    if(!newVersionHigher)
    I hope this helps, if there is a better way of doing it then please let me know.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
    V10lator likes this.
  15. Offline

    V10lator

    iKeirNez Well, this wouldn't realize that 0.5.2.1 is lower than 0.5.3 or that 0.5a is lower than 0.5b. There are many possibilities to check.
    A long time ago there was some discussion about that, but I can't find it. :(
     
  16. Offline

    iKeirNez

    "Well, this wouldn't realize that 0.5.2.1 is lower than 0.5.3 or that 0.5a is lower than 0.5b" I think it would
     
  17. Offline

    russjr08

    V10lator
    Thank you for this! I've implemented it in my plugin iFail, this is amazing! I was actually going to implement an update system that wouldn't auto update, but would just tell the user they needed to update the jar. Now I'm just waiting for my new jar file to be approved, although I think I did something wrong, when I was testing the new plugin it kept saying that the file needed to be updated even though the versions matched.. I probably forgot to change something, but I'll see if it works correctly after the caching finishes and the approval process.


    I just wanted to thank you, alot!
     
  18. Offline

    hawkfalcon

    Cool:p right now I just tell my players to use CbutD
     
  19. Offline

    iKeirNez

    V10lator I'll work on getting your Updater to work with things like 5.2c
     
  20. Offline

    iKeirNez

    V10lator Okay I updated it and I seem to have got it working :D

    Find "public boolean restartMainTask()" and before it add
    Code:
      /***
      * This will determine which level the plugin type is
      * this will help decide whether Release is higher than Beta
      * @param string
      */
      public Integer getTypeLevel(String string){
          if (string.contains("Release")){
              return 1;
          } else if (string.contains("Beta")){
              return 2;
          } else if (string.contains("Alpha")){
              return 3;
          } else {
              return -1;
          }
      }
    Find "nv = bukkitdevPrefix+jo.getString("name")+bukkitdevSuffix;" and after it add
    Code:
    String newVersion = null;
    int nvcounter = 0;
    while (nvcounter < nv.length()){
    if (String.valueOf(nv.charAt(nvcounter)).matches(CommandsEX.intRegex) || String.valueOf(nv.charAt(nvcounter)).equals(".")){
    newVersion = (newVersion != null ? newVersion : "") + nv.charAt(nvcounter);
    }
     
    nvcounter++;
    }
    double nv1 = Double.parseDouble(newVersion);
     
    String currentVersion = null;
    String version = CommandsEX.pdfFile.getVersion();
    int cvcounter = 0;
    while (cvcounter < version.length()){
    if (String.valueOf(version.charAt(cvcounter)).matches(CommandsEX.intRegex) || String.valueOf(version.charAt(cvcounter)).equals(".")){
    currentVersion = (currentVersion != null ? currentVersion : "") + version.charAt(cvcounter);
    }
     
    cvcounter++;
    }
     
    double cv = Double.parseDouble(currentVersion);
    int nvTypeLevel = getTypeLevel(nv);
    int cvTypeLevel = getTypeLevel(version);
    boolean newVersionHigher;
    if (cvTypeLevel == -1){
    newVersionHigher = true;
    } else if (nvTypeLevel == cvTypeLevel){
    if (nv1 == cv){
     
    char cvLetter;
    String cvMinorVersion = null;
    for (cvLetter='a'; cvLetter <= 'z'; cvLetter++){
    if (currentVersion.contains(String.valueOf(cv) + cvLetter)){
    cvMinorVersion = String.valueOf(cvLetter);
    }
    }
     
    char nvLetter;
    String nvMinorVersion = null;
    for (nvLetter='a'; nvLetter <= 'z'; nvLetter++){
    if (nv.contains(String.valueOf(nv1) + nvLetter)){
    nvMinorVersion = String.valueOf(nvLetter);
    }
    }
     
    if (nvMinorVersion == null){
    newVersionHigher = false;
    } else if (cvMinorVersion == null){
    newVersionHigher = true;
    } else {
    int cvValue = Character.getNumericValue(cvMinorVersion.charAt(0) - 9);
    int nvValue = Character.getNumericValue(nvMinorVersion.charAt(0) - 9);
     
    if (nvValue == cvValue){
    newVersionHigher = false;
    } else if (nvValue > cvValue){
    newVersionHigher = true;
    } else {
    newVersionHigher = false;
    }
    }
    } else if (nv1 > cv){
    newVersionHigher = true;
    } else {
    newVersionHigher = false;
    }
    } else if (nvTypeLevel < cvTypeLevel){
    newVersionHigher = true;
    } else {
    newVersionHigher = false;
    }
    
    Find "if(av.equals(nv) || (updateVersion != null && updateVersion.equals(nv)))" and replace it with
    Code:
    if(!newVersionHigher)
    Please let me know if there are any problems/bugs when using this. Also in plugin.yml the format for the version should be "Beta 1.75", if you are going to do a minor version then you do "Beta 1.75a" you can replace "a" from any letter of the alphabet all the way to "z".
     
  21. Offline

    V10lator

    I'll have a look at it soon (currently busy updating a plugin).
    But I don't want to force users of AutoUpdate to use a special format. It should just realize anything. So 0.5a7b is lower than 0.5b7z, 0.5alpha6 is lower than 0.5beta1, ...
     
  22. Offline

    iKeirNez

    Hmmm I'll try!
     
  23. Hey Im using v1.0: Build-in JSON. I add
    to my onenable, it runs fine but when I use /update Killstreaks it says that I need to restart the server, yet when I do it is still running the old version.
     
  24. Offline

    iKeirNez

    Try /reload even although I hate that command. Messes up a lot of stuff usually.
     
  25. Yeah I tried that too, and its still the same version

    Hey, I feel like such a idiot, I did not see the update folder it works perfectly and is now in my plugin Killstreaks , thanks for this amazing api :D

    Hey add http://dev.bukkit.org/server-mods/killstreaks/ to the list of plugins that use autoupdate.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  26. Offline

    p000ison

    13:52:33 [INFO] SimpleClans [AutoUpdate] ======= SNIP HERE =======
    13:52:33 [INFO] SimpleClans [AutoUpdate] java.io.IOException: Server returned HT TP response code: 503 for URL: http://bukget.org/api/plugin/simpleclans/latest
    13:52:33 [INFO] SimpleClans [AutoUpdate] at sun.net.www.protocol.http.Htt pURLConnection.getInputStream(HttpURLConnection.java:1436)
    13:52:33 [INFO] SimpleClans [AutoUpdate] at java.net.URL.openStream(URL.j ava:1010)
    13:52:33 [INFO] SimpleClans [AutoUpdate] at net.sacredlabyrinth.phaed.sim pleclans.AutoUpdate.run(AutoUpdate.java:263)
    13:52:33 [INFO] SimpleClans [AutoUpdate] at org.bukkit.craftbukkit.schedu ler.CraftWorker.run(CraftWorker.java:34)
    13:52:33 [INFO] SimpleClans [AutoUpdate] at java.lang.Thread.run(Thread.j ava:662)
    13:52:33 [INFO] SimpleClans [AutoUpdate] ======= DUMP =======
    13:52:33 [INFO] SimpleClans [AutoUpdate] version : 1.0
    13:52:33 [INFO] SimpleClans [AutoUpdate] delay : 216000
    13:52:33 [INFO] SimpleClans [AutoUpdate] ymlPrefix : v
    13:52:33 [INFO] SimpleClans [AutoUpdate] ymlSuffix :
    13:52:33 [INFO] SimpleClans [AutoUpdate] bukkitdevPrefix:
    13:52:33 [INFO] SimpleClans [AutoUpdate] bukkitdevSuffix:
    13:52:33 [INFO] SimpleClans [AutoUpdate] bukkitdevSlug : simpleclans
    13:52:33 [INFO] SimpleClans [AutoUpdate] COLOR_INFO : BLUE
    13:52:33 [INFO] SimpleClans [AutoUpdate] COLO_OK : GREEN
    13:52:33 [INFO] SimpleClans [AutoUpdate] COLOR_ERROR : RED
    13:52:33 [INFO] SimpleClans [AutoUpdate] bukget : http://bukget.v10lator .de/simpleclans
    13:52:33 [INFO] SimpleClans [AutoUpdate] bukgetFallback : http://bukget.org/api/ plugin/simpleclans/latest
    13:52:33 [INFO] SimpleClans [AutoUpdate] pid : 23
    13:52:33 [INFO] SimpleClans [AutoUpdate] av : v2.4
    13:52:33 [INFO] SimpleClans [AutoUpdate] config : YamlConfiguration[path ='', root='YamlConfiguration']
    13:52:33 [INFO] SimpleClans [AutoUpdate] lock : true
    13:52:33 [INFO] SimpleClans [AutoUpdate] needUpdate : false
    13:52:33 [INFO] SimpleClans [AutoUpdate] updatePending : false
    13:52:33 [INFO] SimpleClans [AutoUpdate] UpdateUrl : null
    13:52:33 [INFO] SimpleClans [AutoUpdate] updateVersion : null
    13:52:33 [INFO] SimpleClans [AutoUpdate] pluginURL : null
    13:52:33 [INFO] SimpleClans [AutoUpdate] type : null
    13:52:33 [INFO] SimpleClans [AutoUpdate] ======= SNIP HERE =======
    13:52:33 [INFO] SimpleClans [AutoUpdate]
    >
     
  27. Offline

    iKeirNez

    That's happening to me too, it's because bukget.org is down.
     
  28. Offline

    V10lator

    ^ This. But now it's back again and everything is working. In the next version it will either post a little warning like this:
    09:33:09 [INFORMATION] [PluginName] [AutoUpdate] WARNING: Bukget returned 503
    or silently ignore it. I'm tending to silently ignore it, but what do you guys think? :)
     
  29. Offline

    iKeirNez

    Have like a debug boolean which would turn that on or off, that would be useful for CommandsEX as it has a debug mode.
     
  30. Offline

    V10lator

    iKeirNez Something like
    public boolean debug = false;
    and as it's public your plugin could set it to true? :)

    //EDIT:
    or something like
    public void setDebug(boolean)
    ?
     
Thread Status:
Not open for further replies.

Share This Page