SteamWar/BauSystem
Archiviert
13
0

Automatic BauServer stop after 60s running without player

Dieser Commit ist enthalten in:
Lixfel 2020-01-19 07:01:07 +01:00
Ursprung 6a14a5be7e
Commit 269cbb163c

Datei anzeigen

@ -18,6 +18,7 @@ import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.permissions.PermissionAttachment; import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import java.io.File; import java.io.File;
import java.io.IOException; 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 PREFIX = "§eBauSystem§8» §7";
public static final String SECTION_PATH = "/home/minecraft/backbone/server/UserBau/"; public static final String SECTION_PATH = "/home/minecraft/backbone/server/UserBau/";
private BukkitTask autoShutdown;
@Override @Override
public void onEnable() { public void onEnable() {
plugin = this; plugin = this;
@ -87,6 +90,8 @@ public class BauSystem extends JavaPlugin implements Listener {
Bukkit.getPluginManager().registerEvents(new RegionListener(), this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
Bukkit.getPluginManager().registerEvents(new TNTListener(), this); Bukkit.getPluginManager().registerEvents(new TNTListener(), this);
Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this); Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this);
autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200);
} }
public static BauSystem getPlugin(){ public static BauSystem getPlugin(){
@ -109,6 +114,11 @@ public class BauSystem extends JavaPlugin implements Listener {
@EventHandler @EventHandler
public void onJoin(PlayerLoginEvent e) { public void onJoin(PlayerLoginEvent e) {
if(autoShutdown != null){
autoShutdown.cancel();
autoShutdown = null;
}
Player p = e.getPlayer(); Player p = e.getPlayer();
PermissionAttachment attachment = p.addAttachment(this); PermissionAttachment attachment = p.addAttachment(this);
attachment.setPermission("F3NPerm.use", true); attachment.setPermission("F3NPerm.use", true);