Guest User

Untitled

a guest
Sep 6th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. package de.ktpvp.de.FFA.mysql;
  2.  
  3. import java.sql.ResultSet;
  4. import java.sql.SQLException;
  5.  
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.event.Listener;
  8.  
  9. import de.ktpvp.de.FFA.system.KilltimeMain;
  10.  
  11. public class Stats implements Listener {
  12.  
  13. public static boolean pExists(String uuid){
  14.  
  15. boolean exists = false;
  16. try {
  17.  
  18. ResultSet rs = KilltimeMain.mysql.query("SELECT * FROM Stats WHERE UUID '"+ uuid +"'");
  19.  
  20.  
  21. if(rs.getString("UUID") == uuid ){
  22. exists = true;
  23. return exists;
  24. }else{
  25. exists = false;
  26. }
  27.  
  28. } catch (SQLException e) {
  29. e.printStackTrace();
  30. }
  31. return false;
  32.  
  33.  
  34.  
  35. }
  36. public static void CreateP(String uuid){
  37.  
  38. if(pExists(uuid) == false){
  39. KilltimeMain.mysql.update("INSERT INTO Stats(UUID, KILLS, DEATHS, COINS) VALUES('"+uuid+"','0', '0', '0');");
  40. }
  41.  
  42.  
  43.  
  44. }
  45.  
  46.  
  47.  
  48.  
  49. public static Integer getkills(String uuid){
  50.  
  51. int kill = 0;
  52.  
  53. if(pExists(uuid) == true){
  54. try {
  55. ResultSet rs = KilltimeMain.mysql.query("SELECT * FROM Stats WHERE UUID '"+ uuid +"'");
  56.  
  57. if(!rs.next() || (Integer.valueOf(rs.getInt("KILLS")) == null));
  58.  
  59. kill = rs.getInt("KILLS");
  60. } catch (SQLException e) {
  61. e.printStackTrace();
  62. }
  63. }else{
  64. CreateP(uuid);
  65. getkills(uuid);
  66. }
  67. return kill;
  68. }
  69.  
  70.  
  71. public static Integer getCoins(String uuid){
  72.  
  73. int coins = 0;
  74.  
  75. if(pExists(uuid) == true ){
  76. try {
  77. ResultSet rs = KilltimeMain.mysql.query("SELECT * FROM Stats WHERE UUID '"+ uuid +"'");
  78.  
  79. if(!rs.next() || (Integer.valueOf(rs.getInt("COINS")) == null));
  80.  
  81. coins = rs.getInt("COINS");
  82. } catch (SQLException e) {
  83. e.printStackTrace();
  84. }
  85. }else{
  86. CreateP(uuid);
  87. getCoins(uuid);
  88. }
  89. return coins;
  90. }
  91.  
  92. public static Integer gettode(String uuid, Player p){
  93.  
  94. int tode = 0;
  95.  
  96. if(pExists(p.getUniqueId().toString()) == true){
  97. try {
  98. ResultSet rs = KilltimeMain.mysql.query("SELECT * FROM Stats WHERE UUID '"+ uuid +"'");
  99.  
  100.  
  101. tode = rs.getInt("DEATHS");
  102.  
  103. } catch (SQLException e) {
  104. e.printStackTrace();
  105. }
  106. }else{
  107. CreateP(uuid);
  108. getCoins(uuid);
  109. }
  110. return tode;
  111. }
  112.  
  113. public static void setkills(String uuid, Integer kills){
  114. if(pExists(uuid) == true){
  115. KilltimeMain.mysql.update("UPDATE Stats SET KILLS= '"+ kills+"' WHERE UUID= '"+uuid+"';");
  116.  
  117. }else{
  118. CreateP(uuid);
  119. setkills(uuid, kills);
  120. }
  121. }
  122.  
  123.  
  124. public static void setDEATHS(String uuid, Integer DEATHS){
  125. if(pExists(uuid) == true){
  126. KilltimeMain.mysql.update("UPDATE Stats SET DEATHS= '"+ DEATHS+"' WHERE UUID= '"+uuid+"';");
  127.  
  128. }else{
  129. CreateP(uuid);
  130. setDEATHS(uuid, DEATHS);
  131. }
  132. }
  133. public static void setCoins(String uuid, Integer coins){
  134. if(pExists(uuid) == true){
  135. KilltimeMain.mysql.update("UPDATE Stats SET COINS= '"+ coins+"' WHERE UUID= '"+uuid+"';");
  136.  
  137. }else{
  138. CreateP(uuid);
  139. setCoins(uuid, coins);
  140. }
  141. }
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155. public static void addDEATHSs(String uuid, Integer deaths, Player p){
  156. if(pExists(uuid)){
  157. setDEATHS(uuid, Integer.valueOf(gettode(uuid, p).intValue() + deaths.intValue()));
  158.  
  159. }else{
  160. CreateP(uuid);
  161. addDEATHSs(uuid, deaths, p);
  162. }
  163. }
  164.  
  165. public static void addkills(String uuid, Integer kills){
  166. if(pExists(uuid)){
  167. setkills(uuid, Integer.valueOf(getkills(uuid).intValue() + kills.intValue()));
  168.  
  169. }else{
  170. CreateP(uuid);
  171. addkills(uuid, kills);
  172. }
  173. }
  174.  
  175. public static void addcoins(String uuid, Integer coins){
  176. if(pExists(uuid)){
  177. setCoins(uuid, Integer.valueOf(getCoins(uuid).intValue() + coins.intValue()));
  178.  
  179. }else{
  180. CreateP(uuid);
  181. addcoins(uuid, coins);
  182. }
  183.  
  184. }
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204. }
Add Comment
Please, Sign In to add comment