Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.ktpvp.de.FFA.mysql;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import org.bukkit.entity.Player;
- import org.bukkit.event.Listener;
- import de.ktpvp.de.FFA.system.KilltimeMain;
- public class Stats implements Listener {
- public static boolean pExists(String uuid){
- boolean exists = false;
- try {
- ResultSet rs = KilltimeMain.mysql.query("SELECT * FROM Stats WHERE UUID '"+ uuid +"'");
- if(rs.getString("UUID") == uuid ){
- exists = true;
- return exists;
- }else{
- exists = false;
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return false;
- }
- public static void CreateP(String uuid){
- if(pExists(uuid) == false){
- KilltimeMain.mysql.update("INSERT INTO Stats(UUID, KILLS, DEATHS, COINS) VALUES('"+uuid+"','0', '0', '0');");
- }
- }
- public static Integer getkills(String uuid){
- int kill = 0;
- if(pExists(uuid) == true){
- try {
- ResultSet rs = KilltimeMain.mysql.query("SELECT * FROM Stats WHERE UUID '"+ uuid +"'");
- if(!rs.next() || (Integer.valueOf(rs.getInt("KILLS")) == null));
- kill = rs.getInt("KILLS");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }else{
- CreateP(uuid);
- getkills(uuid);
- }
- return kill;
- }
- public static Integer getCoins(String uuid){
- int coins = 0;
- if(pExists(uuid) == true ){
- try {
- ResultSet rs = KilltimeMain.mysql.query("SELECT * FROM Stats WHERE UUID '"+ uuid +"'");
- if(!rs.next() || (Integer.valueOf(rs.getInt("COINS")) == null));
- coins = rs.getInt("COINS");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }else{
- CreateP(uuid);
- getCoins(uuid);
- }
- return coins;
- }
- public static Integer gettode(String uuid, Player p){
- int tode = 0;
- if(pExists(p.getUniqueId().toString()) == true){
- try {
- ResultSet rs = KilltimeMain.mysql.query("SELECT * FROM Stats WHERE UUID '"+ uuid +"'");
- tode = rs.getInt("DEATHS");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }else{
- CreateP(uuid);
- getCoins(uuid);
- }
- return tode;
- }
- public static void setkills(String uuid, Integer kills){
- if(pExists(uuid) == true){
- KilltimeMain.mysql.update("UPDATE Stats SET KILLS= '"+ kills+"' WHERE UUID= '"+uuid+"';");
- }else{
- CreateP(uuid);
- setkills(uuid, kills);
- }
- }
- public static void setDEATHS(String uuid, Integer DEATHS){
- if(pExists(uuid) == true){
- KilltimeMain.mysql.update("UPDATE Stats SET DEATHS= '"+ DEATHS+"' WHERE UUID= '"+uuid+"';");
- }else{
- CreateP(uuid);
- setDEATHS(uuid, DEATHS);
- }
- }
- public static void setCoins(String uuid, Integer coins){
- if(pExists(uuid) == true){
- KilltimeMain.mysql.update("UPDATE Stats SET COINS= '"+ coins+"' WHERE UUID= '"+uuid+"';");
- }else{
- CreateP(uuid);
- setCoins(uuid, coins);
- }
- }
- public static void addDEATHSs(String uuid, Integer deaths, Player p){
- if(pExists(uuid)){
- setDEATHS(uuid, Integer.valueOf(gettode(uuid, p).intValue() + deaths.intValue()));
- }else{
- CreateP(uuid);
- addDEATHSs(uuid, deaths, p);
- }
- }
- public static void addkills(String uuid, Integer kills){
- if(pExists(uuid)){
- setkills(uuid, Integer.valueOf(getkills(uuid).intValue() + kills.intValue()));
- }else{
- CreateP(uuid);
- addkills(uuid, kills);
- }
- }
- public static void addcoins(String uuid, Integer coins){
- if(pExists(uuid)){
- setCoins(uuid, Integer.valueOf(getCoins(uuid).intValue() + coins.intValue()));
- }else{
- CreateP(uuid);
- addcoins(uuid, coins);
- }
- }
- }
Add Comment
Please, Sign In to add comment