SHARE
TWEET

HTTPRequest to FENYX API

a guest Mar 21st, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     private void incorrectLicense(String plugin) {
  3.         this.loader.getLogger().warning("Could not load " + plugin + ", invalid license key or server not whitelisted");
  4.         this.loader.getServer().shutdown();
  5.     }
  6.  
  7.     private boolean checkLicense(String plugin) {
  8.  
  9.         ConfigCursor cursor = new ConfigCursor(this.loader.configManager.getLoaderConfig(), "licenses");
  10.         String pluginLicense = cursor.getString(plugin);
  11.  
  12.         if (getJSON(pluginLicense)) {
  13.             this.loader.getLogger().info("[+] License key checked !");
  14.         } else {
  15.             incorrectLicense(plugin);
  16.         }
  17.  
  18.         return false;
  19.     }
  20.  
  21.     private boolean getJSON(String key) {
  22.         boolean access = false;
  23.         try {
  24.             URL url = new URL("https://eu.fenyx.red/api/licenses?key=" + key);
  25.             HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  26.             connection.connect();
  27.             InputStream inputStream = connection.getInputStream();
  28.             InputStreamOperations ipo = new InputStreamOperations();
  29.             String result = ipo.InputStreamToString(inputStream);
  30.  
  31.             JSONObject jsonObject = new JSONObject(result);
  32.             access = jsonObject.getBoolean("access");
  33.  
  34.         } catch (Exception e) {
  35.             e.printStackTrace();
  36.         }
  37.         return access;
  38.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top