SubServers Release v2.11.2b

This commit is contained in:
ME1312 2016-12-29 02:29:22 -05:00
parent 60fc38b5fb
commit d60d6640b5
8 changed files with 129 additions and 82 deletions

Binary file not shown.

View File

@ -4,9 +4,11 @@ import net.ME1312.SubServers.Bungee.Event.SubCreateEvent;
import net.ME1312.SubServers.Bungee.Host.Executable;
import net.ME1312.SubServers.Bungee.Host.Host;
import net.ME1312.SubServers.Bungee.Host.SubCreator;
import net.ME1312.SubServers.Bungee.Host.SubServer;
import net.ME1312.SubServers.Bungee.Library.Config.YAMLConfig;
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
import net.ME1312.SubServers.Bungee.Library.Container;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
import net.ME1312.SubServers.Bungee.Library.UniversalFile;
import net.ME1312.SubServers.Bungee.Library.Util;
import net.ME1312.SubServers.Bungee.Library.Version.Version;
@ -367,6 +369,7 @@ public class InternalSubCreator extends SubCreator {
UniversalFile dir = new UniversalFile(new File(host.getDirectory()), name);
dir.mkdirs();
System.out.println(host.getName() + "/Creator > Generating Server Files...");
if (type == ServerType.SPIGOT) {
exec = new Executable("java -Xmx" + memory + "M -Djline.terminal=jline.UnsupportedTerminal -Dcom.mojang.eula.agree=true -jar Spigot.jar");
@ -396,6 +399,13 @@ public class InternalSubCreator extends SubCreator {
}
} else if (type == ServerType.SPONGE) {
try {
exec = new Executable("java -Xmx" + memory + "M -jar Forge.jar");
GenerateEULA(dir);
GenerateProperties(dir, port);
GenerateSpongeConf(dir);
System.out.println(host.getName() + "/Creator > Searching Versions...");
Document spongexml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(Util.readAll(new BufferedReader(new InputStreamReader(new URL("http://files.minecraftforge.net/maven/org/spongepowered/spongeforge/maven-metadata.xml").openStream(), Charset.forName("UTF-8")))))));
Document forgexml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(Util.readAll(new BufferedReader(new InputStreamReader(new URL("http://files.minecraftforge.net/maven/net/minecraftforge/forge/maven-metadata.xml").openStream(), Charset.forName("UTF-8")))))));
@ -409,6 +419,8 @@ public class InternalSubCreator extends SubCreator {
}
}
}
if (spversion == null) throw new InvalidServerException("Cannot find sponge version for Minecraft " + version.toString());
System.out.println(host.getName() + "/Creator > Found spongeforge-" + spversion.toString());
NodeList mcfnodeList = forgexml.getElementsByTagName("version");
Version mcfversion = null;
@ -420,18 +432,14 @@ public class InternalSubCreator extends SubCreator {
}
}
}
if (mcfversion == null) throw new InvalidServerException("Cannot find forge version for Sponge " + spversion.toString());
System.out.println(host.getName() + "/Creator > Found forge-" + mcfversion.toString());
exec = new Executable("java -Xmx" + memory + "M -jar Forge.jar");
version = new Version(mcfversion.toString() + "::" + spversion.toString());
GenerateEULA(dir);
GenerateProperties(dir, port);
GenerateSpongeConf(dir);
} catch (ParserConfigurationException | IOException | SAXException | NullPointerException e) {
e.printStackTrace();
}
}
try {
InputStream input = null;
OutputStream output = null;
@ -451,7 +459,7 @@ public class InternalSubCreator extends SubCreator {
}
if (!(new File(dir, "build.sh").exists())) {
System.out.println(host.getName() + "/Creator > Problem Copying build.sh!");
System.out.println(host.getName() + "/Creator > Problem copying build.sh");
} else {
File gitBash = new File(this.gitBash, "bin" + File.separatorChar + "bash.exe");
if (!(System.getProperty("os.name").toLowerCase().indexOf("win") >= 0)) {
@ -463,15 +471,15 @@ public class InternalSubCreator extends SubCreator {
e.printStackTrace();
}
if (process.exitValue() != 0) {
System.out.println(host.getName() + "/Creator > Problem Setting Executable Permissions for build.sh");
System.out.println(host.getName() + "/Creator > This may cause errors in the Build Process");
System.out.println(host.getName() + "/Creator > Problem Setting Executable Permissions.");
}
}
System.out.println(host.getName() + "/Creator > Launching build.sh");
this.process = Runtime.getRuntime().exec((System.getProperty("os.name").toLowerCase().indexOf("win") >= 0)?
"\"" + gitBash + "\" --login -i -c \"bash build.sh " + version.toString() + " " + type.toString().toLowerCase() + "\""
:("bash build.sh " + version.toString() + " " + type.toString().toLowerCase() + " " + System.getProperty("user.home")), null, dir);
InternalSubLogger read = new InternalSubLogger(this.process.getInputStream(), host.getName() + "/Creator", new Container<Boolean>(host.plugin.config.get().getSection("Settings").getBoolean("Log-Creator")), new File(dir, "SubCreator-" + type.toString() + "-" + version.toString().replace("::", "@") + ".log"));
InternalSubLogger read = new InternalSubLogger(this.process, host.getName() + "/Creator", new Container<Boolean>(host.plugin.config.get().getSection("Settings").getBoolean("Log-Creator")), new File(dir, "SubCreator-" + type.toString() + "-" + version.toString().replace("::", "@") + ".log"));
read.start();
try {
this.process.waitFor();
@ -481,8 +489,9 @@ public class InternalSubCreator extends SubCreator {
}
if (this.process.exitValue() == 0) {
System.out.println(host.getName() + "/Creator > Saving...");
if (host.plugin.exServers.keySet().contains(name.toLowerCase())) host.plugin.exServers.remove(name.toLowerCase());
host.addSubServer(player, name, true, port, "&aThis is a SubServer", true, "." + File.separatorChar + name, exec, "stop", true, false, false, false, false);
SubServer subserver = host.addSubServer(player, name, true, port, "&aThis is a SubServer", true, "." + File.separatorChar + name, exec, "stop", false, false, false, false, false);
YAMLSection server = new YAMLSection();
server.set("Enabled", true);
@ -500,8 +509,9 @@ public class InternalSubCreator extends SubCreator {
host.plugin.config.get().getSection("Servers").set(name, server);
host.plugin.config.save();
subserver.start(player);
} else {
System.out.println(host.getName() + "/Creator build.sh exited with an errors. Please try again.");
System.out.println(host.getName() + "/Creator > Couldn't build the server jar. See \"SubCreator-" + type.toString() + "-" + version.toString().replace("::", "@") + ".log\" for more details.");
}
}
} catch (IOException e) {

View File

@ -7,67 +7,101 @@ import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class InternalSubLogger extends Thread {
InputStream is;
String name;
Container<Boolean> log;
PrintWriter writer = null;
public class InternalSubLogger {
private Process process;
private String name;
private Container<Boolean> log;
private PrintWriter writer = null;
private boolean started = false;
InternalSubLogger(InputStream is, String name, Container<Boolean> log, File file) {
this.is = is;
InternalSubLogger(Process process, String name, Container<Boolean> log, File file) {
this.process = process;
this.name = name;
this.log = log;
if (file != null)
try {
this.writer = new PrintWriter(file, "UTF-8");
this.writer.println("---------- LOG START: " + name + " ----------");
this.writer.flush();
} catch (UnsupportedEncodingException | FileNotFoundException e) {
e.printStackTrace();
}
}
@Override
public void run() {
try {
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
if (!line.startsWith(">")) {
if (log.get()) {
String msg = line;
// REGEX Formatting
String type = "INFO";
Matcher matcher = Pattern.compile("^((?:\\s*\\[?[0-9]{2}:[0-9]{2}:[0-9]{2}]?)?\\s*(?:\\[|\\[.*\\/)?(INFO|WARN|WARNING|ERROR|ERR|SEVERE)\\]:?\\s*)").matcher(msg);
while (matcher.find()) {
type = matcher.group(2);
}
public void start() {
started = true;
if (writer != null) {
this.writer.println("---------- LOG START: " + name + " ----------");
this.writer.flush();
}
new Thread(() -> {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null;
while ((line = br.readLine()) != null) {
if (!line.startsWith(">")) {
if (log.get()) {
String msg = line;
// REGEX Formatting
String type = "INFO";
Matcher matcher = Pattern.compile("^((?:\\s*\\[?[0-9]{2}:[0-9]{2}:[0-9]{2}]?)?\\s*(?:\\[|\\[.*\\/)?(INFO|WARN|WARNING|ERROR|ERR|SEVERE)\\]:?\\s*)").matcher(msg);
while (matcher.find()) {
type = matcher.group(2);
}
msg = msg.replaceAll("^((?:\\s*\\[?[0-9]{2}:[0-9]{2}:[0-9]{2}]?)?\\s*(?:\\[|\\[.*\\/)?(INFO|WARN|WARNING|ERROR|ERR|SEVERE)\\]:?\\s*)", "");
msg = msg.replaceAll("^((?:\\s*\\[?[0-9]{2}:[0-9]{2}:[0-9]{2}]?)?\\s*(?:\\[|\\[.*\\/)?(INFO|WARN|WARNING|ERROR|ERR|SEVERE)\\]:?\\s*)", "");
switch (type) {
case "INFO":
ProxyServer.getInstance().getLogger().info(name + " > " + msg);
break;
case "WARNING":
case "WARN":
ProxyServer.getInstance().getLogger().warning(name + " > " + msg);
break;
case "SEVERE":
case "ERROR":
case "ERR":
ProxyServer.getInstance().getLogger().severe(name + " > " + msg);
break;
switch (type) {
case "INFO":
ProxyServer.getInstance().getLogger().info(name + " > " + msg);
break;
case "WARNING":
case "WARN":
ProxyServer.getInstance().getLogger().warning(name + " > " + msg);
break;
case "SEVERE":
case "ERROR":
case "ERR":
ProxyServer.getInstance().getLogger().severe(name + " > " + msg);
break;
}
}
if (writer != null) {
writer.println(line);
writer.flush();
}
}
if (writer != null) {
writer.println(line);
writer.flush();
}
}
} catch (IOException ioe) {
} finally {
stop();
}
} catch (IOException ioe) {} finally {
}).start();
new Thread(() -> {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String line;
while ((line = br.readLine()) != null) {
if (!line.startsWith(">")) {
if (log.get()) {
String msg = line;
msg = msg.replaceAll("^((?:\\s*\\[?[0-9]{2}:[0-9]{2}:[0-9]{2}]?)?\\s*(?:\\[|\\[.*\\/)?(INFO|WARN|WARNING|ERROR|ERR|SEVERE)\\]:?\\s*)", "");
ProxyServer.getInstance().getLogger().severe(name + " > " + msg);
}
if (writer != null) {
writer.println(line);
writer.flush();
}
}
}
} catch (IOException ioe) {
} finally {
stop();
}
}).start();
}
private void stop() {
if (started) {
started = false;
if (writer != null) {
writer.println("---------- END LOG ----------");
writer.close();

View File

@ -51,7 +51,7 @@ public class InternalSubServer extends SubServer {
try {
process = Runtime.getRuntime().exec(executable.toString(), null, directory);
System.out.println("SubServers > Now starting " + getName());
final InternalSubLogger read = new InternalSubLogger(process.getInputStream(), getName(), log, null);
final InternalSubLogger read = new InternalSubLogger(process, getName(), log, null);
read.start();
command = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));

View File

@ -1,4 +1,4 @@
# Version: 2.11.2a+
# Version: 2.11.2b+
#
# SubCreator Build Script
# Usage: "bash build.sh <version> <software> [jre]"
@ -16,14 +16,11 @@ if [ -z "$2" ]
rm -Rf $0
exit 1
fi
echo ---------- SERVER BUILD START ----------
if [ $2 == bukkit ] || [ $2 == spigot ]
then
echo Downloading Buildtools...
curl -o BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar; retvalb=$?
if [ $retvalb -eq 0 ]; then
echo Downloaded Buildtools!
else
if ! [ $retvalb -eq 0 ]; then
echo ERROR: Failed Downloading Buildtools. Is SpigotMC.org down?
rm -Rf $0
exit 3
@ -34,27 +31,25 @@ if [ $2 == bukkit ] || [ $2 == spigot ]
fi
mkdir Buildtools
cd "Buildtools"
echo Building CraftBukkit/Spigot Jarfiles...
export MAVEN_OPTS="-Xmx2G"
echo Launching BuildTools.jar
export MAVEN_OPTS="-Xms2G"
if [ -z "$3" ]
then
java -Xmx2G -jar ../BuildTools.jar --rev $1; retvalc=$?
java -Xms2G -jar ../BuildTools.jar --rev $1; retvalc=$?
else
HOME=$3 java -Xmx2G -jar ../BuildTools.jar --rev $1; retvalc=$?
HOME=$3 java -Xms2G -jar ../BuildTools.jar --rev $1; retvalc=$?
fi
cd ../
if [ $retvalc -eq 0 ]; then
echo CraftBukkit/Spigot Jarfiles Built!
echo Copying Final Jar...
if [ $2 == "spigot" ]; then
cp Buildtools/spigot-*.jar Spigot.jar
else
cp Buildtools/craftbukkit-*.jar Craftbukkit.jar
fi
echo Added Jarfiles!
echo Cleaning Up...
rm -Rf BuildTools.jar
rm -Rf Buildtools
echo ---------- END SERVER BUILD ----------
rm -Rf $0
exit 0
else
@ -72,7 +67,7 @@ else
fi
mkdir Buildtools
mkdir Buildtools/Vanilla
echo Downloading Vanilla Server Jarfile
echo Downloading Vanilla Jar...
curl -o Buildtools/Vanilla/minecraft_server.$1.jar https://s3.amazonaws.com/Minecraft.Download/versions/$1/minecraft_server.$1.jar; retvald=$?
if [ $retvald -eq 0 ]; then
echo Downloading Vanilla Patches...
@ -80,16 +75,19 @@ else
if [ $retvale -eq 0 ]; then
echo Patching Vanilla for BungeeCord Support
cd Buildtools/Vanilla
java -jar bungee-patch.jar $1; retvalf=$?;
if [ -z "$3" ]
then
java -jar bungee-patch.jar $1; retvalf=$?;
else
HOME=$3 java -jar bungee-patch.jar $1; retvalf=$?;
fi
if [ $retvalf -eq 0 ]; then
echo Patched Vanilla Jar!
echo Copying Final Jar...
cd ../../
cp Buildtools/Vanilla/out/$1-bungee.jar Buildtools/vanilla-$1.jar
cp Buildtools/Vanilla/out/$1-bungee.jar Vanilla.jar
echo Added Jarfiles!
echo Cleaning Up...
rm -Rf Buildtools
echo ---------- END SERVER BUILD ----------
rm -Rf $0
exit 0
else
@ -114,21 +112,25 @@ else
if [ $2 == "sponge" ]; then
IFS='::' read -r -a version <<< "$1"
sversion=$(echo ${version[@]:1} | tr -d ' ')
echo Downloading Minecraft Forge
echo Downloading Minecraft Forge...
curl -o forge-${version[0]}-installer.jar http://files.minecraftforge.net/maven/net/minecraftforge/forge/${version[0]}/forge-${version[0]}-installer.jar; retvalg=$?
if [ $retvalg -eq 0 ]; then
echo Installing Minecraft Forge Server
java -jar ./forge-${version[0]}-installer.jar --installServer; retvalh=$?
echo Installing Minecraft Forge Server...
if [ -z "$3" ]
then
java -jar ./forge-${version[0]}-installer.jar --installServer; retvalh=$?
else
HOME=$3 java -jar ./forge-${version[0]}-installer.jar --installServer; retvalh=$?
fi
if [ $retvalh -eq 0 ]; then
mkdir ./mods
echo Downloading SpongeForge
echo Downloading SpongeForge...
curl -o mods/Sponge.jar http://files.minecraftforge.net/maven/org/spongepowered/spongeforge/$sversion/spongeforge-$sversion.jar; retvali=$?
if [ $retvali -eq 0 ]; then
echo Cleaning Up...
rm -Rf forge-${version[0]}-installer.jar
rm -Rf forge-${version[0]}-installer.jar.log
mv -f forge-${version[0]}-universal.jar Forge.jar
echo ---------- END SERVER BUILD ----------
rm -Rf $0
exit 0
else
@ -154,4 +156,5 @@ else
fi
fi
fi
echo ERROR: Unknown Server Software
exit 2

View File

@ -36,7 +36,7 @@ public final class SubPlugin extends BungeeCord {
public YAMLConfig lang;
public HashMap<String, String> exLang = new HashMap<String, String>();
public SubDataServer subdata = null;
public final Version version = new Version("2.11.2a");
public final Version version = new Version("2.11.2b");
protected Version bversion = null;
protected boolean running = false;
@ -98,7 +98,7 @@ public final class SubPlugin extends BungeeCord {
} catch (NullPointerException e) {}
brText.close();
if (!Version.equalsIgnoreCase("2.11.2a+")) {
if (!Version.equalsIgnoreCase("2.11.2b+")) {
Files.move(new UniversalFile(dir, "build.sh").toPath(), new UniversalFile(dir, "build.old" + Math.round(Math.random() * 100000) + ".sh").toPath());
Util.copyFromJar(SubPlugin.class.getClassLoader(), "net/ME1312/SubServers/Bungee/Library/Files/build.sh", new UniversalFile(dir, "build.sh").getPath());
System.out.println("SubServers > Updated ~/SubServers/build.sh");

View File

@ -1,6 +1,6 @@
name: 'SubServers'
main: 'net.ME1312.SubServers.Client.Bukkit.SubPlugin'
version: '2.11.2a'
version: '2.11.2b'
authors: [ME1312]
softdepend: [TitleManager]
website: 'http://www.ME1312.net/'