aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/cowtipper/cowlection/config/MooConfig.java20
-rw-r--r--src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java2
-rw-r--r--src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java30
3 files changed, 36 insertions, 16 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;
}
}
}