Browse Source

fix out of bounds exception

mastercake10 4 months ago
parent
commit
1a512944e9
1 changed files with 6 additions and 2 deletions
  1. 6 2
      Plugin/src/main/java/de/Linus122/TimeIsMoney/Main.java

+ 6 - 2
Plugin/src/main/java/de/Linus122/TimeIsMoney/Main.java

@@ -298,7 +298,9 @@ public class Main extends JavaPlugin {
 
 				// choose the last element of the payouts that does not have a custom timer
 				List<Payout> payoutsWithoutInterval = payouts_.stream().filter(payout -> payout.interval == 0).collect(Collectors.toList());
-				finalPayouts.add(payoutsWithoutInterval.get(payoutsWithoutInterval.size() - 1));
+				if (!payoutsWithoutInterval.isEmpty()) {
+					finalPayouts.add(payoutsWithoutInterval.get(payoutsWithoutInterval.size() - 1));
+				}
 				return finalPayouts;
 			} else if(this.getConfig().getBoolean("merge-payouts")) {
 				// Mering multiple payouts to one
@@ -360,7 +362,9 @@ public class Main extends JavaPlugin {
 		}
 
 		if (!finalconfig.getBoolean("allow-multiple-accounts") && !player.hasPermission("tim.multipleaccountsbypass")) {
-			Set<? extends Player> sameAddressPlayers = Bukkit.getOnlinePlayers().stream().filter(p -> p.getAddress().getHostString().equals(p.getAddress().getHostString())).collect(Collectors.toSet());
+			Set<? extends Player> sameAddressPlayers = Bukkit.getOnlinePlayers().stream()
+					.filter(p -> p.getAddress().getHostString().equals(p.getAddress().getHostString()))
+					.collect(Collectors.toSet());
 			int same_address_count = sameAddressPlayers.size();
 
 			if (same_address_count > finalconfig.getInt("max-multiple-accounts")) {