From 4f7ca74a43abc951a99a1b9654d51df0f8ac7933 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 22 Mar 2022 09:50:57 +0100 Subject: [PATCH] Autostop --- src/de/steamwar/tutorial/listener/Joining.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/de/steamwar/tutorial/listener/Joining.java b/src/de/steamwar/tutorial/listener/Joining.java index 86df8fb..d347a26 100644 --- a/src/de/steamwar/tutorial/listener/Joining.java +++ b/src/de/steamwar/tutorial/listener/Joining.java @@ -19,8 +19,10 @@ package de.steamwar.tutorial.listener; +import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; public class Joining extends BasicListener { @@ -28,4 +30,11 @@ public class Joining extends BasicListener { public void onJoin(PlayerJoinEvent event) { event.getPlayer().setOp(true); } + + @EventHandler + public void onQuit(PlayerQuitEvent event) { + if (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer()))) { + Bukkit.shutdown(); + } + } }