|  | 
| 5 | 5 | import java.io.InputStreamReader; | 
| 6 | 6 | import java.net.HttpURLConnection; | 
| 7 | 7 | import java.net.URL; | 
|  | 8 | +import java.net.URLEncoder; | 
| 8 | 9 | import java.nio.charset.StandardCharsets; | 
| 9 | 10 | 
 | 
| 10 | 11 | import org.bukkit.plugin.java.JavaPlugin; | 
|  | 
| 20 | 21 | 
 | 
| 21 | 22 | public class Updater { | 
| 22 | 23 |     private JavaPlugin plugin; | 
| 23 |  | -    private static final String API_KEY = "98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4"; | 
| 24 |  | -    private static final String REQUEST_METHOD = "POST"; | 
|  | 24 | +    private static final String REQUEST_METHOD = "GET"; | 
| 25 | 25 |     private final String RESOURCE_ID; | 
| 26 |  | -    private static final String HOST = "https://www.spigotmc.org"; | 
| 27 |  | -    private static final String QUERY = "/api/general.php"; | 
| 28 |  | -    private String WRITE_STRING; | 
|  | 26 | +    private static final String HOST = "https://api.spigotmc.org"; | 
|  | 27 | +    private static final String PATH = "/legacy/update.php"; | 
| 29 | 28 | 
 | 
| 30 | 29 |     @Getter | 
| 31 | 30 |     private String version; | 
| @@ -56,23 +55,21 @@ public Updater(JavaPlugin plugin, Integer resourceId, boolean disabled) { | 
| 56 | 55 |         } | 
| 57 | 56 | 
 | 
| 58 | 57 |         try { | 
| 59 |  | -            connection = (HttpURLConnection) new URL(HOST + QUERY).openConnection(); | 
|  | 58 | +            final String query = String.format("?resource=%s", URLEncoder.encode(RESOURCE_ID, StandardCharsets.UTF_8.toString())); | 
|  | 59 | +            connection = (HttpURLConnection) new URL(HOST + PATH + query).openConnection(); | 
| 60 | 60 |         } catch (IOException e) { | 
| 61 | 61 |             result = UpdateResult.FAIL_SPIGOT; | 
| 62 | 62 |             plugin.getLogger().severe("Failed to open the connection to SpigotMC."); | 
| 63 | 63 |             e.printStackTrace(); | 
| 64 | 64 |             return; | 
| 65 | 65 |         } | 
| 66 |  | - | 
| 67 |  | -        WRITE_STRING = "key=" + API_KEY + "&resource=" + RESOURCE_ID; | 
| 68 | 66 |         run(); | 
| 69 | 67 |     } | 
| 70 | 68 | 
 | 
| 71 | 69 |     private void run() { | 
| 72 | 70 |         connection.setDoOutput(true); | 
| 73 | 71 |         try { | 
| 74 | 72 |             connection.setRequestMethod(REQUEST_METHOD); | 
| 75 |  | -            connection.getOutputStream().write(WRITE_STRING.getBytes(StandardCharsets.UTF_8)); | 
| 76 | 73 |         } catch (IOException e) { | 
| 77 | 74 |             plugin.getLogger().severe("Failed to open the connection to SpigotMC."); | 
| 78 | 75 |             e.printStackTrace(); | 
|  | 
0 commit comments