diff options
author | Cow <cow@volloeko.de> | 2020-04-26 03:43:30 +0200 |
---|---|---|
committer | Cow <cow@volloeko.de> | 2020-04-26 03:43:30 +0200 |
commit | 35553dceb9c683000095ce1a62b4e094234304bc (patch) | |
tree | 8ed09cd69ba877be4defe9583007333c8164f8f0 /src/main/java/eu/olli/cowmoonication/command/MooCommand.java | |
parent | f0686a8e45528e3dd682a6f7a69dd904730f6fb1 (diff) | |
download | Cowlection-35553dceb9c683000095ce1a62b4e094234304bc.tar.gz Cowlection-35553dceb9c683000095ce1a62b4e094234304bc.tar.bz2 Cowlection-35553dceb9c683000095ce1a62b4e094234304bc.zip |
Improved output of player stalking feature
- offline players now include 'offline for <duration>'
- better handling of special cases (e.g. nicked players)
- also: simplified API requests and config handling
Diffstat (limited to 'src/main/java/eu/olli/cowmoonication/command/MooCommand.java')
-rw-r--r-- | src/main/java/eu/olli/cowmoonication/command/MooCommand.java | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/main/java/eu/olli/cowmoonication/command/MooCommand.java b/src/main/java/eu/olli/cowmoonication/command/MooCommand.java index a38eec7..58d01a5 100644 --- a/src/main/java/eu/olli/cowmoonication/command/MooCommand.java +++ b/src/main/java/eu/olli/cowmoonication/command/MooCommand.java @@ -1,5 +1,6 @@ package eu.olli.cowmoonication.command; +import com.mojang.realmsclient.util.Pair; import eu.olli.cowmoonication.Cowmoonication; import eu.olli.cowmoonication.config.MooConfig; import eu.olli.cowmoonication.config.MooGuiConfig; @@ -15,7 +16,6 @@ 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; @@ -179,12 +179,24 @@ public class MooCommand extends CommandBase { 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 + } else if (slothStalking.hasNeverJoinedHypixel()) { + main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, stalkedPlayer.getName() + EnumChatFormatting.YELLOW + " has " + EnumChatFormatting.GOLD + "never " + EnumChatFormatting.YELLOW + "been on Hypixel (or might be nicked)."); + } else if (slothStalking.isHidingOnlineStatus()) { main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, slothStalking.getPlayerNameFormatted() + EnumChatFormatting.YELLOW + " is hiding their online status."); + } else if (slothStalking.hasNeverLoggedOut()) { + Pair<String, String> lastOnline = Utils.getLastOnlineWords(slothStalking.getLastLogin()); + + main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, slothStalking.getPlayerNameFormatted() + EnumChatFormatting.YELLOW + " was last online " + EnumChatFormatting.GOLD + lastOnline.first() + EnumChatFormatting.YELLOW + " ago" + + (lastOnline.second() != null ? " (" + EnumChatFormatting.GOLD + lastOnline.second() + EnumChatFormatting.YELLOW + ")" : "") + "."); } else { - String offlineSince = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - slothStalking.getLastLogout(), true, true); + Pair<String, String> lastOnline = Utils.getLastOnlineWords(slothStalking.getLastLogout()); - 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 + ")" : "") + "."); + main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, slothStalking.getPlayerNameFormatted() + EnumChatFormatting.YELLOW + " is " + EnumChatFormatting.GOLD + "offline" + EnumChatFormatting.YELLOW + " for " + EnumChatFormatting.GOLD + lastOnline.first() + EnumChatFormatting.YELLOW + + ((lastOnline.second() != null || slothStalking.getLastGame() != null) ? (" (" + + (lastOnline.second() != null ? EnumChatFormatting.GOLD + lastOnline.second() + EnumChatFormatting.YELLOW : "") // = last online date + + (lastOnline.second() != null && slothStalking.getLastGame() != null ? "; " : "") // = delimiter + + (slothStalking.getLastGame() != null ? "last played gamemode: " + EnumChatFormatting.GOLD + slothStalking.getLastGame() + EnumChatFormatting.YELLOW : "") // = last gamemode + + ")") : "") + "."); } }); } |