Jar compiling is now possible

This commit is contained in:
Kristian Knarvik 2018-01-26 23:15:19 +01:00
parent 1fafab78b6
commit 55c7c8defd
6 changed files with 43 additions and 33 deletions

View File

@ -0,0 +1,2 @@
java -jar Minecraft-Server-Launcher.jar
pause

View File

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

3
src/META-INF/MANIFEST.MF Normal file
View File

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

View File

@ -11,7 +11,7 @@ import javax.naming.ConfigurationException;
* @version 0.0.0.1
* @since 0.0.0.1
*/
@SuppressWarnings("SpellCheckingInspection")
class Main {
public static void main(String[] args) {
setup();

View File

@ -49,32 +49,33 @@ public class ServerType {
*/
public static void loadServerTypes() throws ConfigurationException {
if (serverTypes.isEmpty()) {
try (Scanner in = new Scanner(new File("config/servertypes.csv"))) {
while (in.hasNextLine()) {
String[] str = in.nextLine().split(";", -1);
int len = str.length;
String[] ver;
if (str[1].contains(",")) {
ver = str[1].split(",", -1);
} else {
ver = new String[]{str[1]};
}
switch (len) {
case 7:
new AdvancedServerType(str[0], ver, str[2], str[3], str[4], str[5], str[6]);
break;
case 3:
new ServerType(str[0], ver, str[2]);
break;
default:
throw new ConfigurationException("Error: Configuration file invalid.");
}
}
Scanner file;
try {
file = new Scanner(new File("config/servertypes.csv"));
} catch (FileNotFoundException e) {
throw new ConfigurationException("Error: Configuration file not found.");
} catch (ArrayIndexOutOfBoundsException e) {
throw new ConfigurationException("Error: Configuration file invalid.");
file = new Scanner(ServerType.class.getResourceAsStream("/config/servertypes.csv"));
}
while (file.hasNextLine()) {
String[] str = file.nextLine().split(";", -1);
int len = str.length;
String[] ver;
if (str[1].contains(",")) {
ver = str[1].split(",", -1);
} else {
ver = new String[]{str[1]};
}
switch (len) {
case 7:
new AdvancedServerType(str[0], ver, str[2], str[3], str[4], str[5], str[6]);
break;
case 3:
new ServerType(str[0], ver, str[2]);
break;
default:
throw new ConfigurationException("Error: Configuration file invalid.");
}
}
} else {
throw new ConfigurationException("Error: Configuration already loaded.");
}

View File

@ -1,8 +1,10 @@
package net.knarcraft.serverlauncher.userinterface;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.io.IOException;
/**
* A class for creating the gui.
@ -15,18 +17,17 @@ public class GUI {
public GUI() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
} catch (ClassNotFoundException | UnsupportedLookAndFeelException | InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
JFrame frame = new JFrame("Minecraft server launcher");
ImageIcon img = new ImageIcon("files/GUIIcon.png");
ImageIcon img;
try {
img = new ImageIcon(ImageIO.read(GUI.class.getResourceAsStream("/files/GUIIcon.png")));
} catch (IOException | IllegalArgumentException e) {
img = new ImageIcon("files/GUIIcon.png");
}
frame.setIconImage(img.getImage());
frame.setLocation(0,0);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);