diff options
author | Cow <cow@volloeko.de> | 2021-01-03 16:55:34 +0100 |
---|---|---|
committer | Cow <cow@volloeko.de> | 2021-01-03 16:55:34 +0100 |
commit | 59442ae67ed1388003f1b4acbe513367d8df81c9 (patch) | |
tree | d0c0049585abc8f63995250ff5a39faa63a0f845 | |
parent | e20b60fb5791933ebfbd926939312352ae7e357e (diff) | |
download | Cowlection-59442ae67ed1388003f1b4acbe513367d8df81c9.tar.gz Cowlection-59442ae67ed1388003f1b4acbe513367d8df81c9.tar.bz2 Cowlection-59442ae67ed1388003f1b4acbe513367d8df81c9.zip |
Fixed item lookup not working with some bazaar commodities
-rw-r--r-- | src/main/java/de/cowtipper/cowlection/command/MooCommand.java | 2 | ||||
-rw-r--r-- | src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java | 45 |
2 files changed, 29 insertions, 18 deletions
diff --git a/src/main/java/de/cowtipper/cowlection/command/MooCommand.java b/src/main/java/de/cowtipper/cowlection/command/MooCommand.java index 763a2c7..fa58754 100644 --- a/src/main/java/de/cowtipper/cowlection/command/MooCommand.java +++ b/src/main/java/de/cowtipper/cowlection/command/MooCommand.java @@ -880,11 +880,11 @@ public class MooCommand extends CommandBase { public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { if (args.length == 1) { return getListOfStringsMatchingLastWord(args, + /* help */ "help", /* Best friends, friends & other players */ "stalk", "add", "remove", "list", "online", "nameChangeCheck", /* SkyBlock */ "stalkskyblock", "skyblockstalk", "analyzeIsland", "dungeon", /* miscellaneous */ "config", "search", "worldage", "serverage", "guiscale", "rr", "shrug", "apikey", /* update mod */ "update", "updateHelp", "version", "directory", - /* help */ "help", /* rarely used aliases */ "askPolitelyWhereTheyAre", "askPolitelyAboutTheirSkyBlockProgress", "year", "whatyearisit"); } else if (args.length == 2 && args[0].equalsIgnoreCase("remove")) { return getListOfStringsMatchingLastWord(args, main.getFriendsHandler().getBestFriends()); diff --git a/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java b/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java index 524a0c1..632ffa1 100644 --- a/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java +++ b/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java @@ -78,6 +78,9 @@ public class SkyBlockListener { GuiContainer guiContainer = (GuiContainer) e.gui; Slot hoveredSlot = GuiHelper.getSlotUnderMouse(guiContainer); if (hoveredSlot != null && hoveredSlot.getHasStack()) { + String itemBaseName = null; + String querySuffix = ""; + ItemStack itemStack = hoveredSlot.getStack(); NBTTagCompound extraAttributes = itemStack.getSubCompound("ExtraAttributes", false); if (extraAttributes != null && extraAttributes.hasKey("id")) { @@ -86,10 +89,9 @@ public class SkyBlockListener { if (itemLookupType == ItemLookupType.WIKI || (/* itemLookupType == ItemLookupType.PRICE && */ !blackList.contains(sbId) && !sbId.contains("_GENERATOR_"))) { // open item price info or open wiki entry Pair<String, String> sbItemBaseName = Utils.extractSbItemBaseName(itemStack.getDisplayName(), extraAttributes, false); - String itemBaseName = sbItemBaseName.first(); + itemBaseName = sbItemBaseName.first(); // exceptions: - String querySuffix = ""; // remove item count (prefixed or suffixed) Matcher itemCountPrefixMatcher = ITEM_COUNT_PREFIXED_PATTERN.matcher(itemBaseName); Matcher itemCountSuffixMatcher = ITEM_COUNT_SUFFIXED_PATTERN.matcher(itemBaseName); @@ -108,26 +110,35 @@ public class SkyBlockListener { } else if ("CAKE_SOUL".equals(sbId)) { itemBaseName = EnumChatFormatting.LIGHT_PURPLE + "Cake Soul"; } - String link = buildLink(EnumChatFormatting.getTextWithoutFormattingCodes(itemBaseName).trim() + querySuffix, itemLookupType); - if (link == null) { - main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Error: Your operating system doesn't support UTF-8? Huh?"); - return; - } - main.getChatHelper().sendMessage(new MooChatComponent(EnumChatFormatting.DARK_GREEN + " ➡ " - + EnumChatFormatting.GREEN + "Open" + (MooConfig.lookupItemDirectly ? "ing " : " ") + itemLookupType.getDescription() + " for " + itemBaseName).green() - .setUrl(link, itemLookupType.description + ": " + EnumChatFormatting.WHITE + link)); - - if (MooConfig.lookupItemDirectly) { - boolean success = openLink(link); - if (!success) { - main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Error: couldn't open your browser"); - } - } } else { // item is blacklisted from lookup main.getChatHelper().sendMessage(EnumChatFormatting.RED, "⚠ " + EnumChatFormatting.RESET + itemStack.getDisplayName() + EnumChatFormatting.RED + " (" + Utils.fancyCase(sbId) + ") " + itemLookupType.getDescription() + " cannot be looked up."); Minecraft.getMinecraft().thePlayer.playSound("mob.villager.no", Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.MASTER), 1.4f); } + } else { + // check if item is inside Bazaar + List<String> lore = itemStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + if (lore.size() > 5 && lore.get(1).endsWith(" commodity")) { + // item is a Bazaar commodity + itemBaseName = itemStack.getDisplayName(); + } + } + if (itemBaseName != null) { + String link = buildLink(EnumChatFormatting.getTextWithoutFormattingCodes(itemBaseName).trim() + querySuffix, itemLookupType); + if (link == null) { + main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Error: Your operating system doesn't support UTF-8? Huh?"); + return; + } + main.getChatHelper().sendMessage(new MooChatComponent(EnumChatFormatting.DARK_GREEN + " ➡ " + + EnumChatFormatting.GREEN + "Open" + (MooConfig.lookupItemDirectly ? "ing " : " ") + itemLookupType.getDescription() + " for " + itemBaseName).green() + .setUrl(link, itemLookupType.description + ": " + EnumChatFormatting.WHITE + link)); + + if (MooConfig.lookupItemDirectly) { + boolean success = openLink(link); + if (!success) { + main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Error: couldn't open your browser"); + } + } } } } |