Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package server.util;
- import java.sql.*;
- import server.model.players.Client;
- public class SabsabiDonor extends Thread {
- public static Connection con = null;
- public static Statement stm;
- public static void createConnection() {
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- con = DriverManager.getConnection("jdbc:mysql://sabsabionline.com/sabsabi_wut", "sabsabi_wut", "passwordson");
- stm = con.createStatement();
- } catch (Exception e) {
- e.printStackTrace();
- con = null;
- stm = null;
- }
- }
- public SabsabiDonor(){
- }
- public void run() {
- while(true) {
- try {
- if(con == null)
- createConnection();
- else
- ping();
- Thread.sleep(10000);//10 seconds
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- public static void ping(){
- try {
- String query = "SELECT * FROM donation WHERE username = 'null'";
- query(query);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public static void addDonateItems(final Client c,final String name){
- new Thread(){
- @Override
- public void run()
- {
- try {
- String name2 = name.replaceAll(" ","_");
- String query = "SELECT * FROM donation WHERE username = '"+name2+"'";
- ResultSet rs = query(query);
- boolean b = false;
- while(rs.next()){
- b = true;
- if(Integer.parseInt(rs.getString("productid")) == 1){
- c.getItems().addItem(11694,1);
- } else if(Integer.parseInt(rs.getString("productid")) == 2){
- c.getItems().addItem(11700,1);
- } else if(Integer.parseInt(rs.getString("productid")) == 3){
- c.getItems().addItem(995,150000000);
- } else if(Integer.parseInt(rs.getString("productid")) == 4){
- c.getItems().addItem(1048,1);//white phat
- } else if(Integer.parseInt(rs.getString("productid")) == 5){
- c.getItems().addItem(1050,1);// santa hat
- } else if(Integer.parseInt(rs.getString("productid")) == 6){
- c.donorPoints += 500;// 500 donor points
- } else if(Integer.parseInt(rs.getString("productid")) == 7){
- c.donorPoints += 1000;// 1000 donor points
- } else if(Integer.parseInt(rs.getString("productid")) == 8){
- c.donorPoints += 1500;// 1500 donor points
- } else if(Integer.parseInt(rs.getString("productid")) == 9){
- c.donorPoints += 2000;// 2000 donor points
- } else if(Integer.parseInt(rs.getString("productid")) == 10){
- c.donorPoints += 2500;// 2500 donor points
- } else if(Integer.parseInt(rs.getString("productid")) == 11){
- c.yellPoints += 100;// 100 yell points
- } else if(Integer.parseInt(rs.getString("productid")) == 12){
- c.yellPoints += 200;// 200 yell points
- } else if(Integer.parseInt(rs.getString("productid")) == 13){
- c.yellPoints += 300;// 300 yell points
- }
- }
- if(b){
- query("DELETE FROM `donation` WHERE `username` = '"+name2+"';");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }.start();
- }
- public static ResultSet query(String s) throws SQLException {
- try {
- if (s.toLowerCase().startsWith("select")) {
- ResultSet rs = stm.executeQuery(s);
- return rs;
- } else {
- stm.executeUpdate(s);
- }
- return null;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement