aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/eu/olli/cowmoonication/command
diff options
context:
space:
mode:
authorCow <cow@volloeko.de>2020-04-21 16:17:10 +0200
committerCow <cow@volloeko.de>2020-04-21 16:17:10 +0200
commitf0686a8e45528e3dd682a6f7a69dd904730f6fb1 (patch)
tree7c2329dc95527329d9492cddf14e4a8b913269de /src/main/java/eu/olli/cowmoonication/command
parente04715d1c2a5d1909175fa53b3314f7bdb58a4e3 (diff)
downloadCowlection-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.java13
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;