mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 06:57:39 +01:00
Fix jail-online-time with offline players (#5701)
This commit is contained in:
parent
4219450705
commit
6b521e78a6
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user