daily pastebin goal
44%
SHARE
TWEET

im retarded leave me alone

a guest Jan 28th, 2016 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.rs.cores.mysql.impl;
  2.  
  3. import java.sql.ResultSet;
  4. import com.rs.cores.mysql.Database;
  5. import com.rs.game.player.Player;
  6. import com.rs.utils.SerializableFilesManager;
  7.  
  8. public class Donation implements Runnable {
  9.  
  10.     public static final String HOST_ADDRESS = "0.0.0.0";
  11.     public static final String USERNAME = "exylumwv_store";
  12.     public static final String PASSWORD = "REALLYLONGASSPASSTHATWORKSLEAVEITALONE";
  13.     public static final String DATABASE = "exylumwv_store";
  14.    
  15.     private Player player;
  16.    
  17.     @Override
  18.     public void run() {
  19.         try {
  20.             Database db = new Database(HOST_ADDRESS, USERNAME, PASSWORD, DATABASE);
  21.            
  22.             if (!db.init()) {
  23.                 System.err.println("[Donation] Failed to connect to database!");
  24.                 return;
  25.             }
  26.            
  27.             String name = player.getUsername().replace("_", " ");
  28.             ResultSet rs = db.executeQuery("SELECT * FROM payments WHERE player_name='"+name+"' AND claimed=0");
  29.            
  30.             while(rs.next()) {
  31.                 String item_name = rs.getString("item_name");
  32.                 int item_number = rs.getInt("item_number");
  33.                 double amount = rs.getDouble("amount");
  34.                 int quantity = rs.getInt("quantity");
  35.                
  36.                 ResultSet result = db.executeQuery("SELECT * FROM products WHERE item_id="+item_number+" LIMIT 1");
  37.                
  38.                 if (result == null || !result.next()
  39.                         || !result.getString("item_name").equalsIgnoreCase(item_name)
  40.                         || result.getDouble("item_price") != amount
  41.                         || quantity < 1 || quantity > Integer.MAX_VALUE) {
  42.                     System.out.println("[Donation] Invalid purchase for "+name+" (item: "+item_name+", id: "+item_number+")");
  43.                     continue;
  44.                 }
  45.                
  46.                 handleItems(item_number);
  47.                 rs.updateInt("claimed", 1);
  48.                 rs.updateRow();
  49.             }
  50.            
  51.             db.destroyAll();
  52.         } catch (Exception e) {
  53.             e.printStackTrace();
  54.         }
  55.     }
  56.  
  57.     public void handleItems(int productId) {
  58.         switch(productId) {
  59.         case 0:
  60.             player.getPackets().sendGameMessage("<shad=cc0ff><img=1>You Have Recieved Your donation! Thank you for your support!");
  61.             player.getInventory().addItem(995, 100);
  62.             // handle item stuff, like adding items, points, etc.
  63.             break;
  64.         case 12:
  65.             player.getPackets().sendGameMessage("<shad=cc0ff><img=1>You Have Recieved Your donation! Thank you for your support!");
  66.             player.getInventory().addItem(995, 1000000);
  67.             player.setDonator(true);
  68.             SerializableFilesManager.savePlayer(player);
  69.             // handle item stuff, like adding items, points, etc.
  70.             break;
  71.         }
  72.     }
  73.    
  74.     public Donation(Player player) {
  75.         this.player = player;
  76.     }
  77. }
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