Util Safe Donation Tracker

Discussion in 'Resources' started by elancha98, Sep 5, 2015.

Thread Status:
Not open for further replies.
    • Easy and ready to use donate button
    • Friendly interface to donate
    • Normal PayPal transaction
    1. Go to donation-tracker (http://www.donation-tracker.com/)
    2. Register yourself
    3. The tutorial will guide you (IMPORTANT: set your currency and your PayPal email)
    4. OPTIONAL: Change your profile image to your logo
    5. Go to dashboard
    6. Copy this link:
    7. On Twitch (or wherever you want to put the donation button) go to your channel page and hit edit panels:
    8. click on add:
    9. Fill the title, the image and the description (optional), and paste the copied link in the link tab.
    10. Hit submit and your donation button it's done:
    11. Now go back to donation-tracker (http://www.donation-tracker.com/dashboard)
    12. Copy the channel and API key fields:
    13. Paste them in the config file of the plugin (may be different depend on the plugin)
    Devs have to connect to this url: https://www.donation-tracker.com/api/?channel=XXXX&api_key=XXXX (replacing the first "XXXX" with the channel and the second ones with the api_key). Here's an example of the result accessing that url:
       "note":"This is a test to see if it is working",

    Basic Plugin Example

    Main class:

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.lang.reflect.Type;
    import java.net.URL;
    import java.util.ArrayList;
    import java.util.List;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scheduler.BukkitScheduler;
    import com.google.gson.Gson;
    import com.google.gson.reflect.TypeToken;
    public class Main extends JavaPlugin {
        // We load the config
        private String channel = this.getConfig().getString("channel");
        private String api_key = this.getConfig().getString("api_key");
        // initialize the needed arrays
        private ArrayList<Donation> donations = new ArrayList<Donation>();
        private ArrayList<Donation> temp = new ArrayList<Donation>();
        public void onEnable() {
            //We create a new repeating task to access web (we do every 5 seconds because faster our IP will be banned)
            BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
            scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
                public void run() {
                    try {
                        // gets the donations from the web
                        URL url = new URL(
                                "https://www.donation-tracker.com/api/?channel=" + channel + "&api_key=" + api_key);
                        BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
                        String strTemp = "";
                        String str = "";
                        // stores the donations in a string
                        while (null != (strTemp = br.readLine())) {
                            str += strTemp;
                        // initializes Gson (a JSON Parser for Java)
                        Gson gson = new Gson();
                        // stores the donations got from the page
                        Type type = new TypeToken<List<Donation>>() {}.getType();
                        //But first store the past response (to compare)
                        temp = donations;
                        donations = gson.fromJson(str, type);
                        // loops trough all elements
                        for (Donation d : donations) {
                            if (!temp.contains(d)) {
                                //and sends a message with new ones
                                Player p = Bukkit.getPlayer("your_player_name");
                                p.sendMessage(d.getUsername() + " has donated " + d.getAmount() + d.getCurrency_symbol());
                    } catch (Exception ex) {
            }, 0L, 100L);
    Donation class:
    public class Donation {
        public String username;
        public String note;
        public int timestamp;
        public String amount;
        public String currency;
        public String currency_symbol;
        public String transaction_id;
        public String paypal_email;
        public String getUsername() {
            return username;
        public void setUsername(String username) {
            this.username = username;
        public String getNote() {
            return note;
        public void setNote(String note) {
            this.note = note;
        public String getAmount() {
            return amount;
        public void setAmount(String amount) {
            this.amount = amount;
        public String getCurrency_symbol() {
            return currency_symbol;
        public void setCurrency_symbol(String currency_symbol) {
            this.currency_symbol = currency_symbol;
    Last edited: Sep 5, 2015
    jusjus112 likes this.
Thread Status:
Not open for further replies.

Share This Page