Fix jail-online-time with offline players (#5701)

This commit is contained in:
pop4959 2024-02-26 11:32:44 -08:00 committed by GitHub
parent 4219450705
commit 6b521e78a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package com.earth2me.essentials;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Player;
@ -31,4 +32,11 @@ public class PlayerExtension {
public Location getLocation() {
return base.getLocation();
}
public OfflinePlayer getOffline() {
if (base instanceof OfflinePlayerStub) {
return ((OfflinePlayerStub) base).base;
}
return base;
}
}

View File

@ -83,7 +83,7 @@ public class Commandtogglejail extends EssentialsCommand {
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);
player.setOnlineJailedTime(ess.getSettings().isJailOnlineTime() ? ((player.getOffline().getStatistic(PLAY_ONE_TICK)) + (timeDiff / 50)) : 0);
}
final String tlKey;
@ -121,7 +121,7 @@ public class Commandtogglejail extends EssentialsCommand {
final long displayTimeDiff = DateUtil.parseDateDiff(unparsedTime, true);
final long timeDiff = DateUtil.parseDateDiff(unparsedTime, true, ess.getSettings().isJailOnlineTime());
player.setJailTimeout(timeDiff);
player.setOnlineJailedTime(ess.getSettings().isJailOnlineTime() ? ((player.getBase().getStatistic(PLAY_ONE_TICK)) + (timeDiff / 50)) : 0);
player.setOnlineJailedTime(ess.getSettings().isJailOnlineTime() ? ((player.getOffline().getStatistic(PLAY_ONE_TICK)) + (timeDiff / 50)) : 0);
sender.sendTl("jailSentenceExtended", DateUtil.formatDateDiff(displayTimeDiff));
final String tlKey = "jailNotifySentenceExtended";

View File

@ -64,8 +64,8 @@ import java.util.Set;
import java.util.UUID;
public class OfflinePlayerStub implements Player {
protected final transient org.bukkit.OfflinePlayer base;
private final transient Server server;
private final transient org.bukkit.OfflinePlayer base;
private transient Location location = new Location(null, 0, 0, 0, 0, 0);
private transient World world;
private boolean allowFlight = false;