Merge branch 'afkStopper' of SteamWar/BauSystem into master
Dieser Commit ist enthalten in:
Commit
fc47515121
@ -1,10 +1,7 @@
|
||||
package de.steamwar.bausystem;
|
||||
|
||||
import de.steamwar.bausystem.commands.*;
|
||||
import de.steamwar.bausystem.world.ArenaSection;
|
||||
import de.steamwar.bausystem.world.BauScoreboard;
|
||||
import de.steamwar.bausystem.world.RegionListener;
|
||||
import de.steamwar.bausystem.world.TNTListener;
|
||||
import de.steamwar.bausystem.world.*;
|
||||
import de.steamwar.core.CommandRemover;
|
||||
import de.steamwar.scoreboard.SWScoreboard;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
@ -90,6 +87,7 @@ 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);
|
||||
new AFKStopper();
|
||||
|
||||
autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200);
|
||||
}
|
||||
|
35
BauSystem_Main/src/de/steamwar/bausystem/world/AFKStopper.java
Normale Datei
35
BauSystem_Main/src/de/steamwar/bausystem/world/AFKStopper.java
Normale Datei
@ -0,0 +1,35 @@
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class AFKStopper implements Listener {
|
||||
|
||||
private static final String afkWarning = BauSystem.PREFIX + "§cDieser Server wird bei weiterer Inaktivität in einer Minute gestoppt";
|
||||
|
||||
private int minutesAfk;
|
||||
|
||||
public AFKStopper(){
|
||||
minutesAfk = 0;
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
|
||||
switch(minutesAfk){
|
||||
case 5:
|
||||
Bukkit.shutdown();
|
||||
break;
|
||||
case 4:
|
||||
Bukkit.broadcastMessage(afkWarning);
|
||||
default:
|
||||
minutesAfk++;
|
||||
}
|
||||
}, 1200, 1200); //every minute
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event){
|
||||
minutesAfk = 0;
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren