Skip to content

Commit

Permalink
implemented a new configuration ability
Browse files Browse the repository at this point in the history
The payout message can now be set to only display once when the payout
limit was reached.
  • Loading branch information
mastercake10 committed Jun 15, 2020
1 parent f08d2dc commit b71749f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Plugin/src/main/java/de/Linus122/TimeIsMoney/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -82,6 +84,11 @@ public class Main extends JavaPlugin {
* The payouts listed in the config.
*/
private final List<Payout> payouts = new ArrayList<>();

/**
* Players that have already reached the payout limit for today
*/
private Set<UUID> payoutLimitReached = new HashSet<>();
/**
* The time online in seconds of each player by UUID.
*/
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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());
}

/**
Expand Down
3 changes: 3 additions & 0 deletions Plugin/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b71749f

Please sign in to comment.