From 09f315f8b53cf000c8157c4d810f503c31ebed96 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 31 Aug 2023 13:43:50 +0200 Subject: [PATCH] Shutdown Server when Empty --- src/de/steamwar/towerrun/listener/GlobalListener.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/de/steamwar/towerrun/listener/GlobalListener.java b/src/de/steamwar/towerrun/listener/GlobalListener.java index 50f83e2..2483f8c 100644 --- a/src/de/steamwar/towerrun/listener/GlobalListener.java +++ b/src/de/steamwar/towerrun/listener/GlobalListener.java @@ -24,6 +24,7 @@ import de.steamwar.towerrun.game.TowerRunGame; import de.steamwar.towerrun.game.TowerRunPlayer; import de.steamwar.towerrun.state.GameStateBukkitListener; import de.steamwar.towerrun.state.GameStates; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; @@ -48,6 +49,10 @@ public class GlobalListener extends GameStateBukkitListener { TowerRunGame.remove(TowerRunPlayer.get(event.getPlayer())); } TowerRunPlayer.remove(event.getPlayer()); + + if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().stream().allMatch(player -> player == event.getPlayer()))) { + Bukkit.shutdown(); + } } @EventHandler