mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-14 14:25:30 +01:00
Better log handling & Forge-related fixes
This commit is contained in:
parent
1533987bf5
commit
81d2d8b14e
@ -28,7 +28,7 @@
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiUtil</artifactId>
|
||||
<version>21w24a</version>
|
||||
<version>21w26a</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -34,7 +34,7 @@
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubData</groupId>
|
||||
<artifactId>Server</artifactId>
|
||||
<version>21w08a</version>
|
||||
<version>21w26a</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -76,7 +76,7 @@ public class ExternalSubCreator extends SubCreator {
|
||||
if (config.getKeys().contains("Display")) template.setDisplayName(config.getString("Display"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(host.getName() + "/Creator > Couldn't load template: " + file.getName());
|
||||
Logger.get(host.getName()).severe("Couldn't load template: " + file.getName());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -74,17 +74,20 @@ public class ExternalSubLogger extends SubLogger {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void log(String type, String msg) {
|
||||
private void log(int type, String msg) {
|
||||
if (started) {
|
||||
Level level;
|
||||
|
||||
// Determine LOG LEVEL
|
||||
switch (type) {
|
||||
case "WARN":
|
||||
case 80:
|
||||
level = Level.FINE;
|
||||
break;
|
||||
case 40:
|
||||
level = Level.WARNING;
|
||||
break;
|
||||
case "SEVERE":
|
||||
case "ERROR":
|
||||
case 30:
|
||||
case 20:
|
||||
level = Level.SEVERE;
|
||||
break;
|
||||
default:
|
||||
|
@ -39,6 +39,8 @@ import java.security.MessageDigest;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static java.util.logging.Level.*;
|
||||
|
||||
/**
|
||||
* Internal SubCreator Class
|
||||
*/
|
||||
@ -90,35 +92,42 @@ public class InternalSubCreator extends SubCreator {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
private ObjectMap<String> build(File dir, ServerTemplate template, List<ServerTemplate> history) throws SubCreatorException {
|
||||
private ObjectMap<String> build(File dir, ServerTemplate template, List<ServerTemplate> history, List<ServerTemplate> stack) throws SubCreatorException {
|
||||
ObjectMap<String> server = new ObjectMap<String>();
|
||||
Version version = this.version;
|
||||
HashMap<String, String> var = new HashMap<String, String>();
|
||||
boolean error = false;
|
||||
if (history.contains(template)) throw new IllegalStateException("Template import loop detected");
|
||||
history.add(template);
|
||||
if (stack.contains(template)) throw new IllegalStateException("Infinite template import loop detected");
|
||||
stack.add(template);
|
||||
for (String other : template.getBuildOptions().getStringList("Import", new ArrayList<String>())) {
|
||||
if (templates.keySet().contains(other.toLowerCase())) {
|
||||
if (templates.get(other.toLowerCase()).isEnabled()) {
|
||||
if (version != null || !templates.get(other.toLowerCase()).requiresVersion()) {
|
||||
if (update == null || templates.get(other.toLowerCase()).canUpdate()) {
|
||||
server.setAll(this.build(dir, templates.get(other.toLowerCase()), history));
|
||||
if (templates.containsKey(other.toLowerCase())) {
|
||||
final ServerTemplate ot = templates.get(other.toLowerCase());
|
||||
if (ot.isEnabled()) {
|
||||
if (version != null || !ot.requiresVersion()) {
|
||||
if (update == null || ot.canUpdate()) {
|
||||
if (!history.contains(ot)) {
|
||||
server.setAll(this.build(dir, ot, history, stack));
|
||||
} else {
|
||||
log.log(WARNING, "Skipping template that is already loaded: " + other);
|
||||
}
|
||||
} else {
|
||||
Logger.get(prefix).warning("Skipping template that cannot be run in update mode: " + other);
|
||||
log.log(WARNING, "Skipping template that cannot be run in update mode: " + other);
|
||||
}
|
||||
} else {
|
||||
Logger.get(prefix).warning("Skipping template that requires extra versioning information: " + other);
|
||||
log.log(WARNING, "Skipping template that requires extra versioning information: " + other);
|
||||
}
|
||||
} else {
|
||||
Logger.get(prefix).warning("Skipping disabled template: " + other);
|
||||
log.log(WARNING, "Skipping disabled template: " + other);
|
||||
}
|
||||
} else {
|
||||
Logger.get(prefix).warning("Skipping missing template: " + other);
|
||||
log.log(WARNING, "Skipping missing template: " + other);
|
||||
}
|
||||
}
|
||||
history.add(template);
|
||||
stack.remove(template);
|
||||
server.setAll(template.getConfigOptions());
|
||||
try {
|
||||
Logger.get(prefix).info("Loading" + ((template.isDynamic())?" Dynamic":"") + " Template: " + template.getDisplayName());
|
||||
log.log(INFO, "Loading" + ((template.isDynamic())?" Dynamic":"") + " Template: " + template.getDisplayName());
|
||||
updateDirectory(template.getDirectory(), dir, template.getBuildOptions().getBoolean("Update-Files", false));
|
||||
|
||||
for (ObjectMapValue<String> replacement : template.getBuildOptions().getMap("Replacements", new ObjectMap<>()).getValues()) if (!replacement.isNull()) {
|
||||
@ -142,7 +151,7 @@ public class InternalSubCreator extends SubCreator {
|
||||
case SPONGE:
|
||||
case FORGE:
|
||||
if (version != null) {
|
||||
Logger.get(prefix).info("Searching Versions...");
|
||||
log.log(INFO, "Searching Versions...");
|
||||
ObjectMap<String> spversionmanifest = new ObjectMap<String>(new Gson().fromJson("{\"versions\":" + Util.readAll(new BufferedReader(new InputStreamReader(new URL("https://dl-api.spongepowered.org/v1/org.spongepowered/sponge" + ((template.getType() == ServerType.FORGE)?"forge":"vanilla") + "/downloads?type=stable&minecraft=" + version).openStream(), Charset.forName("UTF-8")))) + '}', Map.class));
|
||||
|
||||
ObjectMap<String> spprofile = null;
|
||||
@ -155,11 +164,11 @@ public class InternalSubCreator extends SubCreator {
|
||||
}
|
||||
if (spversion == null)
|
||||
throw new InvalidServerException("Cannot find Sponge version for Minecraft " + version.toString());
|
||||
Logger.get(prefix).info("Found \"sponge" + ((template.getType() == ServerType.FORGE)?"forge":"vanilla") + "-" + spversion.toString() + '"');
|
||||
log.log(INFO, "Found \"sponge" + ((template.getType() == ServerType.FORGE)?"forge":"vanilla") + "-" + spversion.toString() + '"');
|
||||
|
||||
if (template.getType() == ServerType.FORGE) {
|
||||
Version mcfversion = new Version(((spprofile.getMap("dependencies").getRawString("forge").contains("-"))?"":spprofile.getMap("dependencies").getRawString("minecraft") + '-') + spprofile.getMap("dependencies").getRawString("forge"));
|
||||
Logger.get(prefix).info("Found \"forge-" + mcfversion.toString() + '"');
|
||||
log.log(INFO, "Found \"forge-" + mcfversion.toString() + '"');
|
||||
|
||||
var.put("mcf_version", mcfversion.toString());
|
||||
}
|
||||
@ -181,16 +190,16 @@ public class InternalSubCreator extends SubCreator {
|
||||
var.put("source", dir.getAbsolutePath());
|
||||
|
||||
try {
|
||||
Logger.get(prefix).info("Launching Build Script...");
|
||||
log.log(INFO, "Launching Build Script...");
|
||||
ProcessBuilder pb = new ProcessBuilder().command(Executable.parse(gitBash, template.getBuildOptions().getRawString("Executable"))).directory(dir);
|
||||
pb.environment().putAll(var);
|
||||
process = pb.start();
|
||||
log.file = new File(dir, "SubCreator-" + template.getName() + ((version != null)?"-"+version.toString():"") + ".log");
|
||||
process = pb.start();
|
||||
log.process = process;
|
||||
log.start();
|
||||
|
||||
process.waitFor();
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(250);
|
||||
|
||||
if (process.exitValue() != 0) error = true;
|
||||
} catch (InterruptedException e) {
|
||||
@ -233,12 +242,15 @@ public class InternalSubCreator extends SubCreator {
|
||||
ObjectMap<String> server = new ObjectMap<String>();
|
||||
ObjectMap<String> config;
|
||||
try {
|
||||
config = build(dir, template, new LinkedList<>());
|
||||
log.init();
|
||||
config = build(dir, template, new LinkedList<>(), new LinkedList<>());
|
||||
} catch (SubCreatorException e) {
|
||||
config = null;
|
||||
} catch (Exception e) {
|
||||
config = null;
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
log.destroy();
|
||||
}
|
||||
|
||||
declaration.run();
|
||||
@ -364,7 +376,7 @@ public class InternalSubCreator extends SubCreator {
|
||||
if (config.getKeys().contains("Display")) template.setDisplayName(config.getString("Display"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.get(host.getName() + File.separator + "Creator").info("Couldn't load template: " + file.getName());
|
||||
Logger.get(host.getName()).severe("Couldn't load template: " + file.getName());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,16 @@ public class InternalSubLogger extends SubLogger {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
void init() {
|
||||
List<SubLogFilter> filters = new ArrayList<SubLogFilter>();
|
||||
filters.addAll(this.filters);
|
||||
for (SubLogFilter filter : filters) try {
|
||||
filter.start();
|
||||
} catch (Throwable e) {
|
||||
new InvocationTargetException(e, "Exception while running SubLogger Event").printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
started = true;
|
||||
@ -62,13 +72,6 @@ public class InternalSubLogger extends SubLogger {
|
||||
}
|
||||
if (out == null) (out = new Thread(() -> start(process.getInputStream(), false), "SubServers.Bungee::Internal_Log_Spooler(" + name + ')')).start();
|
||||
if (err == null) (err = new Thread(() -> start(process.getErrorStream(), true), "SubServers.Bungee::Internal_Error_Spooler(" + name + ')')).start();
|
||||
List<SubLogFilter> filters = new ArrayList<SubLogFilter>();
|
||||
filters.addAll(this.filters);
|
||||
for (SubLogFilter filter : filters) try {
|
||||
filter.start();
|
||||
} catch (Throwable e) {
|
||||
new InvocationTargetException(e, "Exception while running SubLogger Event").printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -124,19 +127,7 @@ public class InternalSubLogger extends SubLogger {
|
||||
level = Level.INFO;
|
||||
}
|
||||
|
||||
// Filter Message
|
||||
boolean allow = (SubAPI.getInstance().getInternals().sudo == getHandler() && SubAPI.getInstance().getInternals().canSudo) || (log.value() && (SubAPI.getInstance().getInternals().sudo == null || !SubAPI.getInstance().getInternals().canSudo));
|
||||
List<SubLogFilter> filters = new ArrayList<SubLogFilter>();
|
||||
filters.addAll(this.filters);
|
||||
for (SubLogFilter filter : filters)
|
||||
try {
|
||||
allow = (filter.log(level, msg) && allow);
|
||||
} catch (Throwable e) {
|
||||
new InvocationTargetException(e, "Exception while running SubLogger Event").printStackTrace();
|
||||
}
|
||||
|
||||
// Log to CONSOLE
|
||||
if (allow) Logger.get(name).log(level, msg);
|
||||
log(level, msg);
|
||||
|
||||
// Log to FILE
|
||||
if (writer != null) {
|
||||
@ -146,15 +137,56 @@ public class InternalSubLogger extends SubLogger {
|
||||
}
|
||||
}
|
||||
|
||||
void log(Level level, String message) {
|
||||
// Filter Message
|
||||
boolean allow = (SubAPI.getInstance().getInternals().sudo == getHandler() && SubAPI.getInstance().getInternals().canSudo) || (log.value() && (SubAPI.getInstance().getInternals().sudo == null || !SubAPI.getInstance().getInternals().canSudo));
|
||||
List<SubLogFilter> filters = new ArrayList<SubLogFilter>();
|
||||
filters.addAll(this.filters);
|
||||
for (SubLogFilter filter : filters) {
|
||||
try {
|
||||
allow = (filter.log(level, message) && allow);
|
||||
} catch (Throwable e) {
|
||||
new InvocationTargetException(e, "Exception while running SubLogger Event").printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Log to CONSOLE
|
||||
if (allow || !started) {
|
||||
Logger.get(name).log(level, message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
try {
|
||||
if (out != null) out.interrupt();
|
||||
if (err != null) err.interrupt();
|
||||
destroy();
|
||||
if (started) {
|
||||
started = false;
|
||||
if (writer != null) {
|
||||
PrintWriter writer = this.writer;
|
||||
this.writer = null;
|
||||
int l = (int) Math.floor((("---------- LOG START \u2014 " + name + " ----------").length() - 9) / 2);
|
||||
String s = "";
|
||||
while (s.length() < l) s += '-';
|
||||
if (writer != null) {
|
||||
writer.println(s + " LOG END " + s);
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException e) {}
|
||||
}
|
||||
|
||||
void destroy() {
|
||||
filters.addAll(this.filters);
|
||||
for (SubLogFilter filter : filters) try {
|
||||
filter.stop();
|
||||
} catch (Throwable e) {
|
||||
new InvocationTargetException(e, "Exception while running SubLogger Event").printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerFilter(SubLogFilter filter) {
|
||||
if (Util.isNull(filter)) throw new NullPointerException();
|
||||
@ -167,30 +199,6 @@ public class InternalSubLogger extends SubLogger {
|
||||
Util.isException(() -> filters.remove(filter));
|
||||
}
|
||||
|
||||
private void destroy() {
|
||||
if (started) {
|
||||
started = false;
|
||||
List<SubLogFilter> filters = new ArrayList<SubLogFilter>();
|
||||
filters.addAll(this.filters);
|
||||
for (SubLogFilter filter : filters) try {
|
||||
filter.stop();
|
||||
} catch (Throwable e) {
|
||||
new InvocationTargetException(e, "Exception while running SubLogger Event").printStackTrace();
|
||||
}
|
||||
if (writer != null) {
|
||||
PrintWriter writer = this.writer;
|
||||
this.writer = null;
|
||||
int l = (int) Math.floor((("---------- LOG START \u2014 " + name + " ----------").length() - 9) / 2);
|
||||
String s = "";
|
||||
while (s.length() < l) s += '-';
|
||||
if (writer != null) {
|
||||
writer.println(s + " LOG END " + s);
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getHandler() {
|
||||
return handle;
|
||||
|
@ -155,6 +155,7 @@ public class InternalSubServer extends SubServerImpl {
|
||||
pb.environment().put("host", host.getName());
|
||||
pb.environment().put("address", host.getAddress().getHostAddress());
|
||||
pb.environment().put("port", Integer.toString(getAddress().getPort()));
|
||||
logger.init();
|
||||
process = pb.start();
|
||||
Logger.get("SubServers").info("Now starting " + getName());
|
||||
logger.process = process;
|
||||
@ -174,6 +175,7 @@ public class InternalSubServer extends SubServerImpl {
|
||||
allowrestart = false;
|
||||
}
|
||||
|
||||
logger.destroy();
|
||||
Logger.get("SubServers").info(getName() + " has stopped");
|
||||
process = null;
|
||||
command = null;
|
||||
|
@ -23,11 +23,14 @@ public class PacketInExLogMessage implements PacketObjectIn<Integer> {
|
||||
@Override
|
||||
public void receive(SubDataClient client, ObjectMap<Integer> data) {
|
||||
try {
|
||||
if (data.contains(0x0000) && loggers.keySet().contains(data.getUUID(0x0000))) {
|
||||
if (data.contains(0x0001) && data.contains(0x0002)) {
|
||||
Util.reflect(ExternalSubLogger.class.getDeclaredMethod("log", String.class, String.class), loggers.get(data.getUUID(0x0000)), data.getRawString(0x0001), data.getRawString(0x0002));
|
||||
if (data.contains(0x0000)) {
|
||||
if (data.contains(0x0002) && data.contains(0x0001)) {
|
||||
if (loggers.containsKey(data.getUUID(0x0000))) {
|
||||
Util.reflect(ExternalSubLogger.class.getDeclaredMethod("log", int.class, String.class), loggers.get(data.getUUID(0x0000)), data.getInt(0x0001), data.getRawString(0x0002));
|
||||
}
|
||||
} else {
|
||||
unregister(data.getUUID(0x0000));
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -58,6 +61,6 @@ public class PacketInExLogMessage implements PacketObjectIn<Integer> {
|
||||
* @param id External Address
|
||||
*/
|
||||
public static void unregister(UUID id) {
|
||||
loggers.remove(id).stop();
|
||||
if (loggers.containsKey(id)) loggers.remove(id).stop();
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.ME1312.SubServers.Client.Common.Network.Packet.*;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.util.HashMap;
|
||||
@ -118,7 +119,7 @@ public class SubProtocol extends SubDataProtocol {
|
||||
log.setUseParentHandlers(false);
|
||||
log.addHandler(new Handler() {
|
||||
private boolean open = true;
|
||||
private String prefix = "SubData" + ((channel != 0)?"/+"+channel:"");
|
||||
private String prefix = "SubData" + ((channel != 0)?File.separator+"+"+channel:"");
|
||||
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
|
@ -18,13 +18,13 @@
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiUtil</artifactId>
|
||||
<version>21w24a</version>
|
||||
<version>21w26a</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubData</groupId>
|
||||
<artifactId>Client</artifactId>
|
||||
<version>21w08a</version>
|
||||
<version>21w26a</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -18,6 +18,7 @@ import net.ME1312.SubServers.Client.Sponge.SubPlugin;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.spongepowered.api.Sponge;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.util.HashMap;
|
||||
@ -119,7 +120,7 @@ public class SubProtocol extends SubDataProtocol {
|
||||
Logger log = Logger.getAnonymousLogger();
|
||||
log.setUseParentHandlers(false);
|
||||
log.addHandler(new Handler() {
|
||||
private org.slf4j.Logger log = LoggerFactory.getLogger("SubData" + ((channel != 0)? "/+"+channel:""));
|
||||
private org.slf4j.Logger log = LoggerFactory.getLogger("SubData" + ((channel != 0)?File.separator+"+"+channel:""));
|
||||
private boolean open = true;
|
||||
|
||||
@Override
|
||||
|
@ -15,7 +15,7 @@ function __DL() {
|
||||
if [[ -x "$(command -v wget)" ]]; then
|
||||
wget -O "$1" "$2"; return $?
|
||||
else
|
||||
curl -o "$1" "$2"; return $?
|
||||
curl -Lo "$1" "$2"; return $?
|
||||
fi
|
||||
}
|
||||
function __Restore() {
|
||||
@ -33,46 +33,72 @@ function __Restore() {
|
||||
fi
|
||||
}
|
||||
echo Downloading the Minecraft Forge Installer...
|
||||
__DL "forge-$mcf_version-installer.jar" "http://files.minecraftforge.net/maven/net/minecraftforge/forge/$mcf_version/forge-$mcf_version-installer.jar"; __RETURN=$?
|
||||
__DL "forge-$mcf_version-installer.jar" "https://files.minecraftforge.net/maven/net/minecraftforge/forge/$mcf_version/forge-$mcf_version-installer.jar"; __RETURN=$?
|
||||
if [[ $__RETURN -eq 0 ]]; then
|
||||
echo Installing Minecraft Forge...
|
||||
"$java" -jar "forge-$mcf_version-installer.jar" --installServer; __RETURN=$?
|
||||
echo ""
|
||||
echo Downloading the Minecraft Forge Installer Installer...
|
||||
__DL "forge-installer-installer.jar" "https://dev.me1312.net/jenkins/job/Forge%20Installer%20Installer/lastSuccessfulBuild/artifact/artifacts/forge-installer-installer.jar"; __RETURN=$?
|
||||
if [[ $__RETURN -eq 0 ]]; then
|
||||
echo Cleaning Up...
|
||||
if [[ ! -d "mods" ]]; then
|
||||
mkdir mods
|
||||
fi
|
||||
rm -Rf "forge-$mcf_version-installer.jar"
|
||||
rm -Rf "forge-$mcf_version-installer.jar.log"
|
||||
mv -f "forge-$mcf_version-universal.jar" Forge.jar
|
||||
echo Downloading SpongeForge...
|
||||
if [[ -f "mods/Sponge.jar" ]]; then
|
||||
if [[ -f "mods/Sponge.old.jar.x" ]]; then
|
||||
rm -Rf mods/Sponge.old.jar.x
|
||||
fi
|
||||
mv mods/Sponge.jar mods/Sponge.old.jar.x
|
||||
fi
|
||||
__DL mods/Sponge.jar "https://repo.spongepowered.org/maven/org/spongepowered/spongeforge/$sp_version/spongeforge-$sp_version.jar"; __RETURN=$?
|
||||
echo Launching Minecraft Forge Installer Installer
|
||||
"$java" -jar "forge-installer-installer.jar" "forge-$mcf_version-installer.jar"; __RETURN=$?
|
||||
if [[ $__RETURN -eq 0 ]]; then
|
||||
echo Cleaning Up...
|
||||
rm -Rf "$0"
|
||||
exit 0
|
||||
rm -Rf "forge-installer-installer.jar"
|
||||
echo Installing Minecraft Forge...
|
||||
"$java" -jar "forge-$mcf_version-installer.jar" --installServer; __RETURN=$?
|
||||
if [[ $__RETURN -ne 0 ]]; then
|
||||
echo ""
|
||||
echo Retrying...
|
||||
"$java" -jar "forge-$mcf_version-installer.jar" --installServer --offline; __RETURN=$?
|
||||
fi
|
||||
if [[ $__RETURN -eq 0 ]]; then
|
||||
echo Cleaning Up...
|
||||
if [[ ! -d "mods" ]]; then
|
||||
mkdir mods
|
||||
fi
|
||||
rm -Rf "forge-$mcf_version-installer.jar"
|
||||
rm -Rf "forge-$mcf_version-installer.jar.log"
|
||||
mv -f "forge-$mcf_version-universal.jar" Forge.jar
|
||||
echo Downloading SpongeForge...
|
||||
if [[ -f "mods/Sponge.jar" ]]; then
|
||||
if [[ -f "mods/Sponge.old.jar.x" ]]; then
|
||||
rm -Rf mods/Sponge.old.jar.x
|
||||
fi
|
||||
mv mods/Sponge.jar mods/Sponge.old.jar.x
|
||||
fi
|
||||
__DL mods/Sponge.jar "https://repo.spongepowered.org/maven/org/spongepowered/spongeforge/$sp_version/spongeforge-$sp_version.jar"; __RETURN=$?
|
||||
if [[ $__RETURN -eq 0 ]]; then
|
||||
echo Cleaning Up...
|
||||
rm -Rf "$0"
|
||||
exit 0
|
||||
else
|
||||
echo ERROR: Failed downloading Sponge. Is SpongePowered.org down?
|
||||
__Restore
|
||||
rm -Rf "$0"
|
||||
exit 7
|
||||
fi
|
||||
else
|
||||
echo ERROR: The Forge Installer exited with an error. Please try again
|
||||
__Restore
|
||||
rm -Rf "forge-$mcf_version-installer.jar"
|
||||
rm -Rf "forge-$mcf_version-installer.jar.log"
|
||||
rm -Rf "$0"
|
||||
exit 6
|
||||
fi
|
||||
else
|
||||
echo ERROR: Failed downloading Sponge. Is SpongePowered.org down?
|
||||
__Restore
|
||||
rm -Rf "forge-$mcf_version-installer.jar"
|
||||
rm -Rf "forge-installer-installer.jar"
|
||||
rm -Rf "$0"
|
||||
echo ERROR: The Forge Installer Installer exited with an error. Please try again
|
||||
exit 5
|
||||
fi
|
||||
else
|
||||
echo ERROR: The Installer exited with an error. Please try again
|
||||
__Restore
|
||||
echo ERROR: Failed downloading the Forge Installer Installer. Is ME1312.net down?
|
||||
rm -Rf "forge-$mcf_version-installer.jar"
|
||||
rm -Rf "forge-$mcf_version-installer.jar.log"
|
||||
rm -Rf "$0"
|
||||
exit 4
|
||||
fi
|
||||
else
|
||||
echo ERROR: Failed downloading Forge. Is MinecraftForge.net down?
|
||||
echo ERROR: Failed downloading the Forge Installer. Is MinecraftForge.net down?
|
||||
rm -Rf "$0"
|
||||
exit 3
|
||||
fi
|
||||
|
@ -11,7 +11,7 @@ function __DL() {
|
||||
if [[ -x "$(command -v wget)" ]]; then
|
||||
wget -O "$1" "$2"; return $?
|
||||
else
|
||||
curl -o "$1" "$2"; return $?
|
||||
curl -Lo "$1" "$2"; return $?
|
||||
fi
|
||||
}
|
||||
function __Restore() {
|
||||
|
@ -11,7 +11,7 @@ function __DL() {
|
||||
if [[ -x "$(command -v wget)" ]]; then
|
||||
wget -O "$1" "$2"; return $?
|
||||
else
|
||||
curl -o "$1" "$2"; return $?
|
||||
curl -Lo "$1" "$2"; return $?
|
||||
fi
|
||||
}
|
||||
function __Restore() {
|
||||
|
@ -15,7 +15,7 @@ function __DL() {
|
||||
if [[ -x "$(command -v wget)" ]]; then
|
||||
wget -O "$1" "$2"; return $?
|
||||
else
|
||||
curl -o "$1" "$2"; return $?
|
||||
curl -Lo "$1" "$2"; return $?
|
||||
fi
|
||||
}
|
||||
if [[ -z "$cache" ]] || [[ ! -f "$cache/Spigot-$version.jar" ]] || [[ "$mode" == "UPDATE" && $(find "$cache/Spigot-$version.jar" -mtime +1 -print) ]]; then
|
||||
|
@ -11,7 +11,7 @@ function __DL() {
|
||||
if [[ -x "$(command -v wget)" ]]; then
|
||||
wget -O "$1" "$2"; return $?
|
||||
else
|
||||
curl -o "$1" "$2"; return $?
|
||||
curl -Lo "$1" "$2"; return $?
|
||||
fi
|
||||
}
|
||||
function __Restore() {
|
||||
|
@ -15,7 +15,7 @@ function __DL() {
|
||||
if [[ -x "$(command -v wget)" ]]; then
|
||||
wget -O "$1" "$2"; return $?
|
||||
else
|
||||
curl -o "$1" "$2"; return $?
|
||||
curl -Lo "$1" "$2"; return $?
|
||||
fi
|
||||
}
|
||||
if [[ -z "$cache" ]] || [[ ! -f "$cache/Vanilla-$version.jar" ]]; then
|
||||
|
@ -30,13 +30,13 @@
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiEngine</artifactId>
|
||||
<version>21w24a</version>
|
||||
<version>21w26a</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiUI</artifactId>
|
||||
<version>21w24a</version>
|
||||
<version>21w26a</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -293,19 +293,24 @@ public class SubCreatorImpl {
|
||||
templates.putAll(host.templates);
|
||||
}
|
||||
|
||||
private ObjectMap<String> build(File dir, ServerTemplate template, List<ServerTemplate> history) throws SubCreatorException {
|
||||
private ObjectMap<String> build(File dir, ServerTemplate template, List<ServerTemplate> history, List<ServerTemplate> stack) throws SubCreatorException {
|
||||
ObjectMap<String> server = new ObjectMap<String>();
|
||||
Version version = this.version;
|
||||
HashMap<String, String> var = new HashMap<String, String>();
|
||||
boolean error = false;
|
||||
if (history.contains(template)) throw new IllegalStateException("Template import loop detected");
|
||||
history.add(template);
|
||||
if (stack.contains(template)) throw new IllegalStateException("Infinite template import loop detected");
|
||||
stack.add(template);
|
||||
for (String other : template.getBuildOptions().getStringList("Import", new ArrayList<String>())) {
|
||||
if (templates.keySet().contains(other.toLowerCase())) {
|
||||
if (templates.get(other.toLowerCase()).isEnabled()) {
|
||||
if (version != null || !templates.get(other.toLowerCase()).requiresVersion()) {
|
||||
if (update == null || templates.get(other.toLowerCase()).canUpdate()) {
|
||||
server.setAll(this.build(dir, templates.get(other.toLowerCase()), history));
|
||||
if (templates.containsKey(other.toLowerCase())) {
|
||||
final ServerTemplate ot = templates.get(other.toLowerCase());
|
||||
if (ot.isEnabled()) {
|
||||
if (version != null || !ot.requiresVersion()) {
|
||||
if (update == null || ot.canUpdate()) {
|
||||
if (!history.contains(ot)) {
|
||||
server.setAll(this.build(dir, ot, history, stack));
|
||||
} else {
|
||||
log.logger.warn.println("Skipping template that's already loaded: " + other);
|
||||
}
|
||||
} else {
|
||||
log.logger.warn.println("Skipping template that cannot be run in update mode: " + other);
|
||||
}
|
||||
@ -319,6 +324,8 @@ public class SubCreatorImpl {
|
||||
log.logger.warn.println("Skipping missing template: " + other);
|
||||
}
|
||||
}
|
||||
history.add(template);
|
||||
stack.remove(template);
|
||||
server.setAll(template.getConfigOptions());
|
||||
try {
|
||||
log.logger.info.println("Loading" + ((template.isDynamic())?" Dynamic":"") + " Template: " + template.getDisplayName());
|
||||
@ -386,8 +393,8 @@ public class SubCreatorImpl {
|
||||
log.logger.info.println("Launching Build Script...");
|
||||
ProcessBuilder pb = new ProcessBuilder().command(Executable.parse(host.host.getRawString("Git-Bash"), template.getBuildOptions().getRawString("Executable"))).directory(dir);
|
||||
pb.environment().putAll(var);
|
||||
process = pb.start();
|
||||
log.file = new File(dir, "SubCreator-" + template.getName() + "-" + ((version != null)?"-"+version.toString():"") + ".log");
|
||||
process = pb.start();
|
||||
log.process = process;
|
||||
log.start();
|
||||
|
||||
@ -434,12 +441,15 @@ public class SubCreatorImpl {
|
||||
|
||||
ObjectMap<String> config;
|
||||
try {
|
||||
config = build(dir, template, new LinkedList<>());
|
||||
log.init();
|
||||
config = build(dir, template, new LinkedList<>(), new LinkedList<>());
|
||||
} catch (SubCreatorException e) {
|
||||
config = null;
|
||||
} catch (Exception e) {
|
||||
config = null;
|
||||
log.logger.error.println(e);
|
||||
} finally {
|
||||
log.destroy();
|
||||
}
|
||||
|
||||
declaration.run();
|
||||
|
@ -40,7 +40,7 @@ public class SubLoggerImpl {
|
||||
static boolean logc = true;
|
||||
File file;
|
||||
private SubDataClient channel = null;
|
||||
private LinkedList<Pair<String, String>> ccache = null;
|
||||
private LinkedList<Pair<Byte, String>> ccache = null;
|
||||
private PrintWriter writer = null;
|
||||
private boolean started = false;
|
||||
private Thread out = null;
|
||||
@ -70,13 +70,13 @@ public class SubLoggerImpl {
|
||||
if (logn) {
|
||||
if (this.address != null && channel != null && !channel.isClosed()) {
|
||||
if (ccache != null) {
|
||||
for (Pair<String, String> val : ccache) channel.sendPacket(new PacketOutExLogMessage(this.address, val.key(), val.value()));
|
||||
for (Pair<Byte, String> val : ccache) channel.sendPacket(new PacketOutExLogMessage(this.address, val.key(), val.value()));
|
||||
ccache = null;
|
||||
}
|
||||
channel.sendPacket(new PacketOutExLogMessage(this.address, stream.getLevel().getName(), message));
|
||||
channel.sendPacket(new PacketOutExLogMessage(this.address, stream.getLevel().getID(), message));
|
||||
} else {
|
||||
if (ccache == null) ccache = new LinkedList<Pair<String, String>>();
|
||||
ccache.add(new ContainedPair<>(stream.getLevel().getName(), message));
|
||||
if (ccache == null) ccache = new LinkedList<Pair<Byte, String>>();
|
||||
ccache.add(new ContainedPair<>(stream.getLevel().getID(), message));
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,23 +85,10 @@ public class SubLoggerImpl {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Start Logger
|
||||
*/
|
||||
public void start() {
|
||||
started = true;
|
||||
if (file != null && writer == null) {
|
||||
try {
|
||||
this.writer = new PrintWriter(file, "UTF-8");
|
||||
this.writer.println("---------- LOG START \u2014 " + name + " ----------");
|
||||
this.writer.flush();
|
||||
} catch (IOException e) {
|
||||
logger.error.println(e);
|
||||
}
|
||||
}
|
||||
Process process = this.process;
|
||||
ExHost host = SubAPI.getInstance().getInternals();
|
||||
@SuppressWarnings("deprecation")
|
||||
void init() {
|
||||
if (logn) Util.isException(() -> {
|
||||
ExHost host = SubAPI.getInstance().getInternals();
|
||||
channel = (SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0].newChannel();
|
||||
channel.on.closed(new Callback<Pair<DisconnectReason, DataClient>>() {
|
||||
@Override
|
||||
@ -131,11 +118,24 @@ public class SubLoggerImpl {
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void start() {
|
||||
started = true;
|
||||
if (file != null && writer == null) {
|
||||
try {
|
||||
this.writer = new PrintWriter(file, "UTF-8");
|
||||
this.writer.println("---------- LOG START \u2014 " + name + " ----------");
|
||||
this.writer.flush();
|
||||
} catch (IOException e) {
|
||||
logger.error.println(e);
|
||||
}
|
||||
}
|
||||
Process process = this.process;
|
||||
if (out == null) (out = new Thread(() -> start(process.getInputStream(), false), SubAPI.getInstance().getAppInfo().getName() + "::Log_Spooler(" + name + ')')).start();
|
||||
if (err == null) (err = new Thread(() -> start(process.getErrorStream(), true), SubAPI.getInstance().getAppInfo().getName() + "::Error_Spooler(" + name + ')')).start();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void start(InputStream in, boolean isErr) {
|
||||
try {
|
||||
@ -213,29 +213,28 @@ public class SubLoggerImpl {
|
||||
try {
|
||||
if (out != null) out.interrupt();
|
||||
if (err != null) err.interrupt();
|
||||
destroy();
|
||||
if (started) {
|
||||
started = false;
|
||||
if (writer != null) {
|
||||
PrintWriter writer = this.writer;
|
||||
this.writer = null;
|
||||
int l = (int) Math.floor((("---------- LOG START \u2014 " + name + " ----------").length() - 9) / 2);
|
||||
String s = "";
|
||||
while (s.length() < l) s += '-';
|
||||
if (writer != null) {
|
||||
writer.println(s + " LOG END " + s);
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException e) {}
|
||||
}
|
||||
|
||||
private void destroy() {
|
||||
if (started) {
|
||||
started = false;
|
||||
if (writer != null) {
|
||||
PrintWriter writer = this.writer;
|
||||
this.writer = null;
|
||||
int l = (int) Math.floor((("---------- LOG START \u2014 " + name + " ----------").length() - 9) / 2);
|
||||
String s = "";
|
||||
while (s.length() < l) s += '-';
|
||||
if (writer != null) {
|
||||
writer.println(s + " LOG END " + s);
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
if (channel != null && !channel.isClosed()) {
|
||||
channel.sendPacket(new PacketOutExLogMessage(address));
|
||||
}
|
||||
channel = null;
|
||||
void destroy() {
|
||||
if (channel != null && !channel.isClosed()) {
|
||||
channel.sendPacket(new PacketOutExLogMessage(address));
|
||||
}
|
||||
channel = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,6 +106,7 @@ public class SubServerImpl {
|
||||
if (SubAPI.getInstance().getSubDataNetwork()[0] != null) pb.environment().put("host", SubAPI.getInstance().getName());
|
||||
pb.environment().put("address", host.config.get().getMap("Settings").getRawString("Server-Bind"));
|
||||
pb.environment().put("port", Integer.toString(getPort()));
|
||||
logger.init();
|
||||
process = pb.start();
|
||||
falsestart = false;
|
||||
host.log.info.println("Now starting " + name);
|
||||
@ -126,8 +127,10 @@ public class SubServerImpl {
|
||||
if (falsestart) ((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketExEditServer(this, PacketExEditServer.UpdateType.LAUNCH_EXCEPTION));
|
||||
}
|
||||
|
||||
if (SubAPI.getInstance().getSubDataNetwork()[0] != null)
|
||||
logger.destroy();
|
||||
if (SubAPI.getInstance().getSubDataNetwork()[0] != null) {
|
||||
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketExEditServer(this, PacketExEditServer.UpdateType.STOPPED, (Integer) process.exitValue(), (Boolean) allowrestart));
|
||||
}
|
||||
host.log.info.println(name + " has stopped");
|
||||
process = null;
|
||||
command = null;
|
||||
|
@ -11,31 +11,27 @@ import java.util.UUID;
|
||||
*/
|
||||
public class PacketOutExLogMessage implements PacketObjectOut<Integer> {
|
||||
private UUID address;
|
||||
private String level, line;
|
||||
private boolean terminate;
|
||||
private Byte level;
|
||||
private String line;
|
||||
|
||||
/**
|
||||
* New PacketInExLogMessage (Out)
|
||||
*/
|
||||
public PacketOutExLogMessage(UUID address, String level, String line) {
|
||||
public PacketOutExLogMessage(UUID address, byte level, String line) {
|
||||
this.address = address;
|
||||
this.level = level;
|
||||
this.line = line;
|
||||
this.terminate = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* New PacketInExLogMessage (Out)
|
||||
* New PacketInExLogMessage (Reset)
|
||||
*/
|
||||
public PacketOutExLogMessage(UUID address) {
|
||||
this.address = address;
|
||||
this.terminate = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectMap<Integer> send(SubDataSender client) throws Exception {
|
||||
if (terminate) client.getConnection().close();
|
||||
|
||||
ObjectMap<Integer> data = new ObjectMap<Integer>();
|
||||
data.set(0x0000, address);
|
||||
if (level != null) data.set(0x0001, level);
|
||||
|
@ -23,6 +23,7 @@ import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.conf.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
@ -128,7 +129,7 @@ public class SubProtocol extends SubDataProtocol {
|
||||
}
|
||||
|
||||
private Logger getLogger(int channel) {
|
||||
return net.ME1312.SubServers.Bungee.Library.Compatibility.Logger.get("SubData" + ((channel != 0)?"/+"+channel:""));
|
||||
return net.ME1312.SubServers.Bungee.Library.Compatibility.Logger.get("SubData" + ((channel != 0)?File.separator+"+"+channel:""));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user