SHARE
TWEET

Untitled

a guest Oct 16th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.                    
  33.                 } else {
  34.                     money = money - amount;
  35.                     setCoins(player, money);
  36.                 }
  37.             } else {
  38.                 SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + 0 + "'", "PlayerInformation");
  39.             }
  40.         } else {
  41.             SQL.createTable("PlayerInformation","UUID TEXT(64), Coins INT");
  42.             SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + 0 + "'", "PlayerInformation");
  43.         }
  44.         return this;
  45.     }
  46.  
  47.     public CoinsSystem setCoins(OfflinePlayer player, int amount) {
  48.         if(SQL.isTableExists("PlayerInformation")) {
  49.             if(SQL.exists("UUID",player.getUniqueId().toString(),"PlayerInformation")) {
  50.                 SQL.UpdateData("Coins","'" + amount + "'","PlayerInformation","UUID = '" + player.getUniqueId().toString() + "'");
  51.             } else {
  52.                 SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + amount + "'", "PlayerInformation");
  53.             }
  54.         } else {
  55.             SQL.createTable("PlayerInformation","UUID TEXT(64), Coins INT");
  56.             SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + amount + "'", "PlayerInformation");
  57.         }
  58.         return this;
  59.     }
  60.  
  61.     public CoinsSystem setPlayer(OfflinePlayer target) {
  62.         this.target = target;
  63.         return this;
  64.     }
  65.  
  66.     public static int getCoins(OfflinePlayer player) {
  67.         if(SQL.isTableExists("PlayerInformation")) {
  68.             if(SQL.exists("UUID",player.getUniqueId().toString(), "PlayerInformation")){
  69.                 int amount = (int) SQL.get("Coins","UUID",player.getUniqueId().toString(), "PlayerInformation");
  70.                 return amount;
  71.             } else {
  72.                 SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + 0 + "'", "PlayerInformation");
  73.                 return 0;
  74.             }
  75.         } else {
  76.             SQL.createTable("PlayerInformation","UUID TEXT(64), Coins INT");
  77.             SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + 0 + "'", "PlayerInformation");
  78.             return 0;
  79.         }
  80.     }
  81.  
  82.     public OfflinePlayer getTarget() {
  83.         return target;
  84.     }
  85. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top