Browse Source

ATM: limit amount of money that can be deposited / stored

mastercake10 7 months ago
parent
commit
eba20df5f0

+ 4 - 0
Plugin/src/main/java/de/Linus122/TimeIsMoney/ATM.java

@@ -186,6 +186,10 @@ public class ATM implements Listener, CommandExecutor {
 	}
 	
 	private static void interactDeposit(Player p, double amount) {
+		if (ATM.getBankBalance(p) >= Main.finalconfig.getDouble("atm_balance_limit", Double.MAX_VALUE)) {
+			p.sendMessage(CC(Main.finalconfig.getString("message_atm_limit_reached")));
+			return;
+		}
 		if (Main.economy.has(p, amount)) {
 			ATM.depositBank(p, amount);
 			Main.economy.withdrawPlayer(p, amount);

+ 4 - 0
Plugin/src/main/java/de/Linus122/TimeIsMoney/Main.java

@@ -402,6 +402,10 @@ public class Main extends JavaPlugin {
 		}
 
 		if (finalconfig.getBoolean("store-money-in-bank")) {
+			if(ATM.getBankBalance(player) >= finalconfig.getDouble("atm_balance_limit", Double.MAX_VALUE)) {
+				sendMessage(player, CC(finalconfig.getString("message_atm_limit_reached")));
+				return;
+			}
 			ATM.depositBank(player, payout_amt);
 		} else {
 			double before = 0;

+ 6 - 0
Plugin/src/main/resources/config.yml

@@ -18,6 +18,8 @@ display-messages-in-chat: true
 display-messages-in-actionbar: true
 display-messages-in-actionbar-time: 10
 give_money_every_second: 600
+
+# defines whether the money should be stored in the bank (access it using /atm or an [ATM] sign, see more below)
 store-money-in-bank: false
 
 # Define if multiple accounts should get paid with the same ip address.
@@ -74,6 +76,7 @@ message_atm_nopermbuild: "&cYou don't have permissions to build ATM's (tim.atm.p
 message_atm_created: "&2ATM created! (You can also write something in the Lines 2-4)"
 message_atm_withdrew: "&cTook &a%s &cfrom your account."
 message_atm_deposited: "&2Added &a%s &2to your account."
+message_atm_limit_reached: "&cATM limit reached! Please withdraw some money before you can receive money again."
 
 # Set this to true to send the payout limit reached message only one time once reached
 display-payout-limit-reached-message-once: false
@@ -97,6 +100,9 @@ atm_worth_gradation:
   - 1000.0
   - 10000.0
 
+# Sets a limit for the max amount of money allowed inside a player's ATM.
+#atm_balance_limit: 100000000.0;
+
 # You can seperate the ATM balances for different worlds by group them. Just set group-atms to true and write atm_groups as described below.
 # Note: Existing bank accounts will be removed when enabling this feature. 
 group-atms: false