diff options
Diffstat (limited to 'src/main')
4 files changed, 40 insertions, 18 deletions
diff --git a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java index 0183a76..87f6330 100644 --- a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java +++ b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java @@ -12,6 +12,7 @@ import de.cowtipper.cowlection.util.MooChatComponent; import de.cowtipper.cowlection.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.SoundCategory; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.command.ICommand; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; @@ -98,6 +99,7 @@ public class MooConfig { public static String bestiaryOverviewOrder; private String[] bestiaryOverviewOrderDefaultValues; private static int lookupWikiKeyBinding; + private static String lookupWikiPreferredWiki; private static int lookupPriceKeyBinding; public static boolean lookupItemDirectly; // Category: SkyBlock Dungeons @@ -560,6 +562,8 @@ public class MooConfig { Property propLookupWikiKeyBinding = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), "lookupWikiKeyBinding", Keyboard.KEY_I, "Key to lookup wiki")); + Property propLookupWikiPreferredWiki = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), + "lookupWikiPreferredWiki", "unofficial", "Prefer official or unofficial wiki?", new String[]{"unofficial", "official"})); Property propLookupPriceKeyBinding = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), "lookupPriceKeyBinding", Keyboard.KEY_P, "Key to lookup item price")); @@ -788,6 +792,7 @@ public class MooConfig { bazaarConnectGraphsLineWidth = propBazaarConnectGraphsLineWidth.getInt(); bestiaryOverviewOrder = propBestiaryOverviewOrder.getString(); lookupWikiKeyBinding = propLookupWikiKeyBinding.getInt(); + lookupWikiPreferredWiki = propLookupWikiPreferredWiki.getString(); lookupPriceKeyBinding = propLookupPriceKeyBinding.getInt(); lookupItemDirectly = propLookupItemDirectly.getBoolean(); // Category: SkyBlock Dungeons @@ -881,6 +886,7 @@ public class MooConfig { propBazaarConnectGraphsLineWidth.set(bazaarConnectGraphsLineWidth); propBestiaryOverviewOrder.set(bestiaryOverviewOrder); propLookupWikiKeyBinding.set(lookupWikiKeyBinding); + propLookupWikiPreferredWiki.set(lookupWikiPreferredWiki); propLookupPriceKeyBinding.set(lookupPriceKeyBinding); propLookupItemDirectly.set(lookupItemDirectly); // Category: SkyBlock Dungeons @@ -1103,7 +1109,21 @@ public class MooConfig { return tooltipToggleKeyBinding > 0 && Keyboard.isKeyDown(tooltipToggleKeyBinding); } + /** + * @return true if unofficial wiki is preferred but shift isn't pressed, or if unofficial wiki isn't preferred and shift is pressed + */ public static boolean isLookupWikiKeyBindingPressed() { + return isLookupAnyWikiKeyBindingPressed() && ("unofficial".equals(lookupWikiPreferredWiki) ^ GuiScreen.isShiftKeyDown()); + } + + /** + * @return true if official wiki is preferred but shift isn't pressed, or if official wiki isn't preferred and shift is pressed + */ + public static boolean isLookupOfficialWikiKeyBindingPressed() { + return isLookupAnyWikiKeyBindingPressed() && ("official".equals(lookupWikiPreferredWiki) ^ GuiScreen.isShiftKeyDown()); + } + + private static boolean isLookupAnyWikiKeyBindingPressed() { return lookupWikiKeyBinding > 0 && Keyboard.isKeyDown(lookupWikiKeyBinding); } diff --git a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java index 7c516c6..fd3f0b1 100644 --- a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java +++ b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java @@ -59,7 +59,7 @@ public class MooConfigCategoryScrolling extends GuiListExtended { this.mc = mc; listEntriesPreviews = new TreeMap<>(); - newConfigOptions = Sets.newHashSet("chestAnalyzerShowNpcItems"); + newConfigOptions = Sets.newHashSet("chestAnalyzerShowNpcItems", "lookupWikiKeyBinding", "lookupWikiPreferredWiki", "lookupPriceKeyBinding"); explanations = new HashMap<>(); listEntries = new ArrayList<>(); } 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 4f9b386..b6f05eb 100644 --- a/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java +++ b/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java @@ -91,6 +91,8 @@ public class SkyBlockListener { ItemLookupType itemLookupType; if (MooConfig.isLookupWikiKeyBindingPressed()) { itemLookupType = ItemLookupType.WIKI; + } else if (MooConfig.isLookupOfficialWikiKeyBindingPressed()) { + itemLookupType = ItemLookupType.OFFICIAL_WIKI; } else if (MooConfig.isLookupPriceKeyBindingPressed()) { itemLookupType = ItemLookupType.PRICE; } else { @@ -105,10 +107,11 @@ public class SkyBlockListener { ItemStack itemStack = hoveredSlot.getStack(); NBTTagCompound extraAttributes = itemStack.getSubCompound("ExtraAttributes", false); + String sbId = null; if (extraAttributes != null && extraAttributes.hasKey("id")) { // seems to be a SkyBlock item - String sbId = extraAttributes.getString("id"); - if (itemLookupType == ItemLookupType.WIKI || (/* itemLookupType == ItemLookupType.PRICE && */ !DataHelper.AMBIGUOUS_ITEM_IDS.contains(sbId) && !sbId.contains("_GENERATOR_"))) { + sbId = extraAttributes.getString("id"); + if (itemLookupType == ItemLookupType.WIKI || itemLookupType == ItemLookupType.OFFICIAL_WIKI || (/* itemLookupType == ItemLookupType.PRICE && */ !DataHelper.AMBIGUOUS_ITEM_IDS.contains(sbId) && !sbId.contains("_GENERATOR_"))) { // open item price info or open wiki entry Pair<String, String> sbItemBaseName = Utils.extractSbItemBaseName(itemStack.getDisplayName(), extraAttributes, false); itemBaseName = sbItemBaseName.first(); @@ -146,7 +149,7 @@ public class SkyBlockListener { } } if (itemBaseName != null) { - String link = buildLink(EnumChatFormatting.getTextWithoutFormattingCodes(itemBaseName).trim() + querySuffix, itemLookupType); + String link = itemLookupType.buildLink(sbId, EnumChatFormatting.getTextWithoutFormattingCodes(itemBaseName).trim() + querySuffix); if (link == null) { main.getChatHelper().sendMessage(EnumChatFormatting.RED, "Error: Your operating system doesn't support UTF-8? Huh?"); return; @@ -775,14 +778,6 @@ public class SkyBlockListener { } } - private String buildLink(String itemName, ItemLookupType itemLookupType) { - try { - return itemLookupType.getBaseUrl() + URLEncoder.encode(itemName, "UTF-8"); - } catch (UnsupportedEncodingException ignored) { - } - return null; - } - private boolean openLink(String link) { try { Desktop.getDesktop().browse(new URI(link)); @@ -800,8 +795,9 @@ public class SkyBlockListener { } private enum ItemLookupType { - WIKI("wiki", "https://hypixel-skyblock.fandom.com/wiki/Special:Search?search="), - PRICE("price info", "https://stonks.gg/search?input="), + OFFICIAL_WIKI("official wiki", "https://wiki.hypixel.net/?search="), + WIKI("unofficial wiki", "https://hypixel-skyblock.fandom.com/wiki/Special:Search?search="), + PRICE("price info", "https://sky.coflnet.com/item/"), INVALID("nothing", "https://google.com/search?q="); private final String description; @@ -816,8 +812,12 @@ public class SkyBlockListener { return description; } - public String getBaseUrl() { - return baseUrl; + public String buildLink(String itemId, String itemName) { + try { + return this.baseUrl + (this == PRICE ? itemId : URLEncoder.encode(itemName, "UTF-8")); + } catch (UnsupportedEncodingException ignored) { + } + return null; } } } diff --git a/src/main/resources/assets/cowlection/lang/en_US.lang b/src/main/resources/assets/cowlection/lang/en_US.lang index 2691fe9..5634376 100644 --- a/src/main/resources/assets/cowlection/lang/en_US.lang +++ b/src/main/resources/assets/cowlection/lang/en_US.lang @@ -89,9 +89,11 @@ cowlection.config.bazaarConnectGraphsLineWidth.tooltip=Width of the line drawn t cowlection.config.bestiaryOverviewOrder=§7Bestiary: §roverview order by... cowlection.config.bestiaryOverviewOrder.tooltip=Add §6§lBestiary Overview§r to the SkyBlock Bestiary (§e/bestiary§7 or §e/be§r).\nThis setting changes the order of the Bestiary Overview entries, §7which can also be changed by left-clicking the area/location icon in the Bestiary GUI §7(§e/be§7). cowlection.config.lookupWikiKeyBinding=Key binding: lookup item wiki -cowlection.config.lookupWikiKeyBinding.tooltip=Hover over an item in any inventory and press keybinding to open the item's wiki article.\n§7§oAccesses §e§ohypixel-skyblock.fandom.com\n§7§odefault key: §e§oI = info\n\n§7§odisable key binding: §e§oset key binding to §lESC +cowlection.config.lookupWikiKeyBinding.tooltip=Hover over an item in any inventory and press keybinding to open the item's wiki article.\n§7§oAccesses §e§ohypixel-skyblock.fandom.com §7§oor §e§owiki.hypixel.net\n§7§odefault key: §e§oI = info §7§o(+ optionally §e§oSHIFT§7§o: see setting below)\n\n§7§odisable key binding: §e§oset key binding to §lESC +cowlection.config.lookupWikiPreferredWiki=Prefer which wiki? +cowlection.config.lookupWikiPreferredWiki.tooltip=Official wiki: §ewiki.hypixel.net\n§rUnofficial wiki: §ehypixel-skyblock.fandom.com\n\n§7The §6§opreferred§7 wiki can be used by pressing the §ewiki lookup keybinding§7.\n§7The §6§ounpreferred§7 wiki can be used by pressing the §ewiki lookup keybinding §6+ SHIFT§7. cowlection.config.lookupPriceKeyBinding=Key binding: lookup item price -cowlection.config.lookupPriceKeyBinding.tooltip=Hover over an item in any inventory and press keybinding to open the item's price details.\n§7§oAccesses §e§ostonks.gg\n§7§odefault key: §e§oP = price\n\n§7§odisable key binding: §e§oset key binding to §lESC +cowlection.config.lookupPriceKeyBinding.tooltip=Hover over an item in any inventory and press keybinding to open the item's price details.\n§7§oAccesses §e§osky.coflnet.com\n§7§odefault key: §e§oP = price\n\n§7§odisable key binding: §e§oset key binding to §lESC cowlection.config.lookupItemDirectly=Open website directly? cowlection.config.lookupItemDirectly.tooltip=Should the corresponding website be opened immediately (§a✔§r) or sent as a chat message (§c✘§r)? cowlection.config.showItemQualityAndFloor=Show item quality + obtained floor |