diff --git a/bootstrap/viaproxy/build.gradle.kts b/bootstrap/viaproxy/build.gradle.kts index 06fcbac54..17dd7ffb4 100644 --- a/bootstrap/viaproxy/build.gradle.kts +++ b/bootstrap/viaproxy/build.gradle.kts @@ -1,3 +1,8 @@ +java { + targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_17 +} + dependencies { api(projects.core) } diff --git a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyBootstrap.java b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyBootstrap.java index a3a504c4c..57027dc3c 100644 --- a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyBootstrap.java +++ b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyBootstrap.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.platform.viaproxy; import net.raphimc.viaproxy.cli.options.Options; +import org.apache.logging.log4j.Logger; import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; @@ -47,23 +48,29 @@ import java.util.UUID; public class GeyserViaProxyBootstrap implements GeyserBootstrap { - private final GeyserViaProxyLogger logger = new GeyserViaProxyLogger(); + private final File rootFolder; + private final GeyserViaProxyLogger logger; private GeyserViaProxyConfiguration config; private GeyserImpl geyser; private GeyserCommandManager commandManager; private IGeyserPingPassthrough pingPassthrough; + public GeyserViaProxyBootstrap(final Logger logger, final File rootFolder) { + this.logger = new GeyserViaProxyLogger(logger); + this.rootFolder = rootFolder; + } + @Override public void onEnable() { LoopbackUtil.checkAndApplyLoopback(this.logger); try { - final File configFile = FileUtils.fileOrCopiedFromResource(new File(GeyserViaProxyPlugin.ROOT_FOLDER, "config.yml"), "config.yml", s -> s.replaceAll("generateduuid", UUID.randomUUID().toString()), this); + final File configFile = FileUtils.fileOrCopiedFromResource(new File(this.rootFolder, "config.yml"), "config.yml", s -> s.replaceAll("generateduuid", UUID.randomUUID().toString()), this); this.config = FileUtils.loadConfig(configFile, GeyserViaProxyConfiguration.class); } catch (IOException e) { this.logger.severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), e); - System.exit(-1); + return; } config.getRemote().setAuthType(Options.ONLINE_MODE ? AuthType.ONLINE : AuthType.OFFLINE); @@ -105,7 +112,7 @@ public class GeyserViaProxyBootstrap implements GeyserBootstrap { @Override public Path getConfigFolder() { - return GeyserViaProxyPlugin.ROOT_FOLDER.toPath(); + return this.rootFolder.toPath(); } @Override diff --git a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyDumpInfo.java b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyDumpInfo.java index c44006344..39056e8e2 100644 --- a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyDumpInfo.java +++ b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyDumpInfo.java @@ -24,11 +24,39 @@ */ package org.geysermc.geyser.platform.viaproxy; +import lombok.Getter; import net.raphimc.viaproxy.ViaProxy; +import net.raphimc.viaproxy.cli.options.Options; +import net.raphimc.viaproxy.plugins.PluginManager; +import net.raphimc.viaproxy.plugins.ViaProxyPlugin; import org.geysermc.geyser.dump.BootstrapDumpInfo; +import org.geysermc.geyser.text.AsteriskSerializer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +@Getter public class GeyserViaProxyDumpInfo extends BootstrapDumpInfo { - private final String viaProxyVersion = ViaProxy.VERSION; + private final String platformVersion; + private final boolean onlineMode; + + @AsteriskSerializer.Asterisk(isIp = true) + private final String serverIP; + private final int serverPort; + private final List plugins; + + public GeyserViaProxyDumpInfo() { + this.platformVersion = ViaProxy.VERSION; + this.onlineMode = Options.ONLINE_MODE; + this.serverIP = Options.BIND_ADDRESS; + this.serverPort = Options.BIND_PORT; + this.plugins = new ArrayList<>(); + + for (ViaProxyPlugin plugin : PluginManager.getPlugins()) { + this.plugins.add(new PluginInfo(true, plugin.getName(), plugin.getVersion(), "unknown", Collections.singletonList(plugin.getAuthor()))); + } + } } diff --git a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyLogger.java b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyLogger.java index f8ddac14f..10f414b51 100644 --- a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyLogger.java +++ b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyLogger.java @@ -25,54 +25,64 @@ package org.geysermc.geyser.platform.viaproxy; import net.raphimc.viaproxy.cli.ConsoleFormatter; +import org.apache.logging.log4j.Logger; import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.command.GeyserCommandSource; public class GeyserViaProxyLogger implements GeyserLogger, GeyserCommandSource { + private final Logger logger; + private boolean debug; + + public GeyserViaProxyLogger(Logger logger) { + this.logger = logger; + } + @Override public void severe(String message) { - GeyserViaProxyPlugin.LOGGER.fatal(ConsoleFormatter.convert(message)); + this.logger.fatal(ConsoleFormatter.convert(message)); } @Override public void severe(String message, Throwable error) { - GeyserViaProxyPlugin.LOGGER.fatal(ConsoleFormatter.convert(message), error); + this.logger.fatal(ConsoleFormatter.convert(message), error); } @Override public void error(String message) { - GeyserViaProxyPlugin.LOGGER.error(ConsoleFormatter.convert(message)); + this.logger.error(ConsoleFormatter.convert(message)); } @Override public void error(String message, Throwable error) { - GeyserViaProxyPlugin.LOGGER.error(ConsoleFormatter.convert(message), error); + this.logger.error(ConsoleFormatter.convert(message), error); } @Override public void warning(String message) { - GeyserViaProxyPlugin.LOGGER.warn(ConsoleFormatter.convert(message)); + this.logger.warn(ConsoleFormatter.convert(message)); } @Override public void info(String message) { - GeyserViaProxyPlugin.LOGGER.info(ConsoleFormatter.convert(message)); + this.logger.info(ConsoleFormatter.convert(message)); } @Override public void debug(String message) { - GeyserViaProxyPlugin.LOGGER.debug(ConsoleFormatter.convert(message)); + if (this.debug) { + this.logger.debug(ConsoleFormatter.convert(message)); + } } @Override public void setDebug(boolean debug) { - throw new UnsupportedOperationException(); + this.debug = debug; } @Override public boolean isDebug() { - return false; + return this.debug; } } diff --git a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyPlugin.java b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyPlugin.java index 15b756df4..2c2941e9d 100644 --- a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyPlugin.java +++ b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyPlugin.java @@ -49,7 +49,7 @@ public class GeyserViaProxyPlugin extends ViaProxyPlugin { public void onEnable() { ROOT_FOLDER.mkdirs(); - this.bootstrap = new GeyserViaProxyBootstrap(); + this.bootstrap = new GeyserViaProxyBootstrap(LOGGER, ROOT_FOLDER); GeyserLocale.init(this.bootstrap); this.bootstrap.onEnable(); GeyserImpl.getInstance().shutdown(); diff --git a/build-logic/src/main/kotlin/geyser.base-conventions.gradle.kts b/build-logic/src/main/kotlin/geyser.base-conventions.gradle.kts index c9f984596..368ab44e7 100644 --- a/build-logic/src/main/kotlin/geyser.base-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/geyser.base-conventions.gradle.kts @@ -16,7 +16,7 @@ indra { mitLicense() javaVersions { - target(17) + target(16) } } diff --git a/build.gradle.kts b/build.gradle.kts index 6f32ec0cd..e632e98c9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ allprojects { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(16)) } }