Search code examples
javabukkit

Bukkit and Vault: Is there a way to loop through every single player's balance?


I am creating a Bukkit plugin where when a command is run, all player's balances will be modified (offline ones, too). I know it would be easy to do this with the online players, and using:

economy.withdrawPlayer(<player>, <amount>);

by simply looping through the online players, but could I somehow loop through ALL players and modify their account balance?


Solution

  • You can use Bukkit.getOfflinePlayers() to get all Players that have joined a server. Example:

    for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
        economy.withdrawPlayer(player, <amount>);
    }