diff --git a/Plugin/src/main/java/de/Linus122/TimeIsMoney/Main.java b/Plugin/src/main/java/de/Linus122/TimeIsMoney/Main.java index b0bade7..52962f8 100644 --- a/Plugin/src/main/java/de/Linus122/TimeIsMoney/Main.java +++ b/Plugin/src/main/java/de/Linus122/TimeIsMoney/Main.java @@ -38,10 +38,12 @@ import java.util.Comparator; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; @@ -82,6 +84,11 @@ public class Main extends JavaPlugin { * The payouts listed in the config. */ private final List payouts = new ArrayList<>(); + + /** + * Players that have already reached the payout limit for today + */ + private Set payoutLimitReached = new HashSet<>(); /** * The time online in seconds of each player by UUID. */ @@ -335,12 +342,19 @@ private void pay(Player p) { if (payout.max_payout_per_day != -1) { if (payed >= payout.max_payout_per_day) { //Reached max payout + + if(finalconfig.getBoolean("display-payout-limit-reached-message-once") && payoutLimitReached.contains(p.getUniqueId())) { + return; + } + if (finalconfig.getBoolean("display-messages-in-chat")) { sendMessage(p, finalconfig.getString("message_payoutlimit_reached")); } if (finalconfig.getBoolean("display-messages-in-actionbar") && useActionbars) { sendActionbar(p, finalconfig.getString("message_payoutlimit_reached_actionbar")); } + if(finalconfig.getBoolean("display-payout-limit-reached-message-once")) + payoutLimitReached.add(p.getUniqueId()); return; } } @@ -444,6 +458,10 @@ private void pay(Player p) { } lastLocation.put(p.getUniqueId(), p.getLocation()); + + // clear payout limit reached message + if(finalconfig.getBoolean("display-payout-limit-reached-message-once")) + payoutLimitReached.remove(p.getUniqueId()); } /** diff --git a/Plugin/src/main/resources/config.yml b/Plugin/src/main/resources/config.yml index a535a90..92e36e0 100644 --- a/Plugin/src/main/resources/config.yml +++ b/Plugin/src/main/resources/config.yml @@ -65,6 +65,9 @@ message_atm_noperms: "&cYou don't have the permission to use ATM's!" message_atm_nomoneyinbank: "&cYou don't have enough money in bank!" message_atm_nomoney: "&cYou don't have enough money!" +# Set this to true to send the payout limit reached message only one time once reached +display-payout-limit-reached-message-once: false + # ATM -> Place down a sign with [atm] on the first line to use it! enable_atm: true atm_title: "&cATM"