Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.88 KB | None | 0 0
  1. package de.ZockTV.AuraPVP.System;
  2.  
  3. import java.sql.ResultSet;
  4. import java.sql.SQLException;
  5. import java.sql.Statement;
  6.  
  7. import de.sentostv.venoriaapi.VenoriaDB;
  8.  
  9. public class Stats_System {
  10.     public static void createData(String name) {
  11.         if (VenoriaDB.Query.isRegistered(name, "Name", "users")) {
  12.             String uuid = VenoriaDB.Query.returnString("UUID", "users", "Name", name);
  13.            
  14.             if (!VenoriaDB.Query.isRegistered(name, "Name", "AuraPVP")) {
  15.                 VenoriaDB.update("INSERT INTO AuraPVP (Name, UUID, Kills, Deaths, Wins, Plays) VALUES ('" + name + "', '" + uuid + "', 0, 0, 0, 0)");
  16.             }
  17.         }
  18.     }
  19.    
  20.     public static int getKills(String name) {
  21.         if (VenoriaDB.Query.isRegistered(name, "Name", "users")) {
  22.             String uuid = VenoriaDB.Query.returnString("UUID", "users", "Name", name);
  23.            
  24.             if (VenoriaDB.Query.isRegistered(name, "Name", "AuraPVP")) {
  25.                 return VenoriaDB.Query.returnInt("Kills", "AuraPVP", uuid, "uuid");
  26.             }
  27.         }
  28.        
  29.         return -1;
  30.     }
  31.    
  32.     public static int getDeaths(String name) {
  33.         if (VenoriaDB.Query.isRegistered(name, "Name", "users")) {
  34.             String uuid = VenoriaDB.Query.returnString("UUID", "users", "Name", name);
  35.            
  36.             if (VenoriaDB.Query.isRegistered(name, "Name", "AuraPVP")) {
  37.                 return VenoriaDB.Query.returnInt("Deaths", "AuraPVP", uuid, "uuid");
  38.             }
  39.         }
  40.        
  41.         return -1;
  42.     }
  43.    
  44.     public static int getWins(String name) {
  45.         if (VenoriaDB.Query.isRegistered(name, "Name", "users")) {
  46.             String uuid = VenoriaDB.Query.returnString("UUID", "users", "Name", name);
  47.            
  48.             if (VenoriaDB.Query.isRegistered(name, "Name", "AuraPVP")) {
  49.                 return VenoriaDB.Query.returnInt("Wins", "AuraPVP", uuid, "uuid");
  50.             }
  51.         }
  52.        
  53.         return -1;
  54.     }
  55.    
  56.     public static int getPlays(String name) {
  57.         if (VenoriaDB.Query.isRegistered(name, "Name", "users")) {
  58.             String uuid = VenoriaDB.Query.returnString("UUID", "users", "Name", name);
  59.            
  60.             if (VenoriaDB.Query.isRegistered(name, "Name", "AuraPVP")) {
  61.                 return VenoriaDB.Query.returnInt("Plays", "AuraPVP", uuid, "uuid");
  62.             }
  63.         }
  64.        
  65.         return -1;
  66.     }
  67.    
  68.     public static void addKills(String name) {
  69.         if (VenoriaDB.Query.isRegistered(name, "Name", "users")) {
  70.             String uuid = VenoriaDB.Query.returnString("UUID", "users", "Name", name);
  71.            
  72.             if (VenoriaDB.Query.isRegistered(name, "Name", "AuraPVP")) {
  73.                 VenoriaDB.update("UPDATE AuraPVP SET Kills = " + (getKills(name) + 1) + " WHERE UUID = '" + uuid + "'");
  74.             }
  75.         }
  76.     }
  77.    
  78.     public static void addDeaths(String name) {
  79.         if (VenoriaDB.Query.isRegistered(name, "Name", "users")) {
  80.             String uuid = VenoriaDB.Query.returnString("UUID", "users", "Name", name);
  81.            
  82.             if (VenoriaDB.Query.isRegistered(name, "Name", "AuraPVP")) {
  83.                 VenoriaDB.update("UPDATE AuraPVP SET Deaths = " + (getDeaths(name) + 1) + " WHERE UUID = '" + uuid + "'");
  84.             }
  85.         }
  86.     }
  87.    
  88.     public static void addWins(String name) {
  89.         if (VenoriaDB.Query.isRegistered(name, "Name", "users")) {
  90.             String uuid = VenoriaDB.Query.returnString("UUID", "users", "Name", name);
  91.            
  92.             if (VenoriaDB.Query.isRegistered(name, "Name", "AuraPVP")) {
  93.                 VenoriaDB.update("UPDATE AuraPVP SET Wins = " + (getWins(name) + 1) + " WHERE UUID = '" + uuid + "'");
  94.             }
  95.         }
  96.     }
  97.    
  98.     public static void addPlays(String name) {
  99.         if (VenoriaDB.Query.isRegistered(name, "Name", "users")) {
  100.             String uuid = VenoriaDB.Query.returnString("UUID", "users", "Name", name);
  101.            
  102.             if (VenoriaDB.Query.isRegistered(name, "Name", "AuraPVP")) {
  103.                 VenoriaDB.update("UPDATE AuraPVP SET Plays = " + (getPlays(name) + 1) + " WHERE UUID = '" + uuid + "'");
  104.             }
  105.         }
  106.     }
  107.    
  108.     public static String getUUIDFromName(String name) {
  109.         try {
  110.             Statement statement = VenoriaDB.connection.createStatement();
  111.             ResultSet resultSet = statement.executeQuery("SELECT uuid FROM users WHERE name = '" + name + "'");
  112.             if (resultSet.next()) {
  113.                 return resultSet.getString(1);
  114.             }
  115.         } catch (SQLException e) {
  116.            
  117.         }
  118.        
  119.         return null;
  120.     }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement