mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 00:58:50 +01:00
Don't progress playtime for vanished users (#4918)
This commit is contained in:
parent
1c5a7e9ffb
commit
3af931740b
@ -92,6 +92,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
private long lastHomeConfirmationTimestamp;
|
||||
private Boolean toggleShout;
|
||||
private transient final List<String> signCopy = Lists.newArrayList("", "", "", "");
|
||||
private transient long lastVanishTime = System.currentTimeMillis();
|
||||
|
||||
public User(final Player base, final IEssentials ess) {
|
||||
super(base, ess);
|
||||
@ -964,6 +965,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
}
|
||||
}
|
||||
setHidden(true);
|
||||
lastVanishTime = System.currentTimeMillis();
|
||||
ess.getVanishedPlayersNew().add(getName());
|
||||
this.getBase().setMetadata("vanished", new FixedMetadataValue(ess, true));
|
||||
if (isAuthorized("essentials.vanish.effect")) {
|
||||
@ -1190,6 +1192,10 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
return isBaltopExcludeCache();
|
||||
}
|
||||
|
||||
public long getLastVanishTime() {
|
||||
return lastVanishTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getTargetBlock(int maxDistance) {
|
||||
final Block block;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
@ -39,9 +40,12 @@ public class Commandplaytime extends EssentialsCommand {
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_15_2_R01)) {
|
||||
throw e;
|
||||
}
|
||||
final IUser user = getPlayer(server, sender, args, 0, true);
|
||||
displayName = user.getName();
|
||||
final User user = getPlayer(server, args, 0, true, true);
|
||||
displayName = user.getName(); // Vanished players will have their name as their display name
|
||||
playtime = Bukkit.getOfflinePlayer(user.getBase().getUniqueId()).getStatistic(PLAY_ONE_TICK);
|
||||
if (user.getBase().isOnline() && user.isVanished()) {
|
||||
playtime = playtime - ((System.currentTimeMillis() - user.getLastVanishTime()) / 50L);
|
||||
}
|
||||
}
|
||||
key = "playtimeOther";
|
||||
} else if (sender.isPlayer()) {
|
||||
|
Loading…
Reference in New Issue
Block a user