Package com.gmail.mirelatrue.xpbank

Examples of com.gmail.mirelatrue.xpbank.Account


        return api.getMsg("currencyName");
    }

    @Override
    public boolean hasAccount (String playerName) {
        Account account = api.getAccount(playerName);

        if (account != null) {
            return true;
        }
View Full Code Here


        return false;
    }

    @Override
    public double getBalance (String playerName) {
        Account account = api.getAccount(playerName);

        return account.getBalance();
    }
View Full Code Here

        return account.getBalance();
    }

    @Override
    public boolean has (String playerName, double amount) {
        Account account = api.getAccount(playerName);

        if (account.getBalance() >= (int) amount) {
            return true;
        }

        return false;
    }
View Full Code Here

        return false;
    }

    @Override
    public EconomyResponse withdrawPlayer (String playerName, double amount) {
        Account account = api.getAccount(playerName);

        if (account == null) {
            return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("Player doesn't exist."));
        }

        int value = (int) amount;
        int balance = account.getBalance();

        if (value < 1) {
            return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
        }

        if (value > balance) {
            return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format(api.getMsg("InsufficientXP"), api.currencyName(value)));
        }

        account.modifyBalance(-value);

        return new EconomyResponse(value, balance - value, ResponseType.SUCCESS, null);
    }
View Full Code Here

        return new EconomyResponse(value, balance - value, ResponseType.SUCCESS, null);
    }

    @Override
    public EconomyResponse depositPlayer (String playerName, double amount) {
        Account account = api.getAccount(playerName);

        if (account == null) {
            // Stupid plugins that use fake players without creating them first...
            // return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player doesn't exist");
            this.createPlayerAccount(playerName);
        }

        int value = (int) amount;
        int balance = account.getBalance();

        if (value < 1) {
            return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
        }

        account.addTaxableIncome(value);

        return new EconomyResponse(value, balance + value, ResponseType.SUCCESS, null);
    }
View Full Code Here

        if (groupBank != null) {
            return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("GroupBankExists"), name));
        }

        Account account = api.getAccount(player);

        groupBank = api.createGroupBank(name, account);

        return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
    }
View Full Code Here

        if (groupBank == null) {
            return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
        }

        Account account = api.getAccount(name);

        if (account == null) {
            return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, api.getMsg("PlayerNotExist"));
        }

        if (groupBank.getOwner().equalsIgnoreCase(name)) {
            return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
        }

        return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("PlayerNotOwner"), account.getName(), groupBank.getName()));
    }
View Full Code Here

        if (groupBank == null) {
            return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
        }

        Account account = api.getAccount(name);

        if (account == null) {
            return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, api.getMsg("PlayerNotExist"));
        }

        if (groupBank.groupMembers.getMembers().containsKey(playerName)) {
            return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
        }

        return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("NotAMemberOf"), groupBank.getName(), account.getName()));
    }
View Full Code Here

TOP

Related Classes of com.gmail.mirelatrue.xpbank.Account

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.