Skip to content

Commit

Permalink
Updates and Stablity, 1.13 ALPHA
Browse files Browse the repository at this point in the history
  • Loading branch information
Puyodead1 committed Dec 10, 2018
0 parents commit 19d9006
Show file tree
Hide file tree
Showing 6 changed files with 617 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
server
ssb.jar
.project
.classpath
.settings
bin
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
V5.0 - After adding output path, press enter, you should see a confirmation message in console.
V5.0 - Freezing

For any issues, use the Issues section or contact me via Discord: Puyodead1#0982 or join the official Discord Server:
https://discord.gg/sSH4yQN
36 changes: 36 additions & 0 deletions src/io/github/puyodead1/SSB/DownloadURL.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.github.puyodead1.SSB;

import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.net.UnknownHostException;

public class DownloadURL {
public static boolean Download(String url, String output) {
try {
downloadUsingStream(url, output);
return true;
} catch (UnknownHostException e) {
SSB.Log("[ERROR]: Unknown Host, please make sure you are connected to the internet and try again.");
return false;
} catch(IOException e) {
SSB.Log("[ERROR]: Unknown Error Occured!");
return false;
}
}

private static void downloadUsingStream(String urlStr, String file) throws IOException{
URL url = new URL(urlStr);
BufferedInputStream bis = new BufferedInputStream(url.openStream());
FileOutputStream fis = new FileOutputStream(file);
byte[] buffer = new byte[1024];
int count=0;
while((count = bis.read(buffer,0,1024)) != -1)
{
fis.write(buffer, 0, count);
}
fis.close();
bis.close();
}
}
244 changes: 244 additions & 0 deletions src/io/github/puyodead1/SSB/MainGUI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
package io.github.puyodead1.SSB;

import java.util.Arrays;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class MainGUI {

protected Shell shlSpigotServerBuilder;
private Text txtOut;
public static String outputPath;
public static String version;
public static Text console;

public static void Rev() {
switch (version) {
case "latest":
SSB.rev = "latest";
break;
case "1.12.2":
SSB.rev = "1.12.2";
break;
case "1.12.1":
SSB.rev = "1.12.1";
break;
case "1.12":
SSB.rev = "1.12";
break;
case "1.11":
SSB.rev = "1.11";
break;
case "1.10":
SSB.rev = "1.10";
break;
case "1.9.4":
SSB.rev = "1.9.4";
break;
case "1.9.2":
SSB.rev = "1.9.2";
break;
case "1.9":
SSB.rev = "1.9";
break;
case "1.8.8":
SSB.rev = "1.8.8";
break;
case "1.8.7":
SSB.rev = "1.8.7";
break;
case "1.8.3":
SSB.rev = "1.8.3";
break;
case "1.8":
SSB.rev = "1.8";
break;
default:
SSB.rev = "latest";
break;
}
}

/**
* Launch the application.
*
* @param args
*/
public static void main(String[] args) {
try {
MainGUI window = new MainGUI();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* Open the window.
*/
public void open() {
Display display = Display.getDefault();
createContents();
shlSpigotServerBuilder.open();
shlSpigotServerBuilder.layout();
while (!shlSpigotServerBuilder.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}

/**
* Create contents of the window.
*/
protected void createContents() {
shlSpigotServerBuilder = new Shell();
shlSpigotServerBuilder.setSize(1220, 780);
shlSpigotServerBuilder.setText("Spigot Server Builder V2.1 by Puyodead1");
shlSpigotServerBuilder.setLayout(null);

List list = new List(shlSpigotServerBuilder, SWT.BORDER);
list.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent arg0) {
String selectedVersion = Arrays.toString(list.getSelection());
switch (selectedVersion) {
case "[latest]":
version = "latest";
break;
case "[1.13]":
version = "1.13";
break;
case "[1.12.2]":
version = "1.12.2";
break;
case "[1.12.1]":
version = "1.12.1";
break;
case "[1.12]":
version = "1.12";
break;
case "[1.11]":
version = "1.11";
break;
case "[1.10]":
version = "1.10";
break;
case "[1.9.4]":
version = "1.9.4";
break;
case "[1.9.2]":
version = "1.9.2";
break;
case "[1.9]":
version = "1.9";
break;
case "[1.8.8]":
version = "1.8.8";
break;
case "[1.8.7]":
version = "1.8.7";
break;
case "[1.8.3]":
version = "1.8.3";
break;
case "[1.8]":
version = "1.8";
break;
}
Rev();
}
});
list.setBounds(34, 31, 63, 207);

Label lblSelectAVersion = new Label(shlSpigotServerBuilder, SWT.NONE);
lblSelectAVersion.setBounds(24, 10, 93, 15);
lblSelectAVersion.setText("Select a version:");

Label lblChooseOutputPath = new Label(shlSpigotServerBuilder, SWT.NONE);
lblChooseOutputPath.setBounds(150, 10, 167, 15);
lblChooseOutputPath.setText("Enter Path to output directory:");

Label lblCopyright = new Label(shlSpigotServerBuilder, SWT.NONE);
lblCopyright.setBounds(15, 250, 300, 15);
lblCopyright.setText("Copyright 2018 Puyodead1 and Puyodead1 Development");

Label lblCompiledOn = new Label(shlSpigotServerBuilder, SWT.NONE);
lblCompiledOn.setBounds(15, 300, 300, 15);
lblCompiledOn.setText("Compiled on 12/09/2018 at 10:11PM EST");

txtOut = new Text(shlSpigotServerBuilder, SWT.BORDER);
txtOut.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent arg0) {
if (arg0.keyCode == 13) {
outputPath = txtOut.getText();
console.append("Set output path to: " + outputPath + "\n");
}
}
});

txtOut.setText("Directory output path");
txtOut.setBounds(160, 32, 126, 21);

Button btnGo = new Button(shlSpigotServerBuilder, SWT.NONE);
btnGo.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e1) {
console.setText(" ");
if (txtOut.getText() != null || txtOut.getText() != "Directory output path") {
outputPath = txtOut.getText();
console.append("Set output path to: " + outputPath + "\n");
}
console.append("Started!\n");
SSB.Init();
}
});
btnGo.setBounds(163, 83, 126, 74);
btnGo.setText("GO!");

Label label = new Label(shlSpigotServerBuilder, SWT.SEPARATOR | SWT.VERTICAL);
label.setBounds(332, 0, 2, 464);

Label lblOutput = new Label(shlSpigotServerBuilder, SWT.NONE);
lblOutput.setAlignment(SWT.CENTER);
lblOutput.setBounds(571, 10, 296, 15);
lblOutput.setText("Output:");

Label label_1 = new Label(shlSpigotServerBuilder, SWT.SEPARATOR | SWT.HORIZONTAL);
label_1.setBounds(123, 59, 211, 2);

Label label_2 = new Label(shlSpigotServerBuilder, SWT.SEPARATOR | SWT.VERTICAL);
label_2.setBounds(123, 0, 2, 246);

Label label_3 = new Label(shlSpigotServerBuilder, SWT.SEPARATOR | SWT.HORIZONTAL);
label_3.setBounds(0, 244, 334, 2);

ScrolledComposite scrolledComposite = new ScrolledComposite(shlSpigotServerBuilder,
SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
scrolledComposite.setBounds(340, 51, 854, 412);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);

console = new Text(scrolledComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL);
console.setEditable(false);
scrolledComposite.setContent(console);
scrolledComposite.setMinSize(console.computeSize(SWT.DEFAULT, SWT.DEFAULT));
String[] versions = { "latest", "1.13", "1.12.2", "1.12.1", "1.12", "1.11", "1.10", "1.9.4", "1.9.2", "1.9",
"1.8.8", "1.8.7", "1.8.3", "1.8" };
for (int i = 0; i < versions.length; i++) {
list.add(versions[i]);
}
}
}
63 changes: 63 additions & 0 deletions src/io/github/puyodead1/SSB/SSB.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package io.github.puyodead1.SSB;

import io.github.puyodead1.SSB.utils.Utils;

public class SSB {
public static String rev;
public static String buildToolsDownloadURL = "https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar";

public static void Log(String log) {
MainGUI.console.append(log + "\n");
}

public static void Init() {
Utils.GetOS();
if (Utils.isWindows()) {
Log("Windows Detected");
InitWindows();
} else if (Utils.isUnix()) {
InitLinux();
} else if(Utils.isMac()) {
SSB.Log("Sorry, Mac is currently unsupported! 0_0 D:");
return;
} else if(Utils.isSolaris()) {
SSB.Log("Sorry, Solaris is currntly unsupported! 0_0 D:");
return;
}else {
SSB.Log("Hm, nice OS, unfortunatly its unsupported 0_0 D:, please contact me and let me know what OS this is so I can possibly add it :D");
return;
}
}

private static void InitWindows() {
Utils.CheckForDirectory(MainGUI.outputPath);
Utils.CheckForDirectory(MainGUI.outputPath + "\\SpigotServer");
Utils.CheckForDirectory(MainGUI.outputPath + "\\BuildTools");
Log("Checking for BuildTools.jar in BuildTools Directory...");
if (!Utils.CheckForBuildTools(MainGUI.outputPath)) {
SSB.Log("GREAT ERROR!");
System.out.println("GREAT ERROR");
return;
}
// BuildTools.jar found and so was an Existing Spigot jar!
System.out.println("DEBUG 1");
Utils.CreateEULA();
Utils.LauncherHandlerWindows();
return;
}

public static void executeScript(String script) {
try {
ProcessBuilder pb = new ProcessBuilder(script);
Process p = pb.start(); // Start the process.
p.waitFor(); // Wait for the process to finish.
System.out.println("Script executed successfully");
} catch (Exception e) {
e.printStackTrace();
}
}

private static void InitLinux() {

}
}
Loading

0 comments on commit 19d9006

Please sign in to comment.