Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mysql.impl;
- import java.sql.*;
- import com.agaroth.world.content.MemberScrolls;
- import com.agaroth.world.entity.impl.player.Player;
- public class Donating 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://agaroth.com/justah_token", "justah_justah", "Kloorman1123");
- stm = con.createStatement();
- } catch (Exception e) {
- e.printStackTrace();
- con = null;
- stm = null;
- }
- }
- public Donating(){}
- public void run() {
- while(true) {
- try {
- if(con == null)
- createConnection();
- else
- ping();
- Thread.sleep(10000);
- } 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();
- con = null;
- stm = null;
- }
- }
- public static void addDonateItems(final Player c,final String name){
- if(con == null){
- if(stm != null){
- try {
- stm = con.createStatement();
- } catch(Exception e){
- con = null;
- stm = null;
- return;
- }
- } else {
- return;
- }
- }
- 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())
- {
- int prod = Integer.parseInt(rs.getString("productid"));
- int price = Integer.parseInt(rs.getString("price"));
- if ((prod == 1) && (price == 1))
- {
- c.getPointsHandler().DonatorPoints += 10;
- c.incrementAmountDonated(1);
- c.getPacketSender().sendMessage("Thank you for your contribution. Please relog for changes to take effect.");
- c.getPacketSender().sendMessage("@red@ 10 Donator Points has been added to your account. Donated total: " + c.getAmountDonated());
- b = true;
- }
- else if ((prod == 2) && (price == 3))
- {
- c.getPointsHandler().DonatorPoints += 30;
- c.incrementAmountDonated(3);
- c.getPacketSender().sendMessage("Thank you for your contribution. Please relog for changes to take effect.");
- c.getPacketSender().sendMessage("@red@ 30 Donator Points has been added to your account. Donated total: " + c.getAmountDonated());
- b = true;
- }
- else if ((prod == 3) && (price == 5))
- {
- c.getPointsHandler().DonatorPoints += 50;
- c.incrementAmountDonated(5);
- c.getPacketSender().sendMessage("Thank you for your contribution. Please relog for changes to take effect.");
- c.getPacketSender().sendMessage("@red@ 50 Donator Points has been added to your account. Donated total: " + c.getAmountDonated());
- b = true;
- }
- else if ((prod == 4) && (price == 7))
- {
- c.getPointsHandler().DonatorPoints += 70;
- c.incrementAmountDonated(7);
- c.getPacketSender().sendMessage("Thank you for your contribution. Please relog for changes to take effect.");
- c.getPacketSender().sendMessage("@red@ 70 Donator Points has been added to your account. Donated total: " + c.getAmountDonated());
- b = true;
- }
- else if ((prod == 5) && (price == 10))
- {
- c.getPointsHandler().DonatorPoints += 100;
- c.incrementAmountDonated(10);
- c.getPacketSender().sendMessage("Thank you for your contribution. Please relog for changes to take effect.");
- c.getPacketSender().sendMessage("@red@ 100 Donator Points has been added to your account. Donated total: " + c.getAmountDonated());
- b = true;
- }
- else if ((prod == 6) && (price == 15))
- {
- c.getPointsHandler().DonatorPoints += 150;
- c.incrementAmountDonated(15);
- c.getPacketSender().sendMessage("Thank you for your contribution. Please relog for changes to take effect.");
- c.getPacketSender().sendMessage("@red@ 150 Donator Points has been added to your account. Donated total: " + c.getAmountDonated());
- b = true;
- }
- else if ((prod == 7) && (price == 20))
- {
- c.getPointsHandler().DonatorPoints += 220;
- c.incrementAmountDonated(20);
- c.getPacketSender().sendMessage("Thank you for your contribution. Please relog for changes to take effect.");
- c.getPacketSender().sendMessage("@red@ 220 Donator Points has been added to your account. Donated total: " + c.getAmountDonated());
- b = true;
- }
- else if ((prod == 8) && (price == 25))
- {
- c.getPointsHandler().DonatorPoints += 275;
- c.incrementAmountDonated(25);
- c.getPacketSender().sendMessage("Thank you for your contribution. Please relog for changes to take effect.");
- c.getPacketSender().sendMessage("@red@ 275 Donator Points has been added to your account. Donated total: " + c.getAmountDonated());
- b = true;
- }
- else if ((prod == 9) && (price == 30))
- {
- c.getPointsHandler().DonatorPoints += 345;
- c.incrementAmountDonated(30);
- c.getPacketSender().sendMessage("Thank you for your contribution. Please relog for changes to take effect.");
- c.getPacketSender().sendMessage("@red@ 345 Donator Points has been added to your account. Donated total: " + c.getAmountDonated());
- b = true;
- }
- else if ((prod == 10) && (price == 40))
- {
- c.getPointsHandler().DonatorPoints += 460;
- c.incrementAmountDonated(40);
- c.getPacketSender().sendMessage("Thank you for your contribution. Please relog for changes to take effect.");
- c.getPacketSender().sendMessage("@red@ 460 Donator Points has been added to your account. Donated total: " + c.getAmountDonated());
- b = true;
- }
- else if ((prod == 11) && (price == 50))
- {
- c.getPointsHandler().DonatorPoints += 600;
- c.incrementAmountDonated(50);
- c.getPacketSender().sendMessage("Thank you for your contribution. Please relog for changes to take effect.");
- c.getPacketSender().sendMessage("@red@ 600 Donator Points has been added to your account. Donated total: " + c.getAmountDonated());
- b = true;
- }
- else if ((prod == 12) && (price == 75))
- {
- c.getPointsHandler().DonatorPoints += 935;
- c.incrementAmountDonated(75);
- c.getPacketSender().sendMessage("Thank you for your contribution. Please relog for changes to take effect.");
- c.getPacketSender().sendMessage("@red@ 935 Donator Points has been added to your account. Donated total: " + c.getAmountDonated());
- b = true;
- }
- else if ((prod == 13) && (price == 100))
- {
- c.getPointsHandler().DonatorPoints += 1300;
- c.incrementAmountDonated(100);
- c.getPacketSender().sendMessage("Thank you for your contribution. Please relog for changes to take effect.");
- c.getPacketSender().sendMessage("@red@ 1300 Donator Points has been added to your account. Donated total: " + c.getAmountDonated());
- b = true;
- }
- MemberScrolls.checkForRankUpdate(c);
- }
- if (b) {
- Donating.query("DELETE FROM `donation` WHERE `username` = '" + name2 + "';");
- }
- } catch (Exception e) {
- e.printStackTrace();
- con = null;
- stm = null;
- }
- }
- }.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();
- con = null;
- stm = null;
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement