Add IUser#isFreeze & IUser#setFreeze

This commit is contained in:
Josh Roy 2022-12-25 15:59:23 -05:00 committed by MD
parent 6ec4c97ddd
commit e0d6040662
3 changed files with 30 additions and 6 deletions

View File

@ -193,17 +193,26 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
return;
}
if (!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers()) {
event.getHandlers().unregister(this);
final User user = ess.getUser(event.getPlayer());
if (ess.getSettings().isDebug()) {
ess.getLogger().log(Level.INFO, "Unregistering move listener");
if (user.isFreeze()) {
final Location from = event.getFrom();
final Location to = event.getTo().clone();
to.setX(from.getX());
to.setY(from.getY());
to.setZ(from.getZ());
try {
event.setTo(LocationUtil.getSafeDestination(to));
} catch (final Exception ex) {
event.setTo(to);
}
return;
}
final User user = ess.getUser(event.getPlayer());
if (!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers()) {
return;
}
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers()) {
final Location from = event.getFrom();
final Location origTo = event.getTo();

View File

@ -336,4 +336,8 @@ public interface IUser {
List<String> getPastUsernames();
void addPastUsername(String username);
boolean isFreeze();
void setFreeze(boolean freeze);
}

View File

@ -90,6 +90,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
private String lastHomeConfirmation;
private long lastHomeConfirmationTimestamp;
private Boolean toggleShout;
private boolean freeze = false;
private transient final List<String> signCopy = Lists.newArrayList("", "", "", "");
private transient long lastVanishTime = System.currentTimeMillis();
@ -1191,6 +1192,16 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
return signCopy;
}
@Override
public boolean isFreeze() {
return freeze;
}
@Override
public void setFreeze(boolean freeze) {
this.freeze = freeze;
}
public boolean isBaltopExempt() {
if (getBase().isOnline()) {
final boolean exempt = isAuthorized("essentials.balancetop.exclude");