Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void incorrectLicense(String plugin) {
- this.loader.getLogger().warning("Could not load " + plugin + ", invalid license key or server not whitelisted");
- this.loader.getServer().shutdown();
- }
- private boolean checkLicense(String plugin) {
- ConfigCursor cursor = new ConfigCursor(this.loader.configManager.getLoaderConfig(), "licenses");
- String pluginLicense = cursor.getString(plugin);
- if (getJSON(pluginLicense)) {
- this.loader.getLogger().info("[+] License key checked !");
- } else {
- incorrectLicense(plugin);
- }
- return false;
- }
- private boolean getJSON(String key) {
- boolean access = false;
- try {
- URL url = new URL("https://eu.fenyx.red/api/licenses?key=" + key);
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.connect();
- InputStream inputStream = connection.getInputStream();
- InputStreamOperations ipo = new InputStreamOperations();
- String result = ipo.InputStreamToString(inputStream);
- JSONObject jsonObject = new JSONObject(result);
- access = jsonObject.getBoolean("access");
- } catch (Exception e) {
- e.printStackTrace();
- }
- return access;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement