mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-01-03 22:08:28 +00:00
Fix offline player error in /playtime for versions < 1.15.2 (#4649)
This commit is contained in:
parent
3c60bcf2de
commit
f8ca1bae5d
1 changed files with 6 additions and 1 deletions
|
@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
|||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
|
@ -33,7 +34,11 @@ public class Commandplaytime extends EssentialsCommand {
|
|||
final IUser user = getPlayer(server, sender, args, 0);
|
||||
displayName = user.getDisplayName();
|
||||
playtime = user.getBase().getStatistic(PLAY_ONE_TICK);
|
||||
} catch (PlayerNotFoundException ignored) {
|
||||
} catch (PlayerNotFoundException e) {
|
||||
// The ability to get the statistics of offline players is only available in 1.15.2+
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_15_2_R01)) {
|
||||
throw e;
|
||||
}
|
||||
final IUser user = getPlayer(server, sender, args, 0, true);
|
||||
displayName = user.getName();
|
||||
playtime = Bukkit.getOfflinePlayer(user.getBase().getUniqueId()).getStatistic(PLAY_ONE_TICK);
|
||||
|
|
Loading…
Reference in a new issue