Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String key = "key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=";
- public void VersionChecker(int idOfPlugin, String nameOfPlugin, String versionofPlugin){
- try {
- HttpURLConnection connection = (HttpURLConnection) new URL("http://www.spigotmc.org/api/general.php").openConnection();
- connection.setDoOutput(true);
- connection.setRequestMethod("POST");
- connection.getOutputStream().write((key + idOfPlugin).getBytes("UTF-8"));
- String version = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine();
- if (!version.equals(versionofPlugin)){
- System.out.println(ChatColor.GOLD + "New version of " + nameOfPlugin + " is available");
- }else{
- System.out.println(ChatColor.GREEN + nameOfPlugin + " is up to date");
- }
- } catch (IOException e) {
- System.out.println(ChatColor.RED + "Unable to chceck the newest version of " + nameOfPlugin);
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement