From 2dd6e0b0ff4df3cc843f4f47a8c0e2fa1d698527 Mon Sep 17 00:00:00 2001 From: Downforce Agent Date: Wed, 3 Jul 2024 16:46:21 -0500 Subject: [PATCH] Fix invisible mod entries (#1) --- src/Clifford.java | 8 ++++++++ src/MissPiggy.java | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Clifford.java b/src/Clifford.java index ad20d7d..c172659 100644 --- a/src/Clifford.java +++ b/src/Clifford.java @@ -139,6 +139,10 @@ public class Clifford implements ActionListener { mod.description = fDescription.getText(); JSONObject container = new JSONObject(); + if (mod.friendlyName.isEmpty()) { + JOptionPane.showMessageDialog(frame, "Mod name cannot be empty.", "Error", JOptionPane.ERROR_MESSAGE); + return; + } container.put("version", mod.version); container.put("friendlyName", mod.friendlyName); container.put("author", mod.author); @@ -158,6 +162,10 @@ public class Clifford implements ActionListener { invoker.InitializeModListInGUI(); frame.dispose(); } else if (actionEvent.getSource() == savebtn && creating) { + if (fName.getText().isEmpty()) { + JOptionPane.showMessageDialog(frame, "Mod name cannot be empty.", "Error", JOptionPane.ERROR_MESSAGE); + return; + } try { Integer.parseInt(fVersion.getText()); } catch (NumberFormatException e) { diff --git a/src/MissPiggy.java b/src/MissPiggy.java index c0bb1a1..b18870b 100644 --- a/src/MissPiggy.java +++ b/src/MissPiggy.java @@ -286,12 +286,14 @@ public class MissPiggy implements ActionListener { /*JLabel[]*/String[] contents = new String[Main.Mods.size()]; System.out.println("Initializing modList to GUI with length of " + Main.Mods.size() + " units"); //debug while (i < Main.Mods.size()) { + if (Main.Mods.get(i).friendlyName == null || Main.Mods.get(i).friendlyName.isEmpty()) + {Main.Mods.get(i).friendlyName = Main.Mods.get(i).path;} if (Main.Mods.get(i).enabled) {contents[i] = Main.Mods.get(i).friendlyName;} else {contents[i] = Main.Mods.get(i).friendlyName + " (Disabled)";} //debug String authorDisplay; - if (Main.Mods.get(i).author == null) {authorDisplay = "Anonymous";} else {authorDisplay = "\"" + Main.Mods.get(i).author + "\"";} + if (Main.Mods.get(i).author == null || Main.Mods.get(i).author.isEmpty()) {authorDisplay = "Anonymous";} else {authorDisplay = "\"" + Main.Mods.get(i).author + "\"";} System.out.println("Added " + Main.Mods.get(i).friendlyName + " by " + authorDisplay); i++; @@ -546,7 +548,7 @@ public class MissPiggy implements ActionListener { modFileSizeStr = String.valueOf(df.format(modFileSize / (1024 * 1024 * 1024))); modFileSizeUnits = "Gigabytes"; } - if (Main.Mods.get(modList.getSelectedIndex()).author == null) { + if (Main.Mods.get(modList.getSelectedIndex()).author == null || Main.Mods.get(modList.getSelectedIndex()).author.isEmpty()) { authorDisplay = "an Unknown Author"; } else { authorDisplay = Main.Mods.get(modList.getSelectedIndex()).author;