Kick players on the main thread, in a sync task. Closes #32

This commit is contained in:
graywolf336 2014-08-15 08:36:54 -05:00
parent 71a60e6ee3
commit 9f48cd6d0b

View File

@ -74,7 +74,7 @@ public class JailTimer {
//only execute this code if the prisoner's time is more than 0 milliseconds
//and they don't have any offline pending things
if(p.getRemainingTime() > 0 && !p.isOfflinePending()) {
Player player = pl.getServer().getPlayer(p.getUUID());
final Player player = pl.getServer().getPlayer(p.getUUID());
//Check if the player is offline
if(player == null) {
@ -90,8 +90,15 @@ public class JailTimer {
p.setAFKTime(p.getAFKTime() + timePassed);
if(p.getAFKTime() > afkTime) {
p.setAFKTime(0);
//This is so we kick players on the main thread
//instead of on the async thread(s), as spigot
//has a protection against this enabled.
pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, new Runnable() {
public void run() {
player.kickPlayer(Lang.AFKKICKMESSAGE.get());
}
});
}
}
//The prisoner isn't offline, so let's count down