1.12.2 Spigot Version Checker Error

Discussion in 'Spigot Plugin Development' started by Zoon20X, Jan 11, 2020.

Thread Status:
Not open for further replies.
  1. Alright so i've tried most if not all methods i know how to fix this, but for a bit now my plugin LevelPoints has been sending errors to people who use my plugin, now the error when a player loads their console is
    Code (Text):
    java.io.IOException: Server returned HTTP response code: 405 for URL: https://api.spigotmc.org/legacy/update.php?resource=63996
    now seeing this error and knowing there was a different way of making a version checker i tried the other method of using http://www.spigotmc.org/api/general.php

    and well it worked and didn't throw a error cause it could connect to the server but the value for the version is null

    both snippets of code is below for you to read


    First Method running through api.spigot.org
    Code (Java):
                String key = "key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=";
                try {
                    HttpURLConnection connection = (HttpURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=").openConnection();
                    connection.setDoOutput(true);
                    connection.setRequestMethod("POST");
                    connection.getOutputStream().write((key + 63996).getBytes("UTF-8"));
                    String version = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine();

                    getServer().getConsoleSender().sendMessage(version);
    Second Method Running through spigotmc.org/api/general.php

    Code (Text):
                String key = "key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=";
                try {
                    HttpURLConnection connection = (HttpURLConnection) new URL("http://www.spigotmc.org/api/general.php").openConnection();
                    connection.setDoOutput(true);
                    connection.setRequestMethod("POST");
                    connection.getOutputStream().write((key + 63996).getBytes("UTF-8"));
                    String version = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine();

                    getServer().getConsoleSender().sendMessage(version);

    any help would be appriciated
     
  2. question so what should i use to do update checks now?
     
  3. The code in the thread works for me, look at the last post of the thread not the first one.
     
  4. just tested it, thanks you're a real life saver
     
Thread Status:
Not open for further replies.