Add ability to bypass auto leave for FPlayers. Implements #659.

Permission is factions.bypassautoleave
This commit is contained in:
Trent Hensler 2016-05-29 17:33:46 -07:00
parent 14946cd1b2
commit efb5d335f6
6 changed files with 30 additions and 2 deletions

View File

@ -37,6 +37,10 @@ public interface FPlayer extends EconomyParticipator {
public void setFaction(Faction faction);
public boolean willAutoLeave();
public void setAutoLeave(boolean autoLeave);
public void setMonitorJoins(boolean monitor);
public boolean isMonitoringJoins();

View File

@ -85,6 +85,9 @@ public class FactionsPlayerListener implements Listener {
}
}
}
// If they have the permission, don't let them autoleave. Bad inverted setter :\
me.setAutoLeave(!player.hasPermission(Permission.AUTO_LEAVE_BYPASS.node));
}
@EventHandler(priority = EventPriority.NORMAL)

View File

@ -12,6 +12,7 @@ public enum Permission {
AHOME("ahome"),
ANNOUNCE("announce"),
AUTOCLAIM("autoclaim"),
AUTO_LEAVE_BYPASS("autoleavebypass"),
BYPASS("bypass"),
CHAT("chat"),
CHATSPY("chatspy"),

View File

@ -6,6 +6,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.ListIterator;
import java.util.logging.Level;
public class AutoLeaveProcessTask extends BukkitRunnable {
@ -46,6 +47,13 @@ public class AutoLeaveProcessTask extends BukkitRunnable {
}
FPlayer fplayer = iterator.next();
// Check if they should be exempt from this.
if (!fplayer.willAutoLeave()) {
P.p.log(Level.INFO, fplayer.getName() + " was going to be auto-removed but was set not to.");
continue;
}
if (fplayer.isOffline() && now - fplayer.getLastLoginTime() > toleranceMillis) {
if (Conf.logFactionLeave || Conf.logFactionKick) {
P.p.log("Player " + fplayer.getName() + " was auto-removed due to inactivity.");

View File

@ -57,6 +57,7 @@ public abstract class MemoryFPlayer implements FPlayer {
protected int warmupTask;
protected boolean isAdminBypassing = false;
protected int kills, deaths;
protected boolean willAutoLeave;
protected transient FLocation lastStoodAt = new FLocation(); // Where did this player stand the last time we checked?
protected transient boolean mapAutoUpdating;
@ -124,6 +125,15 @@ public abstract class MemoryFPlayer implements FPlayer {
this.powerBoost = powerBoost;
}
public boolean willAutoLeave() {
return this.willAutoLeave;
}
public void setAutoLeave(boolean willLeave) {
this.willAutoLeave = willLeave;
P.p.debug(name + " set autoLeave to " + willLeave);
}
public Faction getAutoClaimFor() {
return autoClaimFor;
}

View File

@ -263,3 +263,5 @@ permissions:
description: Don't lose power for being offline.
factions.ahome:
description: Ability to send players to their faction home.
factions.autoleavebypass:
description: Bypass autoleave.