Solved MalformedURLException

Discussion in 'Plugin Development' started by IAmANoot, Jun 15, 2019.

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

    IAmANoot

    Code:
        public static void checkUpdates() {
            console.sendMessage("§eChecking for updates...");
            try {
                String url = Settings.URL + "/pluginversion.html";
                HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection();
                String version = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine();
                if (!plugin.getDescription().getVersion().equalsIgnoreCase(version)) {
                    console.sendMessage("§aYou are using an outdated version of " + Settings.NAME + ". Please update to the latest version. §4<!> Disabling plugin <!>");
                    Bukkit.getScheduler().cancelTasks(plugin);
                    Bukkit.getPluginManager().disablePlugin(plugin);
                } else {
                    console.sendMessage("§aYou are using the latest version of " + Settings.NAME + ".");
                    startPlugin();
                }
               
            } catch (IOException e) {
                console.sendMessage("§cAn error occured while checking for updates with " + Settings.NAME + ". §4<!> Disabling plugin <!>");
                e.printStackTrace();
            }
        }
    Error
    java.net.MalformedURLException: no protocol: notatallonmyarket.epizy.com/pluginversion.html
     
  2. Offline

    Kars

    Add the HTTP protocol prefix AKA http://
     
  3. Offline

    bwfcwalshy Retired Staff

    @IAmANoot Add https:// to the start.


    @Kars 2019, https boi! (Also he literally uses HttpsURLConnection and IIRC it errors on non-secure protocol)
     
  4. Offline

    Kars

    Right, yes. This.
     
Thread Status:
Not open for further replies.

Share This Page