Advertisement
Guest User

Untitled

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