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

    Maxx_Qc

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

    Class:
    Show Spoiler
    Code:
    package com.maxx.nameshower;
    
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.util.logging.Logger;
    
    public class Updater {
        Main plugin;
        private String currentVersion;
        private String readurl = "http://plugins.olympe.in/nameshower_version.txt";
       
        public Updater(Main plugin) {
            this.plugin = plugin;
            this.currentVersion = plugin.getDescription().getVersion();
        }
    
        public void startUpdateCheck() {
            Logger log = plugin.getLogger();
            try {
                log.info("Recherche d'une nouvelle version...");
                log.info("Checking for a new version...");
                log.info("--------------------------------------------");
                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) {
                        log.info("Une nouvelle version du plugin est disponible!");
                        log.info("Votre version: " + currentVersion);
                        log.info("Nouvelle version: " + line);
                        log.info(" ");
                        log.info("A new version of the plugin is available!");
                        log.info("Your version: " + currentVersion);
                        log.info("New version: " + line);
                        log.info("--------------------------------------------");
                    } else {
                        log.info("Aucune mise à jour détectée!");
                        log.info("No updates detected!");
                        log.info("--------------------------------------------");
                    }
                }
                br.close();
            } 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

    caseif

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

    Maxx_Qc

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

Share This Page