diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 5f558db..6e1df36 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,7 +1,7 @@ on: push: branches: - - main + - release pull_request: branches: - main diff --git a/pom.xml b/pom.xml index 4b0b0f2..635b6f6 100644 --- a/pom.xml +++ b/pom.xml @@ -8,6 +8,8 @@ 17 17 + UTF-8 + UTF-8 diff --git a/src/data/GuiData.java b/src/data/GuiData.java index 6ff3711..e485b29 100644 --- a/src/data/GuiData.java +++ b/src/data/GuiData.java @@ -21,6 +21,7 @@ public class GuiData { private ArrayList verifier = new ArrayList(); private ArrayList creator = new ArrayList(); private ArrayList ytlink = new ArrayList(); + public ArrayList completed = new ArrayList(); private FetchData data = new FetchData(); @@ -60,7 +61,7 @@ public class GuiData { - public void IndexLevelName() throws IOException { + public void IndexData() throws IOException { FetchData data = new FetchData(); @@ -70,174 +71,25 @@ public class GuiData { String jsonstring; localLength = filelengthindex.length; - - System.out.println(filelengthindex.length); - + for(int i = 0; i < filelengthindex.length; i++) { - - jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + data.allLevels().get(i) + ".json"), StandardCharsets.UTF_8); jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", ""); JSONObject obj = new JSONObject(jsonstring); + JSONArray recordsArray = obj.getJSONArray("records"); localLevels.add(obj.getString("name")); - - - - } - - - - } - - public void IndexLevelID() throws IOException { - - - - File filelength = new File("C:\\ExtremeDemonList\\levels"); - File[] filelengthindex = filelength.listFiles(); - - String jsonstring; - - localLength = filelengthindex.length; - - System.out.println(filelengthindex.length); - - for(int i = 0; i < filelengthindex.length; i++) { - - - - jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + data.allLevels().get(i) + ".json"), StandardCharsets.UTF_8); - jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", ""); - - JSONObject obj = new JSONObject(jsonstring); - id.add(obj.getInt("id") + ""); - - - - } - - } - - public void IndexVerifiers() throws IOException { - - FetchData data = new FetchData(); - - File filelength = new File("C:\\ExtremeDemonList\\levels"); - File[] filelengthindex = filelength.listFiles(); - - String jsonstring; - - localLength = filelengthindex.length; - - System.out.println(filelengthindex.length); - - for(int i = 0; i < filelengthindex.length; i++) { - - - - jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + data.allLevels().get(i) + ".json"), StandardCharsets.UTF_8); - jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", ""); - - JSONObject obj = new JSONObject(jsonstring); - verifier.add(obj.getString("verifier")); - - - - } - - - - } - - public void IndexCreators() throws IOException { - - FetchData data = new FetchData(); - - File filelength = new File("C:\\ExtremeDemonList\\levels"); - File[] filelengthindex = filelength.listFiles(); - - String jsonstring; - - localLength = filelengthindex.length; - - System.out.println(filelengthindex.length); - - for(int i = 0; i < filelengthindex.length; i++) { - - - - jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + data.allLevels().get(i) + ".json"), StandardCharsets.UTF_8); - jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", ""); - - JSONObject obj = new JSONObject(jsonstring); - creator.add(obj.getString("author")); + qualification.add(obj.getInt("percentToQualify") + ""); + ytlink.add(obj.getString("verification") + ""); - } - - - - } - - public void IndexQualification() throws IOException { - - FetchData data = new FetchData(); - - File filelength = new File("C:\\ExtremeDemonList\\levels"); - File[] filelengthindex = filelength.listFiles(); - - String jsonstring; - - localLength = filelengthindex.length; - - System.out.println(filelengthindex.length); - - for(int i = 0; i < filelengthindex.length; i++) { - - - - jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + data.allLevels().get(i) + ".json"), StandardCharsets.UTF_8); - jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", ""); - - JSONObject obj = new JSONObject(jsonstring); - - qualification.add(obj.getInt("percentToQualify") + ""); - } - } - - public ArrayList IndexYoutubeLink() throws IOException { - FetchData data = new FetchData(); - - File filelength = new File("C:\\ExtremeDemonList\\levels"); - File[] filelengthindex = filelength.listFiles(); - - String jsonstring; - - localLength = filelengthindex.length; - - System.out.println(filelengthindex.length); - - for(int i = 0; i < filelengthindex.length; i++) { - - - - jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + data.allLevels().get(i) + ".json"), StandardCharsets.UTF_8); - jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", ""); - - JSONObject obj = new JSONObject(jsonstring); - - ytlink.add(obj.getString("verification") + ""); - } - - return ytlink; - } + } public static ArrayList allVictors(String levelname) throws IOException { ArrayList completed = new ArrayList<>(); @@ -259,7 +111,4 @@ public class GuiData { return completed; } - - - } diff --git a/src/gui/SettingsGui.java b/src/gui/SettingsGui.java new file mode 100644 index 0000000..f54a521 --- /dev/null +++ b/src/gui/SettingsGui.java @@ -0,0 +1,22 @@ +package gui; + +import java.awt.Button; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JFrame; + +import settingsfunctions.DeleteDatabase; + +public class SettingsGui { + + public void showSettings() { + JFrame settings = new JFrame("Einstellungen"); + settings.setLayout(null); + settings.setResizable(false); + settings.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + settings.setSize(500, 500); + settings.setVisible(true); + } + +} diff --git a/src/settingsfunctions/DeleteDatabase.java b/src/settingsfunctions/DeleteDatabase.java new file mode 100644 index 0000000..b66b008 --- /dev/null +++ b/src/settingsfunctions/DeleteDatabase.java @@ -0,0 +1,28 @@ +package settingsfunctions; + +import java.io.File; + +public class DeleteDatabase { + + private void deleter(String database) { + File filelength = new File("C:\\ExtremeDemonList\\" + database); + File[] filelengthindex = filelength.listFiles(); + for(File file : filelengthindex) { + file.delete(); + } + } + + public void deleteCompleted() { + deleter("completed"); + } + + public void deleteUncompleted() { + deleter("levels"); + } + + public void deleteAll() { + deleteCompleted(); + deleteUncompleted(); + } + +}