aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoman / Linnea Gräf <roman.graef@gmail.com>2022-12-23 17:27:23 +0100
committerGitHub <noreply@github.com>2022-12-23 17:27:23 +0100
commit7535b1f9c24d56522fd9526a8b9ad8940d130995 (patch)
tree8f2877c2e393f561270d296e7283e79737b406e7 /src
parenta7a2293d000a0ff16ddd2413989801a63868da52 (diff)
downloadNotEnoughUpdates-7535b1f9c24d56522fd9526a8b9ad8940d130995.tar.gz
NotEnoughUpdates-7535b1f9c24d56522fd9526a8b9ad8940d130995.tar.bz2
NotEnoughUpdates-7535b1f9c24d56522fd9526a8b9ad8940d130995.zip
RepoEditing: Allow opening files in the external editor (#487)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java29
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java13
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java1
5 files changed, 47 insertions, 7 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index ca0d91d2..ce15b09a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -288,7 +288,7 @@ public class NEUManager {
public void loadItem(String internalName) {
itemstackCache.remove(internalName);
try {
- JsonObject json = getJsonFromFile(new File(new File(repoLocation, "items"), internalName + ".json"));
+ JsonObject json = getJsonFromFile(getItemFileForInternalName(internalName));
if (json == null) {
return;
}
@@ -971,6 +971,10 @@ public class NEUManager {
return getUUIDFromNBT(tag);
}
+ public File getItemFileForInternalName(String internalName) {
+ return new File(new File(repoLocation, "items"), internalName + ".json");
+ }
+
public void writeItemToFile(ItemStack stack) {
String internalname = getInternalNameForItem(stack);
@@ -984,7 +988,7 @@ public class NEUManager {
json.addProperty("modver", NotEnoughUpdates.VERSION);
try {
- writeJson(json, new File(new File(repoLocation, "items"), internalname + ".json"));
+ writeJson(json, getItemFileForInternalName(internalname));
} catch (IOException ignored) {
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index cff83cca..686f6a27 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -46,6 +46,7 @@ import io.github.moulberry.notenoughupdates.util.LerpingFloat;
import io.github.moulberry.notenoughupdates.util.NotificationHandler;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
import io.github.moulberry.notenoughupdates.util.Utils;
+import lombok.var;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
@@ -84,8 +85,10 @@ import org.lwjgl.opengl.GL14;
import org.lwjgl.util.vector.Vector2f;
import java.awt.*;
+import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
@@ -1156,8 +1159,30 @@ public class NEUOverlay extends Gui {
manager.jsonToStack(item));
}
} else if (NotEnoughUpdates.INSTANCE.config.apiData.repositoryEditing &&
- Keyboard.getEventCharacter() == 'k') {
- Minecraft.getMinecraft().displayGuiScreen(new NEUItemEditor(internalname.get(), item));
+ keyPressed == Keyboard.KEY_K) {
+ if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ var externalEditorCommand = NotEnoughUpdates.INSTANCE.config.hidden.externalEditor;
+ if (externalEditorCommand == null) {
+ Utils.addChatMessage(
+ "§e[NEU] §3No external editor set! Run §b/neudevtest exteditor <editorcommand>§3 " +
+ "to set your external editor. Optionally use {} as a placeholder for the filename.");
+ } else {
+ var externalFileName = manager.getItemFileForInternalName(internalname.get()).getAbsolutePath();
+ if (externalEditorCommand.contains("{}")) {
+ externalEditorCommand = externalEditorCommand.replace("{}", externalFileName);
+ } else {
+ externalEditorCommand += " " + externalFileName;
+ }
+ try {
+ Runtime.getRuntime().exec(externalEditorCommand);
+ } catch (IOException e) {
+ Utils.addChatMessage("§e[NEU]§4 Could not open external editor.");
+ e.printStackTrace();
+ }
+ }
+ } else {
+ Minecraft.getMinecraft().displayGuiScreen(new NEUItemEditor(internalname.get(), item));
+ }
return true;
} else if (keyPressed == manager.keybindItemSelect.getKeyCode() &&
NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java
index 69033345..cf266dca 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java
@@ -19,20 +19,17 @@
package io.github.moulberry.notenoughupdates.commands.dev;
-import com.google.gson.Gson;
import io.github.moulberry.notenoughupdates.BuildFlags;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor;
import io.github.moulberry.notenoughupdates.core.util.MiscUtils;
import io.github.moulberry.notenoughupdates.miscfeatures.FishingHelper;
-import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay;
import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes;
import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent;
import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.SpecialBlockZone;
import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager;
-import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.util.PronounDB;
import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.TabListUtils;
@@ -142,6 +139,16 @@ public class DevTestCommand extends ClientCommandBase {
.collect(Collectors.joining("\n"))));
return;
}
+ if (args.length >= 1 && args[0].equalsIgnoreCase("exteditor")) {
+ if (args.length > 1) {
+ NotEnoughUpdates.INSTANCE.config.hidden.externalEditor = String.join(
+ " ",
+ Arrays.copyOfRange(args, 1, args.length)
+ );
+ }
+ Utils.addChatMessage("§e[NEU] §fYour external editor is: §Z" + NotEnoughUpdates.INSTANCE.config.hidden.externalEditor);
+ return;
+ }
if (args.length >= 1 && args[0].equalsIgnoreCase("pricetest")) {
if (args.length == 1) {
NotEnoughUpdates.INSTANCE.manager.auctionManager.updateBazaar();
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 f936ceb1..b5237a46 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
@@ -456,6 +456,9 @@ public class NEUConfig extends Config {
@Expose
public boolean hasOpenedWaypointMenu = false;
+ @Expose
+ public String externalEditor = null;
+
}
public static ArrayList<String> createDefaultEnchantColours() {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
index 7edbee6b..8db06651 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
@@ -357,6 +357,7 @@ public class TimersOverlay extends TextTabOverlay {
String clean = line.replaceAll("(\u00a7.)", "");
String[] cleanSplit = clean.split(" ");
hidden.cookieBuffRemaining = 0;
+ if (line.contains("Not")) break;
for (int i = 0; i + 1 < cleanSplit.length; i++) {
if (i % 2 == 1) continue;