master
Caleb Fontenot 2022-11-30 00:06:57 +07:00
parent ecf1907b3e
commit 82d8e6f8ca
31 changed files with 280 additions and 16 deletions

Binary file not shown.

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="APPLICATION" />
<option name="description" value="" />
</component>
</project>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

@ -1,4 +1,5 @@
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'java'
id 'application'
}

@ -201,7 +201,7 @@ fi
set -- \
-classpath "$CLASSPATH" \
NULL \
com.calebfontenot.Main \
"$@"
# Use "xargs" to parse quoted args.

@ -71,7 +71,7 @@ set CLASSPATH=%APP_HOME%\lib\Minecraft-Updater-Java-1.0-SNAPSHOT.jar;%APP_HOME%\
@rem Execute Minecraft-Updater-Java
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %MINECRAFT_UPDATER_JAVA_OPTS% -classpath "%CLASSPATH%" NULL %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %MINECRAFT_UPDATER_JAVA_OPTS% -classpath "%CLASSPATH%" com.calebfontenot.Main %*
:end
@rem End local scope for the variables with windows NT shell

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.calebfontenot.Main

File diff suppressed because one or more lines are too long

@ -0,0 +1,51 @@
package com.calebfontenot;
import org.json.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
public class Common {
public static List<String> parse(String fetchURL, String keyToFetch) throws Exception {
//System.out.println("CURLing API...");
URL url = new URL(fetchURL);
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"))) {
for (String line; (line = reader.readLine()) != null; ) {
JSONObject json = new JSONObject(line);
//System.out.println(line);
JSONArray key = json.getJSONArray(keyToFetch);
List<String> returnList = new ArrayList<String>();
for (int i = 0; i < key.length() - 1; i++) {
String returnString = (String) key.get(i);
returnList.add(returnString);
}
return returnList;
}
} catch (Exception IllegalArgumentException) {
return null;
}
return null;
}
public static String rawFetch(String fetchURL) throws Exception {
//System.out.println("CURLing API...");
URL url = new URL(fetchURL);
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"))) {
for (String line; (line = reader.readLine()) != null; ) {
//JSONObject json = new JSONObject(line);
//System.out.println(line);
return line;
}
} catch (Exception IllegalArgumentException) {
System.out.println("Illegal Argument!");
IllegalArgumentException.printStackTrace();
return null;
}
return null;
}
}

@ -1,28 +1,87 @@
package com.calebfontenot;
import java.net.*;
import java.io.*;
import com.calebfontenot.parsers.Velocity;
import java.util.*;
import org.json.*;
public class Main {
//TODO: Move these into the parser classes?
public static final String PAPER_API_URL = "https://api.papermc.io/v2";
public static void main(String[] args) throws Exception {
for (int i = 0; i < args.length; i++) {
System.out.println("args used: " + args[i]);
}
System.out.println("CURLing API...");
URL url = new URL("https://api.papermc.io/v2/projects");
// Check if user passed arguments, if none have been passed, go into interactive mode:
if (args.length == 0) {
menu();
} else if (args[0].equals("download")) {
if (args[1].equals("modrinth")) {
Velocity.fetchVersions(args[2]);
}
}
/*
List<String> projects = Common.parse("https://api.papermc.io/v2/projects", "projects");
System.out.println("The projects returned by Common.parse() are: ");
for(String projectNames:projects) {
System.out.println(projectNames);
}
*/
}
public static void menu() throws Exception {
Scanner input = new Scanner(System.in);
int userInput;
System.out.println("No arguments passed, entering interactive mode!");
System.out.println("Note: Typing '-1' at any point in this menu will exit the program.");
do {
System.out.println("What would you like to do?");
System.out.println("1. Download a jar file from a parser.");
System.out.println("2. Obtain information from an API.");
userInput = input.nextInt();
if (userInput == 1) { // Download
} else if (userInput == 2) { // Obtain info
System.out.println("Selected: Obtain info");
System.out.println("Select which parser to use:");
System.out.println("1. PaperMC (Not finished)");
System.out.println("2. Modrinth");
userInput = input.nextInt();
if (userInput == 1) { // user has selected PaperMC
System.out.println("Available Projects: ");
List<String> projects = Common.parse(PAPER_API_URL + "/projects", "projects");
int i = 1;
for (String projectNames : projects) {
System.out.println(i + ". " + projectNames);
i++;
}
System.out.print("Select project: ");
userInput = input.nextInt();
System.out.println(Common.rawFetch(PAPER_API_URL + "/projects/" + projects.get(userInput - 1)));
}
if (userInput == 2) {
System.out.println("What would you like to do?");
System.out.println("1. Search for mods");
System.out.println("2. Get info about a slug/ID");
userInput = input.nextInt();
if(userInput == 1) {
System.out.print("Enter query:");
String inputString = input.next();
System.out.println(Common.rawFetch(com.calebfontenot.parsers.Velocity.MODRINTH_API_URL + "/search?query=" + inputString));
}
if(userInput == 2) {
System.out.print("Enter slug/ID: ");
String inputString = input.next();
System.out.println(Common.rawFetch(com.calebfontenot.parsers.Velocity.MODRINTH_API_URL + "/project/" + inputString + "/version"));
}
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"))) {
for (String line; (line = reader.readLine()) != null; ) {
JSONObject json = new JSONObject(line);
System.out.println(line);
JSONArray projects = json.getJSONArray("projects");
for (int i = 0; i < projects.length() - 1; i++) {
System.out.println(projects.get(i));
}
}
}
} while (userInput != -1);
}
}

@ -0,0 +1,8 @@
package com.calebfontenot.parsers;
public class PaperMC {
public static String download() {
return "";
}
}

@ -0,0 +1,10 @@
package com.calebfontenot.parsers;
import com.calebfontenot.Common;
public class Velocity {
public static final String MODRINTH_API_URL = "https://api.modrinth.com/v2";
public static void fetchVersions(String modID) throws Exception { // Fetch information about mod versions from the API.
System.out.println(Common.rawFetch(MODRINTH_API_URL + "/project/" + modID + "/version"));
}
}