the c, the h, the e, the m

This commit is contained in:
Downforce Agent 2024-05-07 04:26:40 -05:00
parent 4086dfd319
commit 21653702c3
3 changed files with 39 additions and 4 deletions

View File

@ -0,0 +1,8 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="StringOperationCanBeSimplified" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreStringConstructor" value="true" />
</inspection_tool>
</profile>
</component>

View File

@ -21,8 +21,7 @@ import org.json.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.*;
import java.util.*;
import javax.swing.*;

View File

@ -28,6 +28,9 @@ import java.io.IOException;
import java.math.RoundingMode;
import java.nio.file.*;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.regex.Pattern;
import net.lingala.zip4j.*;
import static javax.swing.WindowConstants.EXIT_ON_CLOSE;
@ -161,13 +164,38 @@ public class MissPiggy implements ActionListener {
modList.setVisibleRowCount(Main.Mods.size());
modList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//get current list of mods
//todo: rewrite when modpacks/playlists are added
try {
priorityList = new String(Files.readAllBytes(Paths.get(Main.inpath + "mods/index"))); //let's please stop repasting the config path over and over - refactor this if customizable inpath is implemented
priorityList = new String(Files.readAllBytes(Paths.get(System.getProperty("user.home") + "/.firestar/mods/index")));
} catch (IOException e) {
//new File();
File priorityListFileHandle = new File(System.getProperty("user.home") + "/.firestar/mods/index");
new File(System.getProperty("user.home") + "/.firestar/mods/").mkdirs();
if(!priorityListFileHandle.isFile()){
try {
priorityListFileHandle.createNewFile();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
priorityList = "";
}
// initialize data structures from each list entry
Pattern pattern = Pattern.compile("/[0-9]+=/g");
String[] pListArray = priorityList.split("\n");
Arrays.sort(pListArray);
//int i = 0;
for (String s : pListArray) {
//s.charAt(0);
if (!s.split("=")[0].matches("/[0-9]+=/g")) {
} else {
//append mod to list from substring -- use zip lib
//i++;
}
}
// add text entry for each
int i = 0;
/*JLabel[]*/String[] contents = new String[Main.Mods.size()];