diff options
| author | Cow <cow@volloeko.de> | 2020-04-21 16:17:10 +0200 |
|---|---|---|
| committer | Cow <cow@volloeko.de> | 2020-04-21 16:17:10 +0200 |
| commit | f0686a8e45528e3dd682a6f7a69dd904730f6fb1 (patch) | |
| tree | 7c2329dc95527329d9492cddf14e4a8b913269de /src/main/java/eu/olli/cowmoonication/command | |
| parent | e04715d1c2a5d1909175fa53b3314f7bdb58a4e3 (diff) | |
| download | Cowlection-f0686a8e45528e3dd682a6f7a69dd904730f6fb1.tar.gz Cowlection-f0686a8e45528e3dd682a6f7a69dd904730f6fb1.tar.bz2 Cowlection-f0686a8e45528e3dd682a6f7a69dd904730f6fb1.zip | |
Improved player stalking feature
- offline player now include 'offline since <duration>'
Diffstat (limited to 'src/main/java/eu/olli/cowmoonication/command')
| -rw-r--r-- | src/main/java/eu/olli/cowmoonication/command/MooCommand.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main/java/eu/olli/cowmoonication/command/MooCommand.java b/src/main/java/eu/olli/cowmoonication/command/MooCommand.java index 2ddf7ce..a38eec7 100644 --- a/src/main/java/eu/olli/cowmoonication/command/MooCommand.java +++ b/src/main/java/eu/olli/cowmoonication/command/MooCommand.java @@ -15,6 +15,7 @@ import net.minecraft.command.ICommandSender; import net.minecraft.event.ClickEvent; import net.minecraft.event.HoverEvent; import net.minecraft.util.*; +import org.apache.commons.lang3.time.DurationFormatUtils; import java.awt.*; import java.io.IOException; @@ -175,7 +176,17 @@ public class MooCommand extends CommandBase { + (session.getMode() != null ? ": " + EnumChatFormatting.GOLD + session.getMode() : "") + (session.getMap() != null ? EnumChatFormatting.YELLOW + " (Map: " + EnumChatFormatting.GOLD + session.getMap() + EnumChatFormatting.YELLOW + ")" : "")); } else { - main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, EnumChatFormatting.GOLD + stalkedPlayer.getName() + EnumChatFormatting.YELLOW + " is currently " + EnumChatFormatting.RED + "offline" + EnumChatFormatting.YELLOW + " (or deactivated API access)."); + ApiUtils.fetchPlayerOfflineStatus(stalkedPlayer, slothStalking -> { + if (slothStalking == null) { + main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Something went wrong contacting the Slothpixel API. Couldn't stalk " + EnumChatFormatting.DARK_RED + stalkedPlayer.getName() + EnumChatFormatting.RED + " but they appear to be offline currently."); + } else if (slothStalking.getLastLogout() < 1) { // last_logout == null in API response + main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, slothStalking.getPlayerNameFormatted() + EnumChatFormatting.YELLOW + " is hiding their online status."); + } else { + String offlineSince = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - slothStalking.getLastLogout(), true, true); + + main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, slothStalking.getPlayerNameFormatted() + EnumChatFormatting.YELLOW + " is " + EnumChatFormatting.GOLD + "offline" + EnumChatFormatting.YELLOW + " since " + EnumChatFormatting.GOLD + offlineSince + EnumChatFormatting.YELLOW + (slothStalking.getLastGame() != null ? " (last played gamemode: " + EnumChatFormatting.GOLD + slothStalking.getLastGame() + EnumChatFormatting.YELLOW + ")" : "") + "."); + } + }); } } else { String cause = (hyStalking != null) ? hyStalking.getCause() : null; |
