Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. package de.pascal.skypvp;
  2.  
  3. import org.bukkit.configuration.file.YamlConfiguration;
  4. import org.bukkit.entity.Player;
  5.  
  6. import java.io.File;
  7. import java.io.IOException;
  8.  
  9. public class Coins {
  10.  
  11. public static File file = new File("plugins/SkyPVP", "coins.yml");
  12. public static YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  13.  
  14. public static int getCoins(Player p) {
  15. return cfg.getInt(getUser(p));
  16. }
  17. public static String getUser(Player p) {
  18. return p.getName();
  19. }
  20.  
  21.  
  22. public static void setCoins(Player p, int anzahl) {
  23. cfg.set(getUser(p), anzahl);
  24. }
  25. public static void addCoins(Player p, int anzahl) {
  26. cfg.set(getUser(p), getCoins(p) + anzahl);
  27. }
  28. public static void removeCoins(Player p, int anzahl) {
  29. cfg.set(getUser(p), getCoins(p) - anzahl);
  30. }
  31.  
  32. public static void saveCoinAPI() {
  33. try {
  34. cfg.save(file);
  35.  
  36. if(!(file.exists())) {
  37. file.createNewFile();
  38. }
  39.  
  40. }catch (IOException e) {
  41. e.printStackTrace();
  42. }
  43. }
  44.  
  45.  
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement