SHARE
TWEET

Untitled

a guest Sep 20th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.whoyou.losowanie;
  2.  
  3. import org.bukkit.entity.Player;
  4.  
  5. public class Api {
  6.  
  7.     Main plugin;
  8.     public Api(Main instance) {
  9.         plugin = instance;
  10.     }
  11.  
  12.     public void addPlayerCoins(Player p, Integer coins) {
  13.         if (plugin.getConfig().getString(p.getUniqueId().toString()) == null) return;
  14.  
  15.         int coins_old = plugin.getConfig().getInt(p.getUniqueId().toString());
  16.  
  17.         plugin.getConfig().set(p.getUniqueId().toString(), coins_old + coins);
  18.  
  19.         plugin.saveConfig();
  20.         plugin.reloadConfig();
  21.     }
  22.  
  23.     public void removePlayerCoins(Player p, Integer coinsToRemove) {
  24.         if (plugin.getConfig().getString(p.getUniqueId().toString()) == null) return;
  25.  
  26.         int coins_old = plugin.getConfig().getInt(p.getUniqueId().toString());
  27.  
  28.         if(coins_old < coinsToRemove) {
  29.             plugin.getConfig().set(p.getUniqueId().toString(), 0);
  30.             return;
  31.         }
  32.  
  33.         plugin.getConfig().set(p.getUniqueId().toString(), coins_old - coinsToRemove);
  34.  
  35.         plugin.saveConfig();
  36.         plugin.reloadConfig();
  37.     }
  38.  
  39.     public Integer getPlayerCoins(Player p) {
  40.         if (plugin.getConfig().getString(p.getUniqueId().toString()) == null) return 0;
  41.         Integer coins = plugin.getConfig().getInt(p.getUniqueId().toString());
  42.         return coins;
  43.     }
  44.  
  45.     public void setPlayerCoins(Player p, Integer coins) {
  46.         if (plugin.getConfig().getString(p.getUniqueId().toString()) == null) return;
  47.  
  48.         plugin.getConfig().set(p.getUniqueId().toString(),coins);
  49.  
  50.         plugin.saveConfig();
  51.         plugin.reloadConfig();
  52.     }
  53. }
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