diff options
-rw-r--r-- | CHANGELOG.md | 5 | ||||
-rw-r--r-- | build.gradle | 2 | ||||
-rw-r--r-- | src/main/java/eu/olli/cowmoonication/Cowmoonication.java | 2 | ||||
-rw-r--r-- | src/main/java/eu/olli/cowmoonication/command/MooCommand.java | 6 | ||||
-rw-r--r-- | src/main/java/eu/olli/cowmoonication/util/HyStalking.java | 90 | ||||
-rw-r--r-- | src/main/java/eu/olli/cowmoonication/util/Utils.java | 6 | ||||
-rw-r--r-- | update.json | 6 |
7 files changed, 84 insertions, 33 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index f3ca6a2..b55419d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [1.8.9-0.3.1] - 29.03.2020 +### Fixed +- Fixed NullPointer in `/moo stalk` and improved mode output to be more human-readable + ## [1.8.9-0.3.0] - 28.03.2020 ### Added - Added first iteration of Hypixel API integration: @@ -35,6 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). *Note:* The 'best friends' list is currently available via <kbd>ESC</kbd> > Mod Options > Cowmoonication > Config > bestFriends. +[1.8.9-0.3.1]: https://github.com/cow-mc/Cowmoonication/compare/v1.8.9-0.3.0...v1.8.9-0.3.1 [1.8.9-0.3.0]: https://github.com/cow-mc/Cowmoonication/compare/v1.8.9-0.2.0...v1.8.9-0.3.0 [1.8.9-0.2.0]: https://github.com/cow-mc/Cowmoonication/compare/v0.1...v1.8.9-0.2.0 [0.1]: https://github.com/cow-mc/Cowmoonication/releases/tag/v0.1 diff --git a/build.gradle b/build.gradle index c4e1102..b4a79a4 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ plugins { id "net.minecraftforge.gradle.forge" version "2.0.2" } */ -version = "1.8.9-0.3.0" +version = "1.8.9-0.3.1" group= "eu.olli.cowmoonication" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "Cowmoonication" 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('_', ' ')); + } } diff --git a/update.json b/update.json index 44f660f..702129c 100644 --- a/update.json +++ b/update.json @@ -1,10 +1,10 @@ { "homepage": "https://github.com/cow-mc/Cowmoonication/", "1.8.9": { - "1.8.9-0.3.0": "https://github.com/cow-mc/Cowmoonication/blob/master/CHANGELOG.md" + "1.8.9-0.3.1": "https://github.com/cow-mc/Cowmoonication/blob/master/CHANGELOG.md" }, "promos": { - "1.8.9-latest": "1.8.9-0.3.0", - "1.8.9-recommended": "1.8.9-0.3.0" + "1.8.9-latest": "1.8.9-0.3.1", + "1.8.9-recommended": "1.8.9-0.3.1" } } |