This plugin requires your server to have my deVaultify plugin as well or it will not work.
As simple as it sounds, keeps track of players currency via deVaultify and allows commands to be used to check player balances, admin deposit into a players balance, pay other players. (the deVaultify plugin will store the player-balances in its plugin folder)
This is an example plugin created to show that deVaultify does work as is in its earliest stages. (deVaultify - not-a-vault API)
Update: 0.0.2: (deVaultify 0.0.9) no change to the commands but a change to showcase deVaultify's latest features such as multi-currency and tracking via Event to have auto conversions, such as 100 Bronze instantly converting to 1 silver and 100 silver to 1 gold.
0.0.3: Active, in post source not updated to reflect it yet.
Now features a sellhand to make the economy part possible for real.
Setting and Deleting sell prices requires a restart to take effect (for now) even though there are in game commands (for admins/etc) to do such.
With 0.0.3 active players will be able to make money from their resources and the economy can start to be really used.
Next update: Likely a "/playershop" to sell items (the players sell them not the server it will list player shops to open) and "/auction" to allow players to sell items via bids.
if (cmd.equals("bal") || cmd.equals("balance")) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command is for players only.");
return true;
}
Player player = (Player) sender;
if (!player.hasPermission("devault.balance")) {
player.sendMessage("§cYou do not have permission to view your balance.");
return true;
}
double gold = deVaultAPI.getBalance(player, "gold");
double silver = deVaultAPI.getBalance(player, "silver");
double bronze = deVaultAPI.getBalance(player, "bronze");
sender.sendMessage("§a--- Your Balances ---");
sender.sendMessage("§6Gold: §e" + gold);
sender.sendMessage("§6Silver: §e" + silver);
sender.sendMessage("§6Bronze: §e" + bronze);
sender.sendMessage("§a----------------------");
return true;
}
if (cmd.equals("pay")) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command is for players only.");
return true;
}
Player senderPlayer = (Player) sender;
if (!senderPlayer.hasPermission("devault.pay")) {
senderPlayer.sendMessage("§cYou do not have permission to use /pay.");
return true;
}
if (args.length != 3) {
senderPlayer.sendMessage("§cUsage: /pay <player> <amount> <currency>");
return true;
}
Player target = Bukkit.getPlayerExact(args[0]);
if (target == null || !target.isOnline()) {
senderPlayer.sendMessage("§cPlayer not found.");
return true;
}
if (target.equals(senderPlayer)) {
senderPlayer.sendMessage("§cYou can't pay yourself.");
return true;
}
double amount;
try {
amount = Double.parseDouble(args[1]);
if (amount <= 0) throw new NumberFormatException();
} catch (NumberFormatException e) {
senderPlayer.sendMessage("§cPlease enter a valid positive amount.");
return true;
}
String currency = args[2].toLowerCase();
if (!deVaultAPI.withdraw(senderPlayer, amount, currency)) {
senderPlayer.sendMessage("§cYou do not have enough " + currency + ".");
return true;
}
if (cmd.equals("deposit")) {
if (!sender.hasPermission("devault.deposit")) {
sender.sendMessage("§cYou do not have permission to use /deposit.");
return true;
}
plugin.getLogger().info("Converted " + silverToRemove + " silver into " + goldToGive + " gold for " + player.getName());
player.sendMessage("§aConverted §6" + silverToRemove + " §asilver into §6" + goldToGive + " §agold.");
} else {
plugin.getLogger().warning("Could not remove silver from " + player.getName() + " to convert to gold.");
player.sendMessage("§cCould not convert silver to gold. Insufficient silver.");
}
}
}
}
This is updated to showcase new features as deVaultify gets updated.
If you would like to test it out and want to quickly get deVaultify, you can click the link via the box on the right-hand side of this page to see more plugins created by me.
With future updates I will create a way to edit messages via the config.yml and other settings too, until it slowly has more desired features!