Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. public String key = "key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=";
  2.  
  3.     public void VersionChecker(int idOfPlugin, String nameOfPlugin, String versionofPlugin){
  4.         try {
  5.             HttpURLConnection connection = (HttpURLConnection) new URL("http://www.spigotmc.org/api/general.php").openConnection();
  6.             connection.setDoOutput(true);
  7.             connection.setRequestMethod("POST");
  8.             connection.getOutputStream().write((key + idOfPlugin).getBytes("UTF-8"));
  9.             String version = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine();
  10.             if (!version.equals(versionofPlugin)){
  11.                 System.out.println(ChatColor.GOLD + "New version of " + nameOfPlugin + " is available");
  12.             }else{
  13.                 System.out.println(ChatColor.GREEN + nameOfPlugin + " is up to date");
  14.             }
  15.         } catch (IOException e) {
  16.             System.out.println(ChatColor.RED + "Unable to chceck the newest version of " + nameOfPlugin);
  17.             e.printStackTrace();
  18.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement