Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.wilko.economy;
- import me.wilko.settings.Settings;
- import org.bukkit.entity.Player;
- import org.mineacademy.fo.settings.YamlConfig;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.UUID;
- public class PlayerAccount extends YamlConfig {
- private final UUID uuid;
- private double balance = 0;
- private static final Map<UUID, PlayerAccount> accounts = new HashMap<>();
- public PlayerAccount(String name) {
- this(name, null);
- }
- public PlayerAccount(String name, java.util.UUID uuid) {
- this.uuid = uuid;
- this.loadConfiguration("accounts/" + uuid.toString() + ".yml");
- accounts.put(uuid, this);
- }
- public UUID getUUID() {
- return uuid;
- }
- public double getBalance() {
- return balance;
- }
- public void setBalance(double balance) {
- this.balance = balance;
- this.save();
- }
- @Override
- protected void onLoad() {
- this.balance = this.getInteger("bal", Settings.START_BAL);
- }
- @Override
- protected void onSave() {
- this.set("bal", this.balance);
- }
- public static PlayerAccount findAccount(Player player) {
- return PlayerAccount.findAccount(player.getName(), player.getUniqueId());
- }
- public static PlayerAccount findAccount(String name, UUID uuid) {
- PlayerAccount account = accounts.get(uuid);
- if (account == null)
- account = new PlayerAccount(name, uuid);
- return account;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement