Solved Reading a file from a URL for an Auto-Update

Discussion in 'Plugin Development' started by Maxx_Qc, Jul 2, 2015.

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


    Hi guys, I have a problem with my auto-updater.

    Show Spoiler
    package com.maxx.nameshower;
    import java.util.logging.Logger;
    public class Updater {
        Main plugin;
        private String currentVersion;
        private String readurl = "";
        public Updater(Main plugin) {
            this.plugin = plugin;
            this.currentVersion = plugin.getDescription().getVersion();
        public void startUpdateCheck() {
            Logger log = plugin.getLogger();
            try {
      "Recherche d'une nouvelle version...");
      "Checking for a new version...");
                URL url = new URL(readurl);
                BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
                String str;
                while ((str = br.readLine()) != null) {
                    String line = str;
                    if (line.toString() != currentVersion) {
              "Une nouvelle version du plugin est disponible!");
              "Votre version: " + currentVersion);
              "Nouvelle version: " + line);
              " ");
              "A new version of the plugin is available!");
              "Your version: " + currentVersion);
              "New version: " + line);
                    } else {
              "Aucune mise à jour détectée!");
              "No updates detected!");
            } catch (IOException e) {
                log.severe("L'URL des mises à jour est invalide ! S'il vous plaît, faites-moi savoir!");
                log.severe("The UpdateChecker URL is invalid! Please let me know!");

    Picture of the problem: [​IMG]

    Thank you to everyone who can and will help me! :)
  2. Offline


    You can't compare strings with normal operators. Instead, you need to use the .equals() method.
  3. Offline


    Wow... Thank you so much <3
Thread Status:
Not open for further replies.

Share This Page