diff options
| author | Cow <cow@volloeko.de> | 2020-07-28 00:12:36 +0200 |
|---|---|---|
| committer | Cow <cow@volloeko.de> | 2020-07-28 00:12:36 +0200 |
| commit | b393636cb3f7e05ef8b34804eeb06357f1b9cfbe (patch) | |
| tree | d754561fd2e2f09ac66f41b2645ac5f351c1cace /src/main/java/eu | |
| parent | 023589c75ae72ddc5ff75fa7235bce4d102b2ad1 (diff) | |
| download | Cowlection-b393636cb3f7e05ef8b34804eeb06357f1b9cfbe.tar.gz Cowlection-b393636cb3f7e05ef8b34804eeb06357f1b9cfbe.tar.bz2 Cowlection-b393636cb3f7e05ef8b34804eeb06357f1b9cfbe.zip | |
Renamed package to match cowtipper.de
Diffstat (limited to 'src/main/java/eu')
38 files changed, 0 insertions, 5969 deletions
diff --git a/src/main/java/eu/olli/cowlection/Cowlection.java b/src/main/java/eu/olli/cowlection/Cowlection.java deleted file mode 100644 index cff48ad..0000000 --- a/src/main/java/eu/olli/cowlection/Cowlection.java +++ /dev/null @@ -1,127 +0,0 @@ -package eu.olli.cowlection; - -import eu.olli.cowlection.command.MooCommand; -import eu.olli.cowlection.command.ReplyCommand; -import eu.olli.cowlection.command.ShrugCommand; -import eu.olli.cowlection.command.TabCompletableCommand; -import eu.olli.cowlection.config.MooConfig; -import eu.olli.cowlection.handler.DungeonCache; -import eu.olli.cowlection.handler.FriendsHandler; -import eu.olli.cowlection.handler.PlayerCache; -import eu.olli.cowlection.listener.ChatListener; -import eu.olli.cowlection.listener.PlayerListener; -import eu.olli.cowlection.util.ChatHelper; -import eu.olli.cowlection.util.VersionChecker; -import net.minecraftforge.client.ClientCommandHandler; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import org.apache.logging.log4j.Logger; - -import java.io.File; - -@Mod(modid = Cowlection.MODID, name = Cowlection.MODNAME, version = Cowlection.VERSION, - clientSideOnly = true, - guiFactory = "@PACKAGE@.config.MooGuiFactory", - updateJSON = "https://raw.githubusercontent.com/cow-mc/Cowlection/master/update.json") -public class Cowlection { - public static final String MODID = "@MODID@"; - public static final String VERSION = "@VERSION@"; - public static final String MODNAME = "@MODNAME@"; - public static final String GITURL = "@GITURL@"; - private static Cowlection instance; - private File configDir; - private File modsDir; - private MooConfig config; - private FriendsHandler friendsHandler; - private VersionChecker versionChecker; - private ChatHelper chatHelper; - private PlayerCache playerCache; - private DungeonCache dungeonCache; - private Logger logger; - - @Mod.EventHandler - public void preInit(FMLPreInitializationEvent e) { - instance = this; - logger = e.getModLog(); - modsDir = e.getSourceFile().getParentFile(); - - this.configDir = new File(e.getModConfigurationDirectory(), MODID + File.separatorChar); - if (!configDir.exists()) { - configDir.mkdirs(); - } - - friendsHandler = new FriendsHandler(this, new File(configDir, "friends.json")); - config = new MooConfig(this, new Configuration(new File(configDir, MODID + ".cfg"))); - - chatHelper = new ChatHelper(); - } - - @EventHandler - public void init(FMLInitializationEvent e) { - MinecraftForge.EVENT_BUS.register(new ChatListener(this)); - MinecraftForge.EVENT_BUS.register(new PlayerListener(this)); - ClientCommandHandler.instance.registerCommand(new MooCommand(this)); - ClientCommandHandler.instance.registerCommand(new ReplyCommand(this)); - ClientCommandHandler.instance.registerCommand(new ShrugCommand(this)); - for (String tabCompletableNamesCommand : MooConfig.tabCompletableNamesCommands) { - ClientCommandHandler.instance.registerCommand(new TabCompletableCommand(this, tabCompletableNamesCommand)); - } - } - - @EventHandler - public void postInit(FMLPostInitializationEvent e) { - versionChecker = new VersionChecker(this); - playerCache = new PlayerCache(this); - } - - public MooConfig getConfig() { - return config; - } - - public FriendsHandler getFriendsHandler() { - return friendsHandler; - } - - public VersionChecker getVersionChecker() { - return versionChecker; - } - - public ChatHelper getChatHelper() { - return chatHelper; - } - - public PlayerCache getPlayerCache() { - return playerCache; - } - - public DungeonCache getDungeonCache() { - if (dungeonCache == null) { - dungeonCache = new DungeonCache(this); - } - return dungeonCache; - } - - public File getConfigDirectory() { - return configDir; - } - - public File getModsDirectory() { - return modsDir; - } - - public Logger getLogger() { - return logger; - } - - /** - * Get mod's instance; instead of this method use dependency injection where possible - */ - public static Cowlection getInstance() { - return instance; - } -} diff --git a/src/main/java/eu/olli/cowlection/command/MooCommand.java b/src/main/java/eu/olli/cowlection/command/MooCommand.java deleted file mode 100644 index bde7758..0000000 --- a/src/main/java/eu/olli/cowlection/command/MooCommand.java +++ /dev/null @@ -1,641 +0,0 @@ -package eu.olli.cowlection.command; - -import com.mojang.realmsclient.util.Pair; -import eu.olli.cowlection.Cowlection; -import eu.olli.cowlection.command.exception.ApiContactException; -import eu.olli.cowlection.command.exception.InvalidPlayerNameException; -import eu.olli.cowlection.command.exception.MooCommandException; -import eu.olli.cowlection.config.MooConfig; -import eu.olli.cowlection.config.MooGuiConfig; -import eu.olli.cowlection.data.*; -import eu.olli.cowlection.data.HySkyBlockStats.Profile.Pet; -import eu.olli.cowlection.handler.DungeonCache; -import eu.olli.cowlection.search.GuiSearch; -import eu.olli.cowlection.util.*; -import net.minecraft.client.Minecraft; -import net.minecraft.command.*; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.event.ClickEvent; -import net.minecraft.event.HoverEvent; -import net.minecraft.item.ItemSkull; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.*; -import net.minecraftforge.common.util.Constants; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang3.StringUtils; - -import java.awt.*; -import java.io.IOException; -import java.util.List; -import java.util.*; -import java.util.concurrent.TimeUnit; - -public class MooCommand extends CommandBase { - private final Cowlection main; - - public MooCommand(Cowlection main) { - this.main = main; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length == 0) { - main.getChatHelper().sendMessage(EnumChatFormatting.GOLD, "Tried to say " + EnumChatFormatting.YELLOW + getCommandName() + EnumChatFormatting.GOLD + "? Use " + EnumChatFormatting.YELLOW + getCommandName() + " say [optional text]" + EnumChatFormatting.GOLD + " instead.\n" - + "Tried to use the command " + EnumChatFormatting.YELLOW + "/" + getCommandName() + EnumChatFormatting.GOLD + "? Use " + EnumChatFormatting.YELLOW + "/" + getCommandName() + " help" + EnumChatFormatting.GOLD + " for a list of available commands"); - return; - } - // sub commands: friends & other players - if (args[0].equalsIgnoreCase("say")) { - // work-around so you can still say 'moo' in chat without triggering the client-side command - String msg = CommandBase.buildString(args, 1); - Minecraft.getMinecraft().thePlayer.sendChatMessage(getCommandName() + (!msg.isEmpty() ? " " + msg : "")); - } else if (args[0].equalsIgnoreCase("stalk") - || args[0].equalsIgnoreCase("s") - || args[0].equalsIgnoreCase("askPolitelyWhereTheyAre")) { - if (args.length != 2) { - throw new WrongUsageException("/" + getCommandName() + " stalk <playerName>"); - } else if (!Utils.isValidMcName(args[1])) { - throw new InvalidPlayerNameException(args[1]); - } else { - handleStalking(args[1]); - } - } else if (args[0].equalsIgnoreCase("stalkskyblock") || args[0].equalsIgnoreCase("skyblockstalk") - || args[0].equalsIgnoreCase("ss") - || args[0].equalsIgnoreCase("stalksb") || args[0].equalsIgnoreCase("sbstalk") - || args[0].equalsIgnoreCase("askPolitelyAboutTheirSkyBlockProgress")) { - if (args.length != 2) { - throw new WrongUsageException("/" + getCommandName() + " skyblockstalk <playerName>"); - } else if (!Utils.isValidMcName(args[1])) { - throw new InvalidPlayerNameException(args[1]); - } else { - handleStalkingSkyBlock(args[1]); - } - } else if (args[0].equalsIgnoreCase("analyzeIsland")) { - Map<String, String> minions = DataHelper.getMinions(); - - Map<String, Integer> detectedMinions = new HashMap<>(); - Map<Integer, Integer> detectedMinionsWithSkin = new HashMap<>(); - int detectedMinionCount = 0; - int minionsWithSkinCount = 0; - entityLoop: - for (Entity entity : sender.getEntityWorld().loadedEntityList) { - if (entity instanceof EntityArmorStand) { - EntityArmorStand minion = (EntityArmorStand) entity; - - if (minion.isInvisible() || !minion.isSmall() || minion.getHeldItem() == null) { - // not a minion: invisible, or not small armor stand, or no item in hand (= minion in a minion chair) - continue; - } - for (int slot = 0; slot < 4; slot++) { - if (minion.getCurrentArmor(slot) == null) { - // not a minion: missing equipment - continue entityLoop; - } - } - ItemStack skullItem = minion.getCurrentArmor(3); // head slot - if (skullItem.getItem() instanceof ItemSkull && skullItem.getMetadata() == 3 && skullItem.hasTagCompound()) { - // is a player head! - if (skullItem.getTagCompound().hasKey("SkullOwner", Constants.NBT.TAG_COMPOUND)) { - NBTTagCompound skullOwner = skullItem.getTagCompound().getCompoundTag("SkullOwner"); - String skullDataBase64 = skullOwner.getCompoundTag("Properties").getTagList("textures", Constants.NBT.TAG_COMPOUND).getCompoundTagAt(0).getString("Value"); - String skullData = new String(Base64.decodeBase64(skullDataBase64)); - String minionSkinId = StringUtils.substringBetween(skullData, "http://textures.minecraft.net/texture/", "\""); - String detectedMinion = minions.get(minionSkinId); - if (detectedMinion != null) { - // minion head matches one know minion tier - detectedMinions.put(detectedMinion, detectedMinions.getOrDefault(detectedMinion, 0) + 1); - detectedMinionCount++; - } else { - int minionTier = ImageUtils.getTierFromTexture(minionSkinId); - if (minionTier > 0) { - detectedMinionsWithSkin.put(minionTier, detectedMinionsWithSkin.getOrDefault(minionTier, 0) + 1); - minionsWithSkinCount++; - } else { - // looked like a minion but has no matching tier badge - main.getLogger().info("[/moo analyzeIsland] Found an armor stand that could be a minion but it is missing a tier badge: " + minionSkinId + "\t\t\t" + minion.serializeNBT()); - } - } - } - } - } - } - StringBuilder analysisResults = new StringBuilder("Found ").append(EnumChatFormatting.GOLD).append(detectedMinionCount).append(EnumChatFormatting.YELLOW).append(" minions"); - if (minionsWithSkinCount > 0) { - analysisResults.append(" + ").append(EnumChatFormatting.GOLD).append(minionsWithSkinCount).append(EnumChatFormatting.YELLOW).append(" unknown minions with skins"); - } - analysisResults.append(" on this island"); - detectedMinions.entrySet().stream() - .sorted(Map.Entry.comparingByKey()) // sort alphabetically by minion name and tier - .forEach(minion -> { - String minionWithTier = minion.getKey(); - int lastSpace = minionWithTier.lastIndexOf(' '); - - String tierRoman = minionWithTier.substring(lastSpace + 1); - - int tierArabic = Utils.convertRomanToArabic(tierRoman); - EnumChatFormatting tierColor = Utils.getMinionTierColor(tierArabic); - - minionWithTier = minionWithTier.substring(0, lastSpace) + " " + tierColor + (MooConfig.useRomanNumerals() ? tierRoman : tierArabic); - analysisResults.append("\n ").append(EnumChatFormatting.GOLD).append(minion.getValue()).append(minion.getValue() > 1 ? "✕ " : "⨉ ") - .append(EnumChatFormatting.YELLOW).append(minionWithTier); - }); - detectedMinionsWithSkin.entrySet().stream() - .sorted(Map.Entry.comparingByKey()) // sort by tier - .forEach(minionWithSkin -> { - EnumChatFormatting tierColor = Utils.getMinionTierColor(minionWithSkin.getKey()); - String minionTier = MooConfig.useRomanNumerals() ? Utils.convertArabicToRoman(minionWithSkin.getKey()) : String.valueOf(minionWithSkin.getKey()); - analysisResults.append("\n ").append(EnumChatFormatting.GOLD).append(minionWithSkin.getValue()).append(minionWithSkin.getValue() > 1 ? "✕ " : "⨉ ") - .append(EnumChatFormatting.RED).append("Unknown minion ").append(EnumChatFormatting.YELLOW).append("(new or with minion skin) ").append(tierColor).append(minionTier); - }); - main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, analysisResults.toString()); - } else if (args[0].equalsIgnoreCase("deaths")) { - DungeonCache dungeonCache = main.getDungeonCache(); - if (dungeonCache.isInDungeon()) { - dungeonCache.sendDeathCounts(); - } else { - throw new MooCommandException(EnumChatFormatting.DARK_RED + "Looks like you're not in a dungeon..."); - } - } else if (args[0].equalsIgnoreCase("add")) { - handleBestFriendAdd(args); - } else if (args[0].equalsIgnoreCase("remove")) { - handleBestFriendRemove(args); - } else if (args[0].equalsIgnoreCase("list")) { - handleListBestFriends(); - } else if (args[0].equalsIgnoreCase("nameChangeCheck")) { - handleNameChangeCheck(args); - } - // sub-commands: miscellaneous - else if (args[0].equalsIgnoreCase("config") || args[0].equalsIgnoreCase("toggle")) { - new TickDelay(() -> Minecraft.getMinecraft().displayGuiScreen(new MooGuiConfig(null)), 1); // delay by 1 tick, because the chat closing would close the new gui instantly as well. - } else if (args[0].equalsIgnoreCase("search")) { - new TickDelay(() -> Minecraft.getMinecraft().displayGuiScreen(new GuiSearch(main.getConfigDirectory())), 1); // delay by 1 tick, because the chat closing would close the new gui instantly as well. - } else if (args[0].equalsIgnoreCase("guiscale")) { - int currentGuiScale = (Minecraft.getMinecraft()).gameSettings.guiScale; - if (args.length == 1) { - main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "\u279C Current GUI scale: " + EnumChatFormatting.DARK_GREEN + currentGuiScale); - } else { - int scale = MathHelper.parseIntWithDefault(args[1], -1); - if (scale == -1 || scale > 10) { - throw new NumberInvalidException(EnumChatFormatting.DARK_RED + args[1] + EnumChatFormatting.RED + " is an invalid GUI scale value. Valid values are integers below 10"); - } - Minecraft.getMinecraft().gameSettings.guiScale = scale; - main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "\u2714 New GUI scale: " + EnumChatFormatting.DARK_GREEN + scale + EnumChatFormatting.GREEN + " (previous: " + EnumChatFormatting.DARK_GREEN + currentGuiScale + EnumChatFormatting.GREEN + ")"); - } - } else if (args[0].equalsIgnoreCase("rr")) { - Minecraft.getMinecraft().thePlayer.sendChatMessage("/r " + CommandBase.buildString(args, 1)); - } else if (args[0].equalsIgnoreCase("shrug")) { - main.getChatHelper().sendShrug(buildString(args, 1)); - } else if (args[0].equalsIgnoreCase("apikey")) { - handleApiKey(args); - } - // sub-commands: update mod - else if (args[0].equalsIgnoreCase("update")) { - boolean updateCheckStarted = main.getVersionChecker().runUpdateCheck(true); - - if (updateCheckStarted) { - main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "\u279C Checking for a newer mod version..."); - // VersionChecker#handleVersionStatus will run with a 5 seconds delay - } else { - long nextUpdate = main.getVersionChecker().getNextCheck(); - String waitingTime = String.format("%02d:%02d", - TimeUnit.MILLISECONDS.toMinutes(nextUpdate), - TimeUnit.MILLISECONDS.toSeconds(nextUpdate) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(nextUpdate))); - throw new MooCommandException("\u26A0 Update checker is on cooldown. Please wait " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + waitingTime + EnumChatFormatting.RESET + EnumChatFormatting.RED + " more minutes before checking again."); - } - } else if (args[0].equalsIgnoreCase("updateHelp")) { - main.getChatHelper().sendMessage(new ChatComponentText("\u279C Update instructions:").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(true)) - .appendSibling(new ChatComponentText("\n\u278A" + EnumChatFormatting.YELLOW + " download latest mod version").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false) - .setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, main.getVersionChecker().getDownloadUrl())) - .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "Download the latest version of " + Cowlection.MODNAME + "\n\u279C Click to download latest mod file"))))) - .appendSibling(new ChatComponentText("\n\u278B" + EnumChatFormatting.YELLOW + " exit Minecraft").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false) - .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.GOLD + "\u278B" + EnumChatFormatting.YELLOW + " Without closing Minecraft first,\n" + EnumChatFormatting.YELLOW + "you can't delete the old .jar file!"))))) - .appendSibling(new ChatComponentText("\n\u278C" + EnumChatFormatting.YELLOW + " copy " + EnumChatFormatting.GOLD + Cowlection.MODNAME.replace(" ", "") + "-" + main.getVersionChecker().getNewVersion() + ".jar" + EnumChatFormatting.YELLOW + " into mods directory").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false) - .setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/moo directory")) - .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "Open mods directory with command " + EnumChatFormatting.GOLD + "/moo directory\n\u279C Click to open mods directory"))))) - .appendSibling(new ChatComponentText("\n\u278D" + EnumChatFormatting.YELLOW + " delete old mod file " + EnumChatFormatting.GOLD + Cowlection.MODNAME.replace(" ", "") + "-" + Cowlection.VERSION + ".jar ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false))) - .appendSibling(new ChatComponentText("\n\u278E" + EnumChatFormatting.YELLOW + " start Minecraft again").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false)))); - } else if (args[0].equalsIgnoreCase("version")) { - main.getVersionChecker().handleVersionStatus(true); - } else if (args[0].equalsIgnoreCase("directory") || args[0].equalsIgnoreCase("folder")) { - try { - Desktop.getDesktop().open(main.getModsDirectory()); - } catch (IOException e) { - e.printStackTrace(); - throw new MooCommandException("\u2716 An error occurred trying to open the mod's directory. I guess you have to open it manually \u00af\\_(\u30c4)_/\u00af"); - } - } else if (args[0].equalsIgnoreCase("help")) { - sendCommandUsage(sender); - } - // "catch-all" remaining sub-commands - else { - main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Command " + EnumChatFormatting.DARK_RED + "/" + getCommandName() + " " + args[0] + EnumChatFormatting.RED + " doesn't exist. Use " + EnumChatFormatting.DARK_RED + "/" + getCommandName() + " help " + EnumChatFormatting.RED + "to show command usage."); - } - } - - private void handleApiKey(String[] args) throws CommandException { - if (args.length == 1) { - String firstSentence; - EnumChatFormatting color; - EnumChatFormatting colorSecondary; - if (Utils.isValidUuid(MooConfig.moo)) { - firstSentence = "You already set your Hypixel API key."; - color = EnumChatFormatting.GREEN; - colorSecondary = EnumChatFormatting.DARK_GREEN; - } else { - firstSentence = "You haven't set your Hypixel API key yet."; - color = EnumChatFormatting.RED; - colorSecondary = EnumChatFormatting.DARK_RED; - } - main.getChatHelper().sendMessage(color, firstSentence + " Use " + colorSecondary + "/api new" + color + " to request a new API key from Hypixel or use " + colorSecondary + "/" + this.getCommandName() + " apikey <key>" + color + " to manually set your existing API key."); - } else { - String key = args[1]; - if (Utils.isValidUuid(key)) { - MooConfig.moo = key; - main.getConfig().syncFromFields(); - main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "Updated API key!"); - } else { - throw new SyntaxErrorException("That doesn't look like a valid API key..."); - } - } - } - - private void handleStalking(String playerName) throws CommandException { - if (!Utils.isValidUuid(MooConfig.moo)) { - throw new MooCommandException("You haven't set your Hypixel API key yet. Use " + EnumChatFormatting.DARK_RED + "/api new" + EnumChatFormatting.RED + " to request a new API key from Hypixel or use " + EnumChatFormatting.DARK_RED + "/" + this.getCommandName() + " apikey <key>" + EnumChatFormatting.RED + " to manually set your existing API key."); - } - main.getChatHelper().sendMessage(EnumChatFormatting.GRAY, "Stalking " + EnumChatFormatting.WHITE + playerName + EnumChatFormatting.GRAY + ". This may take a few seconds."); - boolean isBestFriend = main.getFriendsHandler().isBestFriend(playerName, true); - if (isBestFriend) { - Friend stalkedPlayer = main.getFriendsHandler().getBestFriend(playerName); - // we have the uuid already, so stalk the player - stalkPlayer(stalkedPlayer); - } else { - // fetch player uuid - ApiUtils.fetchFriendData(playerName, stalkedPlayer -> { - if (stalkedPlayer == null) { - throw new ApiContactException("Mojang", "couldn't stalk " + EnumChatFormatting.DARK_RED + playerName); - } else if (stalkedPlayer.equals(Friend.FRIEND_NOT_FOUND)) { - throw new PlayerNotFoundException("There is no player with the name " + EnumChatFormatting.DARK_RED + playerName + EnumChatFormatting.RED + "."); - } else { - // ... then stalk the player - stalkPlayer(stalkedPlayer); - } - }); - } - } - - private void stalkPlayer(Friend stalkedPlayer) { - ApiUtils.fetchPlayerStatus(stalkedPlayer, hyStalking -> { - if (hyStalking != null && hyStalking.isSuccess()) { - HyStalkingData.HySession session = hyStalking.getSession(); - if (session.isOnline()) { - main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, EnumChatFormatting.GOLD + stalkedPlayer.getName() + EnumChatFormatting.YELLOW + " is currently playing " + EnumChatFormatting.GOLD + session.getGameType() + EnumChatFormatting.YELLOW - + (session.getMode() != null ? ": " + EnumChatFormatting.GOLD + session.getMode() : "") - + (session.getMap() != null ? EnumChatFormatting.YELLOW + " (Map: " + EnumChatFormatting.GOLD + session.getMap() + EnumChatFormatting.YELLOW + ")" : "")); - } else { - ApiUtils.fetchPlayerOfflineStatus(stalkedPlayer, hyPlayerData -> { - if (hyPlayerData == null) { - throw new ApiContactException("Hypixel", "couldn't stalk " + EnumChatFormatting.DARK_RED + stalkedPlayer.getName() + EnumChatFormatting.RED + " but they appear to be offline currently."); - } else if (hyPlayerData.hasNeverJoinedHypixel()) { - main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, EnumChatFormatting.GOLD + stalkedPlayer.getName() + EnumChatFormatting.YELLOW + " has " + EnumChatFormatting.GOLD + "never " + EnumChatFormatting.YELLOW + "been on Hypixel (or might be nicked)."); - } else if (hyPlayerData.isHidingOnlineStatus()) { - main.getChatHelper().sendMessage(new ChatComponentText(hyPlayerData.getPlayerNameFormatted()).appendSibling(new ChatComponentText(" is hiding their online status from the Hypixel API. You can see their online status with ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW))) - .appendSibling(new ChatComponentText("/profile " + hyPlayerData.getPlayerName()).setChatStyle(new ChatStyle() - .setColor(EnumChatFormatting.GOLD) - .setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/profile " + hyPlayerData.getPlayerName())) - .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "Run " + EnumChatFormatting.GOLD + "/profile " + hyPlayerData.getPlayerName()))))) - .appendSibling(new ChatComponentText(" while you're in a lobby (tooltip of the player head on the top left).").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)))); - } else if (hyPlayerData.hasNeverLoggedOut()) { - Pair<String, String> lastOnline = Utils.getDurationAsWords(hyPlayerData.getLastLogin()); - - main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, hyPlayerData.getPlayerNameFormatted() + EnumChatFormatting.YELLOW + " was last online " + EnumChatFormatting.GOLD + lastOnline.first() + EnumChatFormatting.YELLOW + " ago" - + (lastOnline.second() != null ? " (" + EnumChatFormatting.GOLD + lastOnline.second() + EnumChatFormatting.YELLOW + ")" : "") + "."); - } else if (hyPlayerData.getLastLogin() > hyPlayerData.getLastLogout()) { - // player is logged in but is hiding their session details from API (My Profile > API settings > Online Status) - main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, EnumChatFormatting.GOLD + hyPlayerData.getPlayerNameFormatted() + EnumChatFormatting.YELLOW + " is currently playing " + EnumChatFormatting.GOLD + hyPlayerData.getLastGame() + "\n" + EnumChatFormatting.DARK_GRAY + "(" + hyPlayerData.getPlayerName() + " hides their session details from the API so that only their current game mode is visible)"); - } else { - Pair<String, String> lastOnline = Utils.getDurationAsWords(hyPlayerData.getLastLogout()); - - |
