Fix further incorrect messages for jail countdowns (#3941)

Fixes #3939, fixes #3940.
This commit is contained in:
Josh Roy 2021-02-16 08:56:57 -05:00 committed by GitHub
parent 36422ab22b
commit 1258d2f0a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -598,7 +598,11 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
@Override
public String getFormattedJailTime() {
return DateUtil.formatDateDiff(getOnlineJailedTime() > 0 ? (System.currentTimeMillis() - getJailTimeout()) : getJailTimeout());
return DateUtil.formatDateDiff(getOnlineJailedTime() > 0 ? getOnlineJailExpireTime() : getJailTimeout());
}
private long getOnlineJailExpireTime() {
return ((getOnlineJailedTime() - getBase().getStatistic(PLAY_ONE_TICK)) * 50) + System.currentTimeMillis();
}
//Returns true if status expired during this check

View File

@ -79,6 +79,7 @@ public class Commandtogglejail extends EssentialsCommand {
player.setJail(jailName);
if (args.length > 2) {
player.setJailTimeout(timeDiff);
// 50 MSPT (milliseconds per tick)
player.setOnlineJailedTime(ess.getSettings().isJailOnlineTime() ? ((player.getBase().getStatistic(PLAY_ONE_TICK)) + (timeDiff / 50)) : 0);
}
sender.sendMessage(timeDiff > 0 ? tl("playerJailedFor", player.getName(), DateUtil.formatDateDiff(finalDisplayTime)) : tl("playerJailed", player.getName()));
@ -99,9 +100,12 @@ public class Commandtogglejail extends EssentialsCommand {
}
if (args.length >= 2 && player.isJailed() && args[1].equalsIgnoreCase(player.getJail())) {
final long timeDiff = DateUtil.parseDateDiff(getFinalArg(args, 2), true);
final String unparsedTime = getFinalArg(args, 2);
final long displayTimeDiff = DateUtil.parseDateDiff(unparsedTime, true);
final long timeDiff = DateUtil.parseDateDiff(unparsedTime, true, ess.getSettings().isJailOnlineTime());
player.setJailTimeout(timeDiff);
sender.sendMessage(tl("jailSentenceExtended", DateUtil.formatDateDiff(timeDiff)));
player.setOnlineJailedTime(ess.getSettings().isJailOnlineTime() ? ((player.getBase().getStatistic(PLAY_ONE_TICK)) + (timeDiff / 50)) : 0);
sender.sendMessage(tl("jailSentenceExtended", DateUtil.formatDateDiff(displayTimeDiff)));
return;
}