commit
This commit is contained in:
parent
497138897e
commit
b285db0d37
16 changed files with 218 additions and 0 deletions
10
.classpath
Normal file
10
.classpath
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
17
.project
Normal file
17
.project
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>ExtremeDemonList</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
2
.settings/org.eclipse.core.resources.prefs
Normal file
2
.settings/org.eclipse.core.resources.prefs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding/<project>=UTF-8
|
14
.settings/org.eclipse.jdt.core.prefs
Normal file
14
.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=17
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=17
|
BIN
bin/data/DownloadLevels.class
Normal file
BIN
bin/data/DownloadLevels.class
Normal file
Binary file not shown.
BIN
bin/data/FetchData.class
Normal file
BIN
bin/data/FetchData.class
Normal file
Binary file not shown.
BIN
bin/data/ManageFiles.class
Normal file
BIN
bin/data/ManageFiles.class
Normal file
Binary file not shown.
BIN
bin/filestructure/CreateFileStructure.class
Normal file
BIN
bin/filestructure/CreateFileStructure.class
Normal file
Binary file not shown.
BIN
bin/main/Main.class
Normal file
BIN
bin/main/Main.class
Normal file
Binary file not shown.
BIN
bin/module-info.class
Normal file
BIN
bin/module-info.class
Normal file
Binary file not shown.
41
src/data/DownloadLevels.java
Normal file
41
src/data/DownloadLevels.java
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
package data;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class DownloadLevels {
|
||||||
|
|
||||||
|
private ManageFiles data = new ManageFiles();
|
||||||
|
|
||||||
|
|
||||||
|
public void download() throws IOException {
|
||||||
|
|
||||||
|
String fileURL;
|
||||||
|
|
||||||
|
for(int i = 0; i < data.missingLevels().size(); i++) {
|
||||||
|
|
||||||
|
System.out.println("downloading " + data.missingLevels().get(i));
|
||||||
|
fileURL = "https://raw.githubusercontent.com/All-Rated-Extreme-Demon-List/AREDL/main/data/" + data.missingLevels().get(i) + ".json";
|
||||||
|
|
||||||
|
try (BufferedInputStream in = new BufferedInputStream(new URL(fileURL).openStream());
|
||||||
|
|
||||||
|
FileOutputStream fileOutputStream = new FileOutputStream("C:\\ExtremeDemonList\\levels\\" + data.missingLevels().get(i) + ".json")) {
|
||||||
|
|
||||||
|
byte dataBuffer[] = new byte[1024];
|
||||||
|
int bytesRead;
|
||||||
|
|
||||||
|
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
|
||||||
|
|
||||||
|
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Handle exceptions
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
42
src/data/FetchData.java
Normal file
42
src/data/FetchData.java
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
package data;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class FetchData {
|
||||||
|
|
||||||
|
private ArrayList<String> levels = new ArrayList<String>();
|
||||||
|
|
||||||
|
public void getGithubString() throws IOException {
|
||||||
|
String link = "https://raw.githubusercontent.com/All-Rated-Extreme-Demon-List/AREDL/main/data/_list.json";
|
||||||
|
|
||||||
|
|
||||||
|
URL url = new URL(link);
|
||||||
|
|
||||||
|
try (BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()))) {
|
||||||
|
|
||||||
|
String line;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
while ((line = in.readLine()) != null) {
|
||||||
|
|
||||||
|
String trimmedLine = line.trim().replace(",", "").replace("\"", "");
|
||||||
|
|
||||||
|
if (!trimmedLine.equals("[") && !trimmedLine.equals("]")) {
|
||||||
|
levels.add(trimmedLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> allLevels() {
|
||||||
|
return levels;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
38
src/data/ManageFiles.java
Normal file
38
src/data/ManageFiles.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package data;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class ManageFiles {
|
||||||
|
|
||||||
|
private FetchData fetch = new FetchData();
|
||||||
|
private static ArrayList<String> missinglevels = new ArrayList<String>(); // fehlende noch zu herunterladende level
|
||||||
|
|
||||||
|
|
||||||
|
private void feedMissingLevelsArray(String levelname) { // fehlende level werden missinglevels hinzugefügt
|
||||||
|
missinglevels.add(levelname);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void compareArrays() throws IOException { // downloadedlevels und onlinelevels werden verglichen und die fehlenden level in missinglevels gepackt
|
||||||
|
|
||||||
|
fetch.getGithubString();
|
||||||
|
|
||||||
|
for(int i = 0; i < fetch.allLevels().size(); i++) {
|
||||||
|
|
||||||
|
File file = new File("C:\\ExtremeDemonList\\levels\\" + fetch.allLevels().get(i) + ".json");
|
||||||
|
|
||||||
|
if(!file.exists()) { // wenn der level lokal nicht vorhanden ist, wird er als fehlend gemeldet.
|
||||||
|
System.out.println(fetch.allLevels().get(i) + " fehlt");
|
||||||
|
feedMissingLevelsArray(fetch.allLevels().get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> missingLevels() { // missinglevels wird zurückgegeben
|
||||||
|
return missinglevels;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
17
src/filestructure/CreateFileStructure.java
Normal file
17
src/filestructure/CreateFileStructure.java
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package filestructure;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class CreateFileStructure {
|
||||||
|
|
||||||
|
public void create() {
|
||||||
|
|
||||||
|
File file = new File("C:\\ExtremeDemonList\\levels");
|
||||||
|
|
||||||
|
if(!file.isDirectory()) {
|
||||||
|
file.mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
29
src/main/Main.java
Normal file
29
src/main/Main.java
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package main;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import data.DownloadLevels;
|
||||||
|
import data.FetchData;
|
||||||
|
import data.ManageFiles;
|
||||||
|
import filestructure.CreateFileStructure;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
|
||||||
|
CreateFileStructure struct = new CreateFileStructure();
|
||||||
|
struct.create();
|
||||||
|
|
||||||
|
FetchData fetch = new FetchData();
|
||||||
|
fetch.getGithubString();
|
||||||
|
|
||||||
|
ManageFiles manager = new ManageFiles();
|
||||||
|
manager.compareArrays();
|
||||||
|
|
||||||
|
DownloadLevels download = new DownloadLevels();
|
||||||
|
download.download();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
8
src/module-info.java
Normal file
8
src/module-info.java
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
module ExtremeDemonList {
|
||||||
|
}
|
Loading…
Reference in a new issue