4 Commits 0c946a7215 ... 2c1eeee8ed

Author SHA1 Message Date
  MasterCake 2c1eeee8ed update supported version 1 week ago
  MasterCake ba558de078 increment minor version 1 week ago
  MasterCake 09a6ab8bfa add deposit all / withdraw all button to the atm gui 1 week ago
  MasterCake 8405868d84 make plugin compile again 1 week ago
5 changed files with 67 additions and 13 deletions
  1. 2 2
      Plugin/pom.xml
  2. 57 8
      Plugin/src/main/java/de/Linus122/TimeIsMoney/ATM.java
  3. 1 1
      README.md
  4. 1 1
      Tools/pom.xml
  5. 6 1
      pom.xml

+ 2 - 2
Plugin/pom.xml

@@ -7,7 +7,7 @@
 	<parent>
 		<groupId>de.Linus122.TimeIsMoney</groupId>
 		<artifactId>parent</artifactId>
-		<version>1.9.12</version>
+		<version>1.9.13</version>
 		<relativePath>../pom.xml</relativePath>
 	</parent>
 
@@ -121,7 +121,7 @@
 		<dependency>
 			<groupId>de.Linus122.TimeIsMoney</groupId>
 			<artifactId>Tools</artifactId>
-			<version>1.9.12</version>
+			<version>1.9.13</version>
 		</dependency>
         <dependency>
             <groupId>org.jetbrains</groupId>

+ 57 - 8
Plugin/src/main/java/de/Linus122/TimeIsMoney/ATM.java

@@ -112,6 +112,9 @@ public class ATM implements Listener, CommandExecutor {
 			for(int i = 0; i < 4; i++) {
 				gui.getOrCreateItem(new SpaceItem().setStack(new StackBuilder(mats[i]).setDisplayname(CC("&cDeposit &a%s"))).setLabel("deposit-" + i), 5 + i + 9);
 			}
+			// Add Withdraw All and Deposit All buttons
+			gui.getOrCreateItem(new SpaceItem().setStack(new StackBuilder(Material.EMERALD).setDisplayname(CC("&cWithdraw All"))).setLabel("withdraw-all"), 2 + 18);
+			gui.getOrCreateItem(new SpaceItem().setStack(new StackBuilder(Material.CHEST).setDisplayname(CC("&cDeposit All"))).setLabel("deposit-all"), 6 + 18);
 		}
 		
 		// balance item
@@ -146,8 +149,26 @@ public class ATM implements Listener, CommandExecutor {
 			})
 			.setFormat((p) -> Main.economy.format(worths[index]));	
 		}
-	
-		
+
+		// Withdraw All button
+		SpaceItem withdrawAllItem = gui.getItemWithLabel("withdraw-all");
+		if(withdrawAllItem != null) {
+			withdrawAllItem.addAction((p, action) -> {
+				ATM.interactWithdrawAll(p);
+				action.getView().update(balanceItem);
+			});
+		}
+
+		// Deposit All button
+		SpaceItem depositAllItem = gui.getItemWithLabel("deposit-all");
+		if(depositAllItem != null) {
+			depositAllItem.addAction((p, action) -> {
+				ATM.interactDepositAll(p);
+				action.getView().update(balanceItem);
+			});
+		}
+
+
 		if(!fileConfig.contains("atm")) {
 			try {
 				fileConfig.set("atm", gui);
@@ -199,8 +220,36 @@ public class ATM implements Listener, CommandExecutor {
 			p.sendMessage(CC(Main.finalconfig.getString("message_atm_nomoney")));
 		}
 	}
-	
-	
+
+	private static void interactWithdrawAll(Player p) {
+		double bankBalance = ATM.getBankBalance(p);
+		if (bankBalance <= 0) {
+			p.sendMessage(CC(Main.finalconfig.getString("message_atm_nomoneyinbank")));
+			return;
+		}
+		EconomyResponse response = Main.economy.depositPlayer(p, bankBalance);
+		if (response.type == ResponseType.SUCCESS) {
+			ATM.withdrawBank(p, bankBalance);
+			p.sendMessage(String.format(CC(Main.finalconfig.getString("message_atm_withdrew")), Main.economy.format(bankBalance)));
+		}
+	}
+
+	private static void interactDepositAll(Player p) {
+		double playerBalance = Main.economy.getBalance(p);
+		if (playerBalance <= 0) {
+			p.sendMessage(CC(Main.finalconfig.getString("message_atm_nomoney")));
+			return;
+		}
+		if (ATM.getBankBalance(p) >= Main.finalconfig.getDouble("atm_balance_limit", Double.MAX_VALUE)) {
+			p.sendMessage(CC(Main.finalconfig.getString("message_atm_limit_reached")));
+			return;
+		}
+		ATM.depositBank(p, playerBalance);
+		Main.economy.withdrawPlayer(p, playerBalance);
+		p.sendMessage(String.format(CC(Main.finalconfig.getString("message_atm_deposited")), Main.economy.format(playerBalance)));
+	}
+
+
 	/**
 	 * Withdraws the specified amount of money from the specified player's bank.
 	 *
@@ -445,13 +494,13 @@ public class ATM implements Listener, CommandExecutor {
 							topBal.put(formattedDisplayString, amount);
 						}
 						topBal.entrySet().stream().
-						    sorted(Entry.comparingByValue(Comparator.reverseOrder())).limit(10).forEachOrdered(entry -> cs.sendMessage("§a" + entry.getKey() + "§2: " + Main.economy.format(entry.getValue())));
+								sorted(Entry.comparingByValue(Comparator.reverseOrder())).limit(10).forEachOrdered(entry -> cs.sendMessage("§a" + entry.getKey() + "§2: " + Main.economy.format(entry.getValue())));
 						break;
 					case "take":
 						if(args.length > 2) {
 							OfflinePlayer playerToTake = Bukkit.getOfflinePlayer(args[1]);
 							String inWorld = args.length > 3 ? args[3] : "world";
-							
+
 							if(playerToTake == null) {
 								cs.sendMessage("§cThis player does not exists");
 								return true;
@@ -474,10 +523,10 @@ public class ATM implements Listener, CommandExecutor {
 						break;
 					case "give":
 						if(args.length > 2) {
-							
+
 							OfflinePlayer playerToGive = Bukkit.getOfflinePlayer(args[1]);
 							String inWorld = args.length > 3 ? args[3] : "world";
-							
+
 							if(playerToGive == null) {
 								cs.sendMessage("§cThis player does not exists");
 								return true;

+ 1 - 1
README.md

@@ -7,7 +7,7 @@
 [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5ATDE93C6J3WE&source=url)
 
 ## Welcome to the TimeIsMoney GitHub repository!
-TimeIsMoney is a Spigot plugin compatible with Spigot versions 1.7 through 1.20.6, that gives players money for their time online!
+TimeIsMoney is a Spigot plugin compatible with Spigot versions 1.7 through 1.21.*, that gives players money for their time online!
 
 In order for everyone to have the best experience possible, we have a few guidelines that everyone must follow.    
 - For all things on GitHub, please make sure you follow the [code of conduct](CODE_OF_CONDUCT.md).  

+ 1 - 1
Tools/pom.xml

@@ -7,7 +7,7 @@
     <parent>
         <groupId>de.Linus122.TimeIsMoney</groupId>
         <artifactId>parent</artifactId>
-        <version>1.9.12</version>
+        <version>1.9.13</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 

+ 6 - 1
pom.xml

@@ -6,7 +6,7 @@
 
     <groupId>de.Linus122.TimeIsMoney</groupId>
     <artifactId>parent</artifactId>
-    <version>1.9.12</version>
+    <version>1.9.13</version>
     <name>TimeIsMoney</name>
     <url>https://www.spigotmc.org/resources/time-is-money.12409/</url>
     <packaging>pom</packaging>
@@ -42,6 +42,11 @@
 			<id>spaceio-repo</id>
 			<url>https://repo.spaceio.xyz/repository/maven-public/</url>
 		</repository>
+		<!-- Override EssentialsX's broken paper-repo with correct URL -->
+		<repository>
+			<id>paper-repo</id>
+			<url>https://repo.papermc.io/repository/maven-public/</url>
+		</repository>
     </repositories>
 
     <build>