aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-01 12:08:25 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-01 12:08:25 +0200
commitfb9d2f2633c185faba162d85e4ae71c2a347fbb5 (patch)
tree04b754ad2cb035094f394d3d525baeebd3660d14
parentd0d1de91a163d69976ce113cad0fe49556112e36 (diff)
downloadOneConfig-fb9d2f2633c185faba162d85e4ae71c2a347fbb5.tar.gz
OneConfig-fb9d2f2633c185faba162d85e4ae71c2a347fbb5.tar.bz2
OneConfig-fb9d2f2633c185faba162d85e4ae71c2a347fbb5.zip
improve non-oneconfig mod command finding
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java21
-rw-r--r--src/main/resources/mcmod.info4
2 files changed, 19 insertions, 6 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java
index 444094e..1587a93 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java
@@ -11,6 +11,7 @@ import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import io.polyfrost.oneconfig.utils.ColorUtils;
import io.polyfrost.oneconfig.utils.InputUtils;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.resources.I18n;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraftforge.client.ClientCommandHandler;
@@ -19,6 +20,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.nanovg.NanoVG;
+import java.util.ArrayList;
+
public class ModCard extends BasicElement {
private final String iconPath;
private final Mod modData;
@@ -94,11 +97,21 @@ public class ModCard extends BasicElement {
}
for (ModMetadata mod : OneConfig.loadedOtherMods) {
if (mod.name.equalsIgnoreCase(modData.name)) {
- System.out.println("Attempting to run command for a mod that isn't OneConfig: " + mod.name);
- for (String commands : ClientCommandHandler.instance.getCommands().keySet()) {
- if (commands.equalsIgnoreCase(mod.name) || commands.equalsIgnoreCase(mod.modId)) {
+ ArrayList<String> possibleCommands = new ArrayList<>();
+ possibleCommands.add(mod.name.toLowerCase().replace(" ", ""));
+ possibleCommands.add(mod.modId.toLowerCase().replaceAll("[ -_]", ""));
+ if (mod.name.split(" ").length > 1) {
+ StringBuilder result = new StringBuilder();
+ for (String word : mod.name.split(" ")) {
+ if (word.length() == 0) continue;
+ result.append(word.charAt(0));
+ }
+ possibleCommands.add(result.toString().toLowerCase());
+ }
+ for (String command : ClientCommandHandler.instance.getCommands().keySet()) {
+ if (possibleCommands.contains(command)) {
try {
- ClientCommandHandler.instance.getCommands().get(commands).processCommand(Minecraft.getMinecraft().thePlayer, new String[]{});
+ ClientCommandHandler.instance.getCommands().get(command).processCommand(Minecraft.getMinecraft().thePlayer, new String[]{});
} catch (CommandException e) {
throw new RuntimeException(e);
}
diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info
index 3c1921e..246a086 100644
--- a/src/main/resources/mcmod.info
+++ b/src/main/resources/mcmod.info
@@ -10,8 +10,8 @@
"authorList": [
"MoonTidez",
"DeDiamondPro",
- "nxtdaydelivery"
- "Wyvest"
+ "nxtdaydelivery",
+ "Wyvest"
],
"credits": "",
"logoFile": "",