diff options
Diffstat (limited to 'src')
4 files changed, 75 insertions, 29 deletions
diff --git a/src/main/java/eu/olli/cowmoonication/Cowmoonication.java b/src/main/java/eu/olli/cowmoonication/Cowmoonication.java index 3f0ab44..544e692 100644 --- a/src/main/java/eu/olli/cowmoonication/Cowmoonication.java +++ b/src/main/java/eu/olli/cowmoonication/Cowmoonication.java @@ -25,7 +25,7 @@ import java.io.File; updateJSON = "https://raw.githubusercontent.com/cow-mc/Cowmoonication/master/update.json") public class Cowmoonication { public static final String MODID = "cowmoonication"; - public static final String VERSION = "1.8.9-0.3.0"; + public static final String VERSION = "1.8.9-0.3.1"; public static final String MODNAME = "Cowmoonication"; private File modsDir; private MooConfig config; diff --git a/src/main/java/eu/olli/cowmoonication/command/MooCommand.java b/src/main/java/eu/olli/cowmoonication/command/MooCommand.java index e933c30..f265d8a 100644 --- a/src/main/java/eu/olli/cowmoonication/command/MooCommand.java +++ b/src/main/java/eu/olli/cowmoonication/command/MooCommand.java @@ -146,7 +146,7 @@ public class MooCommand extends CommandBase { main.getChatHelper().sendMessage(EnumChatFormatting.RED, "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."); return; } - main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, "Stalking " + EnumChatFormatting.GOLD + playerName + EnumChatFormatting.YELLOW + ". This may take a few seconds."); + main.getChatHelper().sendMessage(EnumChatFormatting.GRAY, "Stalking " + EnumChatFormatting.WHITE + playerName + EnumChatFormatting.GRAY + ". This may take a few seconds."); boolean isBestFriend = main.getFriends().isBestFriend(playerName, true); if (isBestFriend) { Friend stalkedPlayer = main.getFriends().getBestFriend(playerName); @@ -172,7 +172,9 @@ public class MooCommand extends CommandBase { if (hyStalking != null && hyStalking.isSuccess()) { HyStalking.HySession session = hyStalking.getSession(); if (session.isOnline()) { - main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, EnumChatFormatting.GOLD + stalkedPlayer.getName() + EnumChatFormatting.YELLOW + " is currently playing " + session.getGameType() + ": " + session.getMode() + (session.getMap() != null ? " (Map: " + session.getMap() + ")" : "")); + 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 { main.getChatHelper().sendMessage(EnumChatFormatting.YELLOW, EnumChatFormatting.GOLD + stalkedPlayer.getName() + EnumChatFormatting.YELLOW + " is currently " + EnumChatFormatting.RED + "offline" + EnumChatFormatting.YELLOW + " (or deactivated API access)."); } diff --git a/src/main/java/eu/olli/cowmoonication/util/HyStalking.java b/src/main/java/eu/olli/cowmoonication/util/HyStalking.java index a46e1b5..a1f11ae 100644 --- a/src/main/java/eu/olli/cowmoonication/util/HyStalking.java +++ b/src/main/java/eu/olli/cowmoonication/util/HyStalking.java @@ -1,6 +1,6 @@ package eu.olli.cowmoonication.util; -import org.apache.commons.lang3.text.WordUtils; +import org.apache.commons.lang3.StringUtils; public class HyStalking { private boolean success; @@ -41,38 +41,76 @@ public class HyStalking { cleanGameType = GameType.valueOf(gameType).getCleanName(); } catch (IllegalArgumentException e) { // no matching game type found - cleanGameType = WordUtils.capitalizeFully(gameType.replace('_', ' ')); + cleanGameType = Utils.fancyCase(gameType); } return cleanGameType; } public String getMode() { - // list partially taken from https://api.hypixel.net/gameCounts?key=MOO - switch (mode) { + // modes partially taken from https://api.hypixel.net/gameCounts?key=MOO + if (mode == null) { + return null; + } + String gameType = getGameType(); + if (GameType.BEDWARS.cleanName.equals(gameType)) { + // BedWars related + String playerMode; + String specialMode; + int specialModeStart = StringUtils.ordinalIndexOf(mode, "_", 2); + if (specialModeStart > -1) { + playerMode = mode.substring(0, specialModeStart); + specialMode = mode.substring(specialModeStart + 1) + " "; + } else { + playerMode = mode; + specialMode = ""; + } + String playerModeClean; + switch (playerMode) { + case "EIGHT_ONE": + playerModeClean = "Solo"; + break; + case "EIGHT_TWO": + playerModeClean = "Doubles"; + break; + case "FOUR_THREE": + playerModeClean = "3v3v3v3"; + break; + case "FOUR_FOUR": + playerModeClean = "4v4v4v4"; + break; + case "TWO_FOUR": + playerModeClean = "4v4"; + break; + default: + playerModeClean = playerMode; + } + return Utils.fancyCase(specialMode + playerModeClean); + } else if (GameType.SKYBLOCK.cleanName.equals(gameType)) { // SkyBlock related - case "dynamic": - return "Private Island"; - case "hub": - return "Hub"; - case "combat_1": - return "Spider's Den"; - case "combat_2": - return "Blazing Fortress"; - case "combat_3": - return "The End"; - case "farming_1": - return "The Barn"; - case "farming_2": - return "Mushroom Desert"; - case "foraging_1": - return "The Park"; - case "mining_1": - return "Gold Mine"; - case "mining_2": - return "Deep Caverns"; - default: - return WordUtils.capitalizeFully(mode.replace('_', ' ')); + switch (mode) { + case "dynamic": + return "Private Island"; + case "hub": + return "Hub"; + case "combat_1": + return "Spider's Den"; + case "combat_2": + return "Blazing Fortress"; + case "combat_3": + return "The End"; + case "farming_1": + return "The Barn"; + case "farming_2": + return "Mushroom Desert"; + case "foraging_1": + return "The Park"; + case "mining_1": + return "Gold Mine"; + case "mining_2": + return "Deep Caverns"; + } } + return Utils.fancyCase(mode); } public String getMap() { diff --git a/src/main/java/eu/olli/cowmoonication/util/Utils.java b/src/main/java/eu/olli/cowmoonication/util/Utils.java index ec96bf1..dd68cc3 100644 --- a/src/main/java/eu/olli/cowmoonication/util/Utils.java +++ b/src/main/java/eu/olli/cowmoonication/util/Utils.java @@ -1,5 +1,7 @@ package eu.olli.cowmoonication.util; +import org.apache.commons.lang3.text.WordUtils; + import java.util.regex.Pattern; public final class Utils { @@ -16,4 +18,8 @@ public final class Utils { public static boolean isValidMcName(String username) { return VALID_USERNAME.matcher(username).matches(); } + + public static String fancyCase(String string) { + return WordUtils.capitalizeFully(string.replace('_', ' ')); + } } |