Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.framedev.massive.coins;
- import de.framedev.mysql.api.api.SQL;
- import org.bukkit.OfflinePlayer;
- public class CoinsSystem {
- public CoinsSystem() {
- }
- OfflinePlayer target;
- public CoinsSystem addCoins(OfflinePlayer player,int amount) {
- if(SQL.isTableExists("PlayerInformation")) {
- if(SQL.exists("UUID",player.getUniqueId().toString(),"PlayerInformation")) {
- int money = (int) SQL.get("Coins", "UUID", player.getUniqueId().toString(), "PlayerInformation");
- money = money + amount;
- setCoins(player, money);
- } else {
- SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + amount + "'", "PlayerInformation");
- }
- } else {
- SQL.createTable("PlayerInformation","UUID TEXT(64), Coins INT");
- SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + amount + "'", "PlayerInformation");
- }
- return this;
- }
- public CoinsSystem removeCoins(OfflinePlayer player, int amount) {
- if(SQL.isTableExists("PlayerInformation")) {
- if(SQL.exists("UUID",player.getUniqueId().toString(),"PlayerInformation")) {
- int money = (int) SQL.get("Coins", "UUID", player.getUniqueId().toString(), "PlayerInformation");
- if(money < amount) {
- } else {
- money = money - amount;
- setCoins(player, money);
- }
- } else {
- SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + 0 + "'", "PlayerInformation");
- }
- } else {
- SQL.createTable("PlayerInformation","UUID TEXT(64), Coins INT");
- SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + 0 + "'", "PlayerInformation");
- }
- return this;
- }
- public CoinsSystem setCoins(OfflinePlayer player, int amount) {
- if(SQL.isTableExists("PlayerInformation")) {
- if(SQL.exists("UUID",player.getUniqueId().toString(),"PlayerInformation")) {
- SQL.UpdateData("Coins","'" + amount + "'","PlayerInformation","UUID = '" + player.getUniqueId().toString() + "'");
- } else {
- SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + amount + "'", "PlayerInformation");
- }
- } else {
- SQL.createTable("PlayerInformation","UUID TEXT(64), Coins INT");
- SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + amount + "'", "PlayerInformation");
- }
- return this;
- }
- public CoinsSystem setPlayer(OfflinePlayer target) {
- this.target = target;
- return this;
- }
- public static int getCoins(OfflinePlayer player) {
- if(SQL.isTableExists("PlayerInformation")) {
- if(SQL.exists("UUID",player.getUniqueId().toString(), "PlayerInformation")){
- int amount = (int) SQL.get("Coins","UUID",player.getUniqueId().toString(), "PlayerInformation");
- return amount;
- } else {
- SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + 0 + "'", "PlayerInformation");
- return 0;
- }
- } else {
- SQL.createTable("PlayerInformation","UUID TEXT(64), Coins INT");
- SQL.InsertData("UUID,Coins","'" + player.getUniqueId().toString() + "','" + 0 + "'", "PlayerInformation");
- return 0;
- }
- }
- public OfflinePlayer getTarget() {
- return target;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement