Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. package de.framedev.massive.coins;
  2.  
  3. import de.framedev.mysql.api.api.SQL;
  4. import org.bukkit.OfflinePlayer;
  5.  
  6. public class CoinsSystem {
  7.  
  8. public CoinsSystem() {
  9. }
  10. OfflinePlayer target;
  11. public CoinsSystem addCoins(OfflinePlayer player,int amount) {
  12. if(SQL.isTableExists("PlayerInformation")) {
  13. if(SQL.exists("UUID",player.getUniqueId().toString(),"PlayerInformation")) {
  14. int money = (int) SQL.get("Coins", "UUID", player.getUniqueId().toString(), "PlayerInformation");
  15. money = money + amount;
  16. setCoins(player, money);
  17. } else {
  18. SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + amount + "'", "PlayerInformation");
  19. }
  20. } else {
  21. SQL.createTable("PlayerInformation","UUID TEXT(64), Coins INT");
  22. SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + amount + "'", "PlayerInformation");
  23. }
  24. return this;
  25. }
  26.  
  27. public CoinsSystem removeCoins(OfflinePlayer player, int amount) {
  28. if(SQL.isTableExists("PlayerInformation")) {
  29. if(SQL.exists("UUID",player.getUniqueId().toString(),"PlayerInformation")) {
  30. int money = (int) SQL.get("Coins", "UUID", player.getUniqueId().toString(), "PlayerInformation");
  31. if(money < amount) {
  32. if(amount >= 0) {
  33.  
  34. }
  35.  
  36. } else {
  37. money = money - amount;
  38. setCoins(player, money);
  39. }
  40. } else {
  41. SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + 0 + "'", "PlayerInformation");
  42. }
  43. } else {
  44. SQL.createTable("PlayerInformation","UUID TEXT(64), Coins INT");
  45. SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + 0 + "'", "PlayerInformation");
  46. }
  47. return this;
  48. }
  49.  
  50. public CoinsSystem setCoins(OfflinePlayer player, int amount) {
  51. if(SQL.isTableExists("PlayerInformation")) {
  52. if(SQL.exists("UUID",player.getUniqueId().toString(),"PlayerInformation")) {
  53. SQL.UpdateData("Coins","'" + amount + "'","PlayerInformation","UUID = '" + player.getUniqueId().toString() + "'");
  54. } else {
  55. SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + amount + "'", "PlayerInformation");
  56. }
  57. } else {
  58. SQL.createTable("PlayerInformation","UUID TEXT(64), Coins INT");
  59. SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + amount + "'", "PlayerInformation");
  60. }
  61. return this;
  62. }
  63.  
  64. public CoinsSystem setPlayer(OfflinePlayer target) {
  65. this.target = target;
  66. return this;
  67. }
  68.  
  69. public static int getCoins(OfflinePlayer player) {
  70. if(SQL.isTableExists("PlayerInformation")) {
  71. if(SQL.exists("UUID",player.getUniqueId().toString(), "PlayerInformation")){
  72. int amount = (int) SQL.get("Coins","UUID",player.getUniqueId().toString(), "PlayerInformation");
  73. return amount;
  74. } else {
  75. SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + 0 + "'", "PlayerInformation");
  76. return 0;
  77. }
  78. } else {
  79. SQL.createTable("PlayerInformation","UUID TEXT(64), Coins INT");
  80. SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + 0 + "'", "PlayerInformation");
  81. return 0;
  82. }
  83. }
  84.  
  85. public OfflinePlayer getTarget() {
  86. return target;
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement