Package org.melonbrew.fe.database

Examples of org.melonbrew.fe.database.Account


        try {
            ResultSet set = connection.createStatement().executeQuery("SELECT * from " + accountsName);

            while (set.next()) {
                Account account = new Account(plugin, set.getString(accountsColumnUser), set.getString(accountsColumnUUID), this);

                account.setMoney(set.getDouble(accountsColumnMoney));

                accounts.add(account);
            }
        } catch (SQLException e) {
            e.printStackTrace();
View Full Code Here


        saveConfig();
    }

    @SuppressWarnings("deprecation")
    public Account getShortenedAccount(String name) {
        Account account = getAPI().getAccount(name, null);

        if (account == null) {
            Player player = getServer().getPlayer(name);

            if (player != null) {
View Full Code Here

    public double getBalance(OfflinePlayer offlinePlayer) {
        return getAccountBalance(offlinePlayer.getName(), offlinePlayer.getUniqueId().toString());
    }

    private double getAccountBalance(String playerName, String uuid) {
        Account account = plugin.getAPI().getAccount(playerName, uuid);

        if (account == null) {
            return 0;
        }

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

    private EconomyResponse withdraw(String playerName, String uuid, double amount) {
        if (amount < 0) {
            return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
        }

        Account account = plugin.getAPI().getAccount(playerName, uuid);

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

        if (account.has(amount)) {
            account.withdraw(amount);

            return new EconomyResponse(amount, account.getMoney(), ResponseType.SUCCESS, "");
        } else {
            return new EconomyResponse(0, account.getMoney(), ResponseType.FAILURE, "Insufficient funds");
        }
    }
View Full Code Here

    private EconomyResponse deposit(String playerName, String uuid, double amount) {
        if (amount < 0) {
            return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot deposit negative funds");
        }

        Account account = plugin.getAPI().getAccount(playerName, uuid);

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

        account.deposit(amount);

        return new EconomyResponse(amount, account.getMoney(), ResponseType.SUCCESS, "");
    }
View Full Code Here

    public void onPlayerQuit(PlayerQuitEvent event) {
        Database database = plugin.getFeDatabase();

        Player player = event.getPlayer();

        Account account = database.getCachedAccount(player.getName(), player.getUniqueId().toString());

        if (account != null) {
            account.save(account.getMoney());

            database.removeCachedAccount(account);
        }
    }
View Full Code Here

TOP

Related Classes of org.melonbrew.fe.database.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.