aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
diff options
context:
space:
mode:
authorRoman / Nea <roman.graef@gmail.com>2022-01-16 01:02:23 +0100
committerGitHub <noreply@github.com>2022-01-15 19:02:23 -0500
commit2aa911fa84399a5a8cc9f36715246c7f3eee7133 (patch)
treeaa4ef88d1fee55727102ff30f97dc157e1744b90 /src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
parent1b43f822ad82efe33b983338f328d52f22d23957 (diff)
downloadnotenoughupdates-2aa911fa84399a5a8cc9f36715246c7f3eee7133.tar.gz
notenoughupdates-2aa911fa84399a5a8cc9f36715246c7f3eee7133.tar.bz2
notenoughupdates-2aa911fa84399a5a8cc9f36715246c7f3eee7133.zip
Fix crafting overlay (#64)
* Fix crafting overlay * bbbbbbbbbbbbbbbbbbbbbbbbbb * Update src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java * Update src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java * Update src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java * Update src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java * Update src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java * Update src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java * Update src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java * Update src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java * Update src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java Co-authored-by: IRONM00N <64110067+IRONM00N@users.noreply.github.com>
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index b3d13351..e5497cd0 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -3,7 +3,7 @@ package io.github.moulberry.notenoughupdates;
import com.google.gson.*;
import io.github.moulberry.notenoughupdates.auction.APIManager;
import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
-import io.github.moulberry.notenoughupdates.overlays.CraftingOverlay;
+import io.github.moulberry.notenoughupdates.recipes.CraftingOverlay;
import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe;
import io.github.moulberry.notenoughupdates.recipes.Ingredient;
import io.github.moulberry.notenoughupdates.recipes.NeuRecipe;
@@ -22,7 +22,8 @@ import org.apache.commons.io.FileUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;
-import javax.swing.*;
+import javax.swing.JDialog;
+import javax.swing.JOptionPane;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
@@ -80,11 +81,14 @@ public class NEUManager {
public File configFile;
public HotmInformation hotm;
+ public CraftingOverlay craftingOverlay;
+
public NEUManager(NotEnoughUpdates neu, File configLocation) {
this.neu = neu;
this.configLocation = configLocation;
this.auctionManager = new APIManager(this);
this.hotm = new HotmInformation(neu);
+ this.craftingOverlay = new CraftingOverlay(this);
GIT_COMMITS_URL = neu.config.hidden.repoCommitsURL;
@@ -127,16 +131,16 @@ public class NEUManager {
public void resetRepo() {
try {
Utils.recursiveDelete(new File(configLocation, "repo"));
- } catch (Exception ignored) {}
+ } catch (Exception ignored) {
+ }
try {
new File(configLocation, "currentCommit.json").delete();
} catch (Exception ignored) {}
}
/**
- * Called when the game is first loaded. Compares the local repository to the github repository and handles
- * the downloading of new/updated files. This then calls the "loadItem" method for every item in the local
- * repository.
+ * Called when the game is first loaded. Compares the local repository to the github repository and handles the
+ * downloading of new/updated files. This then calls the "loadItem" method for every item in the local repository.
*/
public void loadItemInformation() {
/*File repoFile = new File(configLocation, "repo2");
@@ -315,8 +319,8 @@ public class NEUManager {
}
/**
- * Loads the item in to the itemMap and also stores various words associated with this item
- * in to titleWordMap and loreWordMap. These maps are used in the searching algorithm.
+ * Loads the item in to the itemMap and also stores various words associated with this item in to titleWordMap and
+ * loreWordMap. These maps are used in the searching algorithm.
*/
public void loadItem(String internalName) {
itemstackCache.remove(internalName);
@@ -418,8 +422,8 @@ public class NEUManager {
}
/**
- * Searches a string for a query. This method is used to mimic the behaviour of the
- * more complex map-based search function. This method is used for the chest-item-search feature.
+ * Searches a string for a query. This method is used to mimic the behaviour of the more complex map-based search
+ * function. This method is used for the chest-item-search feature.
*/
public boolean searchString(String toSearch, String query) {
int lastMatch = -1;
@@ -443,8 +447,8 @@ public class NEUManager {
}
/**
- * Checks whether an itemstack matches a certain query, following the same rules implemented by the
- * more complex map-based search function.
+ * Checks whether an itemstack matches a certain query, following the same rules implemented by the more complex
+ * map-based search function.
*/
public boolean doesStackMatchSearch(ItemStack stack, String query) {
if (query.startsWith("title:")) {
@@ -498,8 +502,7 @@ public class NEUManager {
}
/**
- * Calls search for each query, separated by |
- * eg. search(A|B) = search(A) + search(B)
+ * Calls search for each query, separated by | eg. search(A|B) = search(A) + search(B)
*/
public Set<String> search(String query, boolean multi) {
if (multi) {
@@ -607,11 +610,10 @@ public class NEUManager {
}
/**
- * Splits a search query into an array of strings delimited by a space character. Then, matches the query to
- * the start of words in the various maps (title & lore). The small query does not need to match the whole entry
- * of the map, only the beginning. eg. "ench" and "encha" will both match "enchanted". All sub queries must
- * follow a word matching the previous sub query. eg. "ench po" will match "enchanted pork" but will not match
- * "pork enchanted".
+ * Splits a search query into an array of strings delimited by a space character. Then, matches the query to the
+ * start of words in the various maps (title & lore). The small query does not need to match the whole entry of the
+ * map, only the beginning. eg. "ench" and "encha" will both match "enchanted". All sub queries must follow a word
+ * matching the previous sub query. eg. "ench po" will match "enchanted pork" but will not match "pork enchanted".
*/
public Set<String> search(String query, TreeMap<String, HashMap<String, List<Integer>>> wordMap) {
HashMap<String, List<Integer>> matches = null;
@@ -850,7 +852,7 @@ public class NEUManager {
if (container != null && container.getLowerChestInventory().getDisplayName().getUnformattedText().equals("Craft Item")) {
Optional<NeuRecipe> recipe = recipesFor.stream().filter(it -> it instanceof CraftingRecipe).findAny();
if (recipe.isPresent()) {
- CraftingOverlay.updateItem((CraftingRecipe) recipe.get());
+ craftingOverlay.setShownRecipe((CraftingRecipe) recipe.get());
return;
}
}
@@ -866,6 +868,10 @@ public class NEUManager {
displayGuiItemRecipe(internalName, "");
}
+ public void showRecipe(String internalName) {
+ showRecipe(getItemInformation().get(internalName));
+ }
+
/**
* Takes an item stack and produces a JsonObject.
*/
@@ -947,7 +953,6 @@ public class NEUManager {
if (!usagesMap.containsKey(internalName)) return false;
Set<NeuRecipe> usages = usagesMap.get(internalName);
if (usages.isEmpty()) return false;
- Utils.sendCloseScreenPacket();
Minecraft.getMinecraft().displayGuiScreen(
new GuiItemRecipe("Item Usages", new ArrayList<>(usages), this));
return true;
@@ -957,7 +962,6 @@ public class NEUManager {
if (!recipesMap.containsKey(internalName)) return false;
Set<NeuRecipe> recipes = recipesMap.get(internalName);
if (recipes.isEmpty()) return false;
- Utils.sendCloseScreenPacket();
Minecraft.getMinecraft().displayGuiScreen(
new GuiItemRecipe(text != null ? text : "Item Recipe", new ArrayList<>(recipes), this));
return true;
@@ -1085,8 +1089,8 @@ public class NEUManager {
}
/**
- * From here to the end of the file are various helper functions for creating and writing json files,
- * in particular json files representing skyblock item data.
+ * From here to the end of the file are various helper functions for creating and writing json files, in particular
+ * json files representing skyblock item data.
*/
public JsonObject createItemJson(String internalname, String itemid, String displayname, String[] lore,
String crafttext, String infoType, String[] info,