Skip to content

Instantly share code, notes, and snippets.

@ServOKio
Last active November 25, 2021 19:43
Show Gist options
  • Save ServOKio/6bda9c5921eb172f5f22401c2f21e3b7 to your computer and use it in GitHub Desktop.
Save ServOKio/6bda9c5921eb172f5f22401c2f21e3b7 to your computer and use it in GitHub Desktop.
Отслеживание донатов QIWI в майнкрафте c помощью HolographicDisplays
// +---------------+
// | QIWI DONATE |
// +---------------+
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
String phone = "твой номер мобилы QIWI";
String token = "Токен";
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://edge.qiwi.com/funding-sources/v2/persons/"+phone+"/accounts");
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.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Authorization", "Bearer "+token);
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("accounts").getAsJsonArray().get(0).getAsJsonObject().get("balance").getAsJsonObject().get("amount").getAsString();
hologram.insertTextLine(0, "&e&lДонат");
hologram.insertTextLine(0, "&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