aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java7
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java44
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Museum.java64
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ItemResolutionQuery.java74
4 files changed, 125 insertions, 64 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
index 6822ab75..4f524c26 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
@@ -54,6 +54,7 @@ import io.github.moulberry.notenoughupdates.options.seperateSections.Mining;
import io.github.moulberry.notenoughupdates.options.seperateSections.MinionHelper;
import io.github.moulberry.notenoughupdates.options.seperateSections.Misc;
import io.github.moulberry.notenoughupdates.options.seperateSections.MiscOverlays;
+import io.github.moulberry.notenoughupdates.options.seperateSections.Museum;
import io.github.moulberry.notenoughupdates.options.seperateSections.NeuAuctionHouse;
import io.github.moulberry.notenoughupdates.options.seperateSections.Notifications;
import io.github.moulberry.notenoughupdates.options.seperateSections.PetOverlay;
@@ -183,6 +184,12 @@ public class NEUConfig extends Config {
@Expose
@Category(
+ name = "Museum",desc = "Musem overlays"
+ )
+ public Museum museum = new Museum();
+
+ @Expose
+ @Category(
name = "GUI Locations",
desc = "Edit the GUI locations of everything here"
)
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java
index f6710514..064a9304 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java
@@ -432,48 +432,4 @@ public class MiscOverlays {
@ConfigAccordionId(id = 0)
public boolean todoIcons = true;
- @ConfigOption(
- name = "Museum Overlay",
- desc = ""
- )
- @ConfigEditorAccordion(id = 1)
- public boolean museumAccordion = true;
-
- @Expose
- @ConfigOption(
- name = "Show Museum Items",
- desc = "Show real items instead of green dye in the museum"
- )
- @ConfigAccordionId(id = 1)
- @ConfigEditorBoolean
- public boolean museumItemShow = true;
-
- @Expose
- @ConfigOption(
- name = "Highlight virtual museum items",
- desc = "Highlight virtual museum items with a background color"
- )
- @ConfigAccordionId(id = 1)
- @ConfigEditorColour
- public String museumItemColor = "0:255:0:255:0";
-
- @Expose
- @ConfigOption(
- name = "Show Items to donate",
- desc = "Show the cheapest items you have not yet donated to the Museum"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
- public boolean museumCheapestItemOverlay = true;
-
- @Expose
- @ConfigOption(
- name = "Value calculation",
- desc = "Choose the source for the value calculation"
- )
- @ConfigEditorDropdown(
- values = {"Lowest BIN", "Craft cost"}
- )
- @ConfigAccordionId(id = 1)
- public int museumCheapestItemOverlayValueSource = 0;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Museum.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Museum.java
new file mode 100644
index 00000000..6f03c2bb
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Museum.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2023 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.options.seperateSections;
+
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
+
+public class Museum {
+
+ @Expose
+ @ConfigOption(
+ name = "Show Museum Items",
+ desc = "Show real items instead of green dye in the museum"
+ )
+ @ConfigEditorBoolean
+ public boolean museumItemShow = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Highlight virtual museum items",
+ desc = "Highlight virtual museum items with a background color"
+ )
+ @ConfigEditorColour
+ public String museumItemColor = "0:255:0:255:0";
+
+ @Expose
+ @ConfigOption(
+ name = "Show Items to donate",
+ desc = "Show the cheapest items you have not yet donated to the Museum"
+ )
+ @ConfigEditorBoolean
+ public boolean museumCheapestItemOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Value calculation",
+ desc = "Choose the source for the value calculation"
+ )
+ @ConfigEditorDropdown(
+ values = {"Lowest BIN", "Craft cost"}
+ )
+ public int museumCheapestItemOverlayValueSource = 0;
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemResolutionQuery.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemResolutionQuery.java
index e5c1b9ad..280a0d3d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemResolutionQuery.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemResolutionQuery.java
@@ -24,6 +24,7 @@ import com.google.gson.JsonParseException;
import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
+import lombok.var;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.inventory.GuiChest;
@@ -36,9 +37,10 @@ import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nullable;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
-import java.util.Map;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -188,31 +190,63 @@ public class ItemResolutionQuery {
return null;
}
+ /**
+ * Search for an item by the display name
+ *
+ * @param displayName The display name of the item we are searching
+ * @param mayBeMangled Whether the item name may be mangled (for example: reforges, stars)
+ * @return the internal neu item id of that item, or null
+ */
+ public static String findInternalNameByDisplayName(String displayName, boolean mayBeMangled) {
+ var cleanDisplayName = StringUtils.cleanColour(displayName);
+ var manager = NotEnoughUpdates.INSTANCE.manager;
+ String bestMatch = null;
+ int bestMatchLength = -1;
+ for (String internalName : findInternalNameCandidatesForDisplayName(cleanDisplayName)) {
+ var item = manager.createItem(internalName);
+ if (item.getDisplayName() == null) continue;
+ var cleanItemDisplayName = StringUtils.cleanColour(item.getDisplayName());
+ if (cleanItemDisplayName.length() == 0) continue;
+ if (mayBeMangled
+ ? !cleanDisplayName.contains(cleanItemDisplayName)
+ : !cleanItemDisplayName.equals(cleanDisplayName)) {
+ continue;
+ }
+ if (cleanItemDisplayName.length() > bestMatchLength) {
+ bestMatchLength = cleanItemDisplayName.length();
+ bestMatch = internalName;
+ }
+ }
+ return bestMatch;
+ }
+
+ /**
+ * Find potential item ids for a given display name. This function is over eager to give results,
+ * and may give invalid results, but if there is a matching item in the repository it will return <em>at least</em>
+ * that item. This should be used as a first filtering pass. Use {@link #findInternalNameByDisplayName} for a more
+ * user-friendly API.
+ *
+ * @param displayName The display name of the item we are searching
+ * @return a list of internal neu item ids some of which may have a matching display name
+ */
+ public static Set<String> findInternalNameCandidatesForDisplayName(String displayName) {
+ var cleanDisplayName = NEUManager.cleanForTitleMapSearch(displayName);
+ var titleWordMap = NotEnoughUpdates.INSTANCE.manager.titleWordMap;
+ var candidates = new HashSet<String>();
+ for (var partialDisplayName : cleanDisplayName.split(" ")) {
+ if (!titleWordMap.containsKey(partialDisplayName)) continue;
+ candidates.addAll(titleWordMap.get(partialDisplayName).keySet());
+ }
+ return candidates;
+ }
+
private String resolveItemInCatacombsRngMeter() {
List<String> lore = ItemUtils.getLore(compound);
if (lore.size() > 16) {
String s = lore.get(15);
if (s.equals("ยง7Selected Drop")) {
String displayName = lore.get(16);
- return getInternalNameByDisplayName(displayName);
- }
- }
-
- return null;
- }
-
- public static String getInternalNameByDisplayName(String displayName) {
- String cleanDisplayName = StringUtils.cleanColour(displayName);
- for (Map.Entry<String, JsonObject> entry : NotEnoughUpdates.INSTANCE.manager
- .getItemInformation()
- .entrySet()) {
-
- JsonObject object = entry.getValue();
- if (object.has("displayname")) {
- String name = object.get("displayname").getAsString();
- if (StringUtils.cleanColour(name).equals(cleanDisplayName)) {
- return entry.getKey();
- }
+ return findInternalNameByDisplayName(displayName, false);
}
}