Implement possibility to send a player a message when they are given money by an admin.

This commit is contained in:
AppleDash 2018-10-05 04:09:37 -04:00
parent 867535bb4d
commit 71832bfffa
5 changed files with 35 additions and 3 deletions

View File

@ -91,6 +91,15 @@ public class EconomyAdminCommand extends SaneCommand {
sTargetPlayer,
ecoMan.getCurrency().formatAmount(newAmount)
);
if (this.saneEconomy.getConfig().getBoolean("economy.notify-admin-give") && targetPlayer.isOnline()) {
this.saneEconomy.getMessenger().sendMessage((Player) targetPlayer, "{1} has given you {2}. Your balance is now {3}.",
sender.getName(),
ecoMan.getCurrency().formatAmount(amount),
ecoMan.getCurrency().formatAmount(newAmount)
);
}
return;
}
@ -105,6 +114,15 @@ public class EconomyAdminCommand extends SaneCommand {
sTargetPlayer,
ecoMan.getCurrency().formatAmount(newAmount)
);
if (this.saneEconomy.getConfig().getBoolean("economy.notify-admin-take") && targetPlayer.isOnline()) {
this.saneEconomy.getMessenger().sendMessage((Player) targetPlayer, "{1} has taken {2} from you. Your balance is now {3}.",
sender.getName(),
ecoMan.getCurrency().formatAmount(amount),
ecoMan.getCurrency().formatAmount(newAmount)
);
}
return;
}
@ -126,6 +144,14 @@ public class EconomyAdminCommand extends SaneCommand {
));
});
if (this.saneEconomy.getConfig().getBoolean("economy.notify-admin-set") && targetPlayer.isOnline()) {
this.saneEconomy.getMessenger().sendMessage((Player) targetPlayer, "{1} has set your balance to {2}.",
sender.getName(),
ecoMan.getCurrency().formatAmount(amount)
);
}
return;
}

View File

@ -49,7 +49,6 @@ public class EconomyStorageBackendJSON extends EconomyStorageBackendCaching {
private synchronized void saveDatabase() {
try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file, false))) {
bufferedWriter.write(gson.toJson(balances));
bufferedWriter.close();
} catch (IOException e) {
throw new RuntimeException("Failed to save database", e);
}

View File

@ -18,6 +18,9 @@ economy:
notify-start-balance: true
server-account: '$SERVER$'
baltop-update-interval: 300
notify-admin-give: false
notify-admin-take: false
notify-admin-set: false
multi-server-sync: false
update-check: true

View File

@ -5,7 +5,7 @@
# To be clear: DO NOT change 'message'. Simply add a new, indented 'translation' line below it, with the changed message.
# Colors can also be used, by means of prefixing color codes with an '&' symbol.
# The order of placeholders can be changed. Anything after the :, like the '02d' in {1:02d} is a Java String.format specifier. If you don't know what that is, I recommend leaving it as-is.
# IMPORTANT: If your translation has a colon ( : ) character inside of it, you must enclose the entire part after "message: " in single quotes ( ' ).
# IMPORTANT: If your translation has a colon ( : ) character inside of it, you must enclose the entire part after "translation: " in single quotes ( ' ).
# If this file doesn't work for some reason, check your console for errors with "SnakeYAML" included in them.
messages:
- message: "You don't have permission to check the balance of {1}."
@ -20,6 +20,9 @@ messages:
- message: "Added {1} to {2}. Their balance is now {3}."
- message: "Took {1} from {2}. Their balance is now {3}."
- message: "Balance for {1} set to {2}."
- message: "{1} has given you {2}. Your balance is now {3}."
- message: "{1} has taken {2} from you. Your balance is now {3}."
- message: "{1} has set your balance to {2}."
- message: "You do not have enough money to transfer {1} to {2}."
- message: "You have transferred {1} to {2}."
- message: "You have received {1} from {2}."
@ -37,3 +40,4 @@ messages:
- message: "/<command> <page>"
- message: "/<command> <give/take/set> [player] <amount>"
- message: "/<command> reload-database"

View File

@ -32,7 +32,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<version>1.13.1-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>