Skip to content

Instantly share code, notes, and snippets.

@ServOKio
Created November 24, 2021 15:14
Show Gist options
  • Save ServOKio/1047f46ca59dc6888b9d93f1ef745c71 to your computer and use it in GitHub Desktop.
Save ServOKio/1047f46ca59dc6888b9d93f1ef745c71 to your computer and use it in GitHub Desktop.
Отслеживание донатов UnitPay
// +------------------+
// | UnitPay DONATE |
// +------------------+
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
String email = "твой email";
String key = "Ключ";
int xo4y = 700; //Цель
Hologram hologram = HologramsAPI.createHologram(main, new Location(Bukkit.getWorld("world"), 0 , 70, 70,0,0));
Bukkit.getScheduler().runTaskTimerAsynchronously(main, () -> {
try {
URL obj = new URL("https://unitpay.ru/api?method=getPartner&params[login]="+email+"params[secretKey]="+key);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; DonateCheckPlugin/0.0.1; + http://tvoy-sait.com)");
con.setRequestProperty("Accept", "application/json");
con.setDoOutput(true);
int responseCode = con.getResponseCode();
if(responseCode == 200){
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
JsonObject json = (JsonObject) (new JsonParser()).parse(response.toString());
String balance = json.get("balance").getAsString();
hologram.insertTextLine(0, "&e&lДонат");
hologram.insertTextLine(1, "&b&l"+balance+"₽ &7/ &3&l"+xo4y+"₽");
}
con.disconnect();
} catch (Exception e){
e.printStackTrace();
}
}, 0, 20*60*5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment