Skip to content

Commit

Permalink
Add mechanism player.money
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 26, 2016
1 parent 1709ad3 commit 4049a77
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/java/net/aufdemrand/denizen/objects/dPlayer.java
Expand Up @@ -2814,6 +2814,25 @@ else if (split.length > 1) {
getOfflinePlayer().setBanned(mechanism.getValue().asBoolean());
}

// <--[mechanism]
// @object dPlayer
// @name money
// @input Element(Number)
// @description
// Set the amount of money a player has with the linked economy plugin.
// (Only if supported by the registered Economy system.)
// -->
if (mechanism.matches("money") && mechanism.requireDouble() && Depends.economy != null) {
double bal = Depends.economy.getBalance(getOfflinePlayer());
double goal = value.asDouble();
if (goal > bal) {
Depends.economy.depositPlayer(getOfflinePlayer(), goal - bal);
}
else if (bal > goal) {
Depends.economy.withdrawPlayer(getOfflinePlayer(), bal - goal);
}
}

// Iterate through this object's properties' mechanisms
for (Property property : PropertyParser.getProperties(this)) {
property.adjust(mechanism);
Expand Down

0 comments on commit 4049a77

Please sign in to comment.