From 269cbb163cc572e06addbf8772129588354e363f Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 19 Jan 2020 07:01:07 +0100 Subject: [PATCH] Automatic BauServer stop after 60s running without player --- .../src/de/steamwar/bausystem/BauSystem.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 3fcf78c..72b387b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -18,6 +18,7 @@ import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.permissions.PermissionAttachment; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitTask; import java.io.File; import java.io.IOException; @@ -32,6 +33,8 @@ public class BauSystem extends JavaPlugin implements Listener { public static final String PREFIX = "§eBauSystem§8» §7"; public static final String SECTION_PATH = "/home/minecraft/backbone/server/UserBau/"; + private BukkitTask autoShutdown; + @Override public void onEnable() { plugin = this; @@ -87,6 +90,8 @@ public class BauSystem extends JavaPlugin implements Listener { Bukkit.getPluginManager().registerEvents(new RegionListener(), this); Bukkit.getPluginManager().registerEvents(new TNTListener(), this); Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this); + + autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200); } public static BauSystem getPlugin(){ @@ -109,6 +114,11 @@ public class BauSystem extends JavaPlugin implements Listener { @EventHandler public void onJoin(PlayerLoginEvent e) { + if(autoShutdown != null){ + autoShutdown.cancel(); + autoShutdown = null; + } + Player p = e.getPlayer(); PermissionAttachment attachment = p.addAttachment(this); attachment.setPermission("F3NPerm.use", true);