3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 22:40:18 +01:00

Applied requested changes to code

Dieser Commit ist enthalten in:
RaphiMC 2023-10-08 21:11:30 +02:00
Ursprung c84b1c5bee
Commit ad53b127ff
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0F6BB0657A03AC94
7 geänderte Dateien mit 67 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -1,3 +1,8 @@
java {
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
}
dependencies { dependencies {
api(projects.core) api(projects.core)
} }

Datei anzeigen

@ -25,6 +25,7 @@
package org.geysermc.geyser.platform.viaproxy; package org.geysermc.geyser.platform.viaproxy;
import net.raphimc.viaproxy.cli.options.Options; import net.raphimc.viaproxy.cli.options.Options;
import org.apache.logging.log4j.Logger;
import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.GeyserLogger;
@ -47,23 +48,29 @@ import java.util.UUID;
public class GeyserViaProxyBootstrap implements GeyserBootstrap { public class GeyserViaProxyBootstrap implements GeyserBootstrap {
private final GeyserViaProxyLogger logger = new GeyserViaProxyLogger(); private final File rootFolder;
private final GeyserViaProxyLogger logger;
private GeyserViaProxyConfiguration config; private GeyserViaProxyConfiguration config;
private GeyserImpl geyser; private GeyserImpl geyser;
private GeyserCommandManager commandManager; private GeyserCommandManager commandManager;
private IGeyserPingPassthrough pingPassthrough; private IGeyserPingPassthrough pingPassthrough;
public GeyserViaProxyBootstrap(final Logger logger, final File rootFolder) {
this.logger = new GeyserViaProxyLogger(logger);
this.rootFolder = rootFolder;
}
@Override @Override
public void onEnable() { public void onEnable() {
LoopbackUtil.checkAndApplyLoopback(this.logger); LoopbackUtil.checkAndApplyLoopback(this.logger);
try { 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); this.config = FileUtils.loadConfig(configFile, GeyserViaProxyConfiguration.class);
} catch (IOException e) { } catch (IOException e) {
this.logger.severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), e); this.logger.severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), e);
System.exit(-1); return;
} }
config.getRemote().setAuthType(Options.ONLINE_MODE ? AuthType.ONLINE : AuthType.OFFLINE); config.getRemote().setAuthType(Options.ONLINE_MODE ? AuthType.ONLINE : AuthType.OFFLINE);
@ -105,7 +112,7 @@ public class GeyserViaProxyBootstrap implements GeyserBootstrap {
@Override @Override
public Path getConfigFolder() { public Path getConfigFolder() {
return GeyserViaProxyPlugin.ROOT_FOLDER.toPath(); return this.rootFolder.toPath();
} }
@Override @Override

Datei anzeigen

@ -24,11 +24,39 @@
*/ */
package org.geysermc.geyser.platform.viaproxy; package org.geysermc.geyser.platform.viaproxy;
import lombok.Getter;
import net.raphimc.viaproxy.ViaProxy; 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.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 { 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<PluginInfo> 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())));
}
}
} }

Datei anzeigen

@ -25,54 +25,64 @@
package org.geysermc.geyser.platform.viaproxy; package org.geysermc.geyser.platform.viaproxy;
import net.raphimc.viaproxy.cli.ConsoleFormatter; import net.raphimc.viaproxy.cli.ConsoleFormatter;
import org.apache.logging.log4j.Logger;
import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.command.GeyserCommandSource;
public class GeyserViaProxyLogger implements GeyserLogger, GeyserCommandSource { public class GeyserViaProxyLogger implements GeyserLogger, GeyserCommandSource {
private final Logger logger;
private boolean debug;
public GeyserViaProxyLogger(Logger logger) {
this.logger = logger;
}
@Override @Override
public void severe(String message) { public void severe(String message) {
GeyserViaProxyPlugin.LOGGER.fatal(ConsoleFormatter.convert(message)); this.logger.fatal(ConsoleFormatter.convert(message));
} }
@Override @Override
public void severe(String message, Throwable error) { public void severe(String message, Throwable error) {
GeyserViaProxyPlugin.LOGGER.fatal(ConsoleFormatter.convert(message), error); this.logger.fatal(ConsoleFormatter.convert(message), error);
} }
@Override @Override
public void error(String message) { public void error(String message) {
GeyserViaProxyPlugin.LOGGER.error(ConsoleFormatter.convert(message)); this.logger.error(ConsoleFormatter.convert(message));
} }
@Override @Override
public void error(String message, Throwable error) { public void error(String message, Throwable error) {
GeyserViaProxyPlugin.LOGGER.error(ConsoleFormatter.convert(message), error); this.logger.error(ConsoleFormatter.convert(message), error);
} }
@Override @Override
public void warning(String message) { public void warning(String message) {
GeyserViaProxyPlugin.LOGGER.warn(ConsoleFormatter.convert(message)); this.logger.warn(ConsoleFormatter.convert(message));
} }
@Override @Override
public void info(String message) { public void info(String message) {
GeyserViaProxyPlugin.LOGGER.info(ConsoleFormatter.convert(message)); this.logger.info(ConsoleFormatter.convert(message));
} }
@Override @Override
public void debug(String message) { public void debug(String message) {
GeyserViaProxyPlugin.LOGGER.debug(ConsoleFormatter.convert(message)); if (this.debug) {
this.logger.debug(ConsoleFormatter.convert(message));
}
} }
@Override @Override
public void setDebug(boolean debug) { public void setDebug(boolean debug) {
throw new UnsupportedOperationException(); this.debug = debug;
} }
@Override @Override
public boolean isDebug() { public boolean isDebug() {
return false; return this.debug;
} }
} }

Datei anzeigen

@ -49,7 +49,7 @@ public class GeyserViaProxyPlugin extends ViaProxyPlugin {
public void onEnable() { public void onEnable() {
ROOT_FOLDER.mkdirs(); ROOT_FOLDER.mkdirs();
this.bootstrap = new GeyserViaProxyBootstrap(); this.bootstrap = new GeyserViaProxyBootstrap(LOGGER, ROOT_FOLDER);
GeyserLocale.init(this.bootstrap); GeyserLocale.init(this.bootstrap);
this.bootstrap.onEnable(); this.bootstrap.onEnable();
GeyserImpl.getInstance().shutdown(); GeyserImpl.getInstance().shutdown();

Datei anzeigen

@ -16,7 +16,7 @@ indra {
mitLicense() mitLicense()
javaVersions { javaVersions {
target(17) target(16)
} }
} }

Datei anzeigen

@ -12,7 +12,7 @@ allprojects {
java { java {
toolchain { toolchain {
languageVersion.set(JavaLanguageVersion.of(17)) languageVersion.set(JavaLanguageVersion.of(16))
} }
} }