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

Implemented ViaProxy bootstrap

Dieser Commit ist enthalten in:
RaphiMC 2023-10-08 18:09:48 +02:00
Ursprung 3fdd6b41d0
Commit c84b1c5bee
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0F6BB0657A03AC94
14 geänderte Dateien mit 459 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -40,4 +40,5 @@ public record PlatformType(String platformName) {
public static final PlatformType SPONGE = new PlatformType("Sponge"); public static final PlatformType SPONGE = new PlatformType("Sponge");
public static final PlatformType STANDALONE = new PlatformType("Standalone"); public static final PlatformType STANDALONE = new PlatformType("Standalone");
public static final PlatformType VELOCITY = new PlatformType("Velocity"); public static final PlatformType VELOCITY = new PlatformType("Velocity");
public static final PlatformType VIAPROXY = new PlatformType("ViaProxy");
} }

Datei anzeigen

@ -0,0 +1,27 @@
dependencies {
api(projects.core)
}
platformRelocate("net.kyori")
platformRelocate("org.yaml")
platformRelocate("it.unimi.dsi.fastutil")
platformRelocate("com.mojang")
platformRelocate("org.cloudburstmc.netty")
// These dependencies are already present on the platform
provided(libs.viaproxy)
application {
mainClass.set("org.geysermc.geyser.platform.viaproxy.GeyserViaProxyMain")
}
tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
archiveBaseName.set("Geyser-ViaProxy")
dependencies {
exclude(dependency("com.google.*:.*"))
exclude(dependency("io.netty:.*"))
exclude(dependency("org.slf4j:.*"))
exclude(dependency("org.ow2.asm:.*"))
}
}

Datei anzeigen

@ -0,0 +1,132 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.platform.viaproxy;
import net.raphimc.viaproxy.cli.options.Options;
import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.api.network.AuthType;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.command.GeyserCommandManager;
import org.geysermc.geyser.configuration.GeyserConfiguration;
import org.geysermc.geyser.dump.BootstrapDumpInfo;
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
import org.geysermc.geyser.ping.IGeyserPingPassthrough;
import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.FileUtils;
import org.geysermc.geyser.util.LoopbackUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.UUID;
public class GeyserViaProxyBootstrap implements GeyserBootstrap {
private final GeyserViaProxyLogger logger = new GeyserViaProxyLogger();
private GeyserViaProxyConfiguration config;
private GeyserImpl geyser;
private GeyserCommandManager commandManager;
private IGeyserPingPassthrough pingPassthrough;
@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);
this.config = FileUtils.loadConfig(configFile, GeyserViaProxyConfiguration.class);
} catch (IOException e) {
this.logger.severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), e);
System.exit(-1);
}
config.getRemote().setAuthType(Options.ONLINE_MODE ? AuthType.ONLINE : AuthType.OFFLINE);
GeyserConfiguration.checkGeyserConfiguration(this.config, this.logger);
this.geyser = GeyserImpl.load(PlatformType.VIAPROXY, this);
GeyserImpl.start();
this.commandManager = new GeyserCommandManager(this.geyser);
this.commandManager.init();
this.pingPassthrough = GeyserLegacyPingPassthrough.init(this.geyser);
}
@Override
public void onDisable() {
this.geyser.shutdown();
}
@Override
public GeyserConfiguration getGeyserConfig() {
return this.config;
}
@Override
public GeyserLogger getGeyserLogger() {
return this.logger;
}
@Override
public GeyserCommandManager getGeyserCommandManager() {
return this.commandManager;
}
@Override
public IGeyserPingPassthrough getGeyserPingPassthrough() {
return this.pingPassthrough;
}
@Override
public Path getConfigFolder() {
return GeyserViaProxyPlugin.ROOT_FOLDER.toPath();
}
@Override
public BootstrapDumpInfo getDumpInfo() {
return new GeyserViaProxyDumpInfo();
}
@NotNull
@Override
public String getServerBindAddress() {
return Options.BIND_ADDRESS;
}
@Override
public int getServerPort() {
return Options.BIND_PORT;
}
@Override
public boolean testFloodgatePluginPresent() {
return false;
}
}

Datei anzeigen

@ -0,0 +1,41 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.platform.viaproxy;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.geysermc.geyser.configuration.GeyserJacksonConfiguration;
import java.io.File;
import java.nio.file.Path;
@JsonIgnoreProperties(ignoreUnknown = true)
public class GeyserViaProxyConfiguration extends GeyserJacksonConfiguration {
@Override
public Path getFloodgateKeyPath() {
return new File(GeyserViaProxyPlugin.ROOT_FOLDER, this.getFloodgateKeyFile()).toPath();
}
}

Datei anzeigen

@ -0,0 +1,34 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.platform.viaproxy;
import net.raphimc.viaproxy.ViaProxy;
import org.geysermc.geyser.dump.BootstrapDumpInfo;
public class GeyserViaProxyDumpInfo extends BootstrapDumpInfo {
private final String viaProxyVersion = ViaProxy.VERSION;
}

Datei anzeigen

@ -0,0 +1,78 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.platform.viaproxy;
import net.raphimc.viaproxy.cli.ConsoleFormatter;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.command.GeyserCommandSource;
public class GeyserViaProxyLogger implements GeyserLogger, GeyserCommandSource {
@Override
public void severe(String message) {
GeyserViaProxyPlugin.LOGGER.fatal(ConsoleFormatter.convert(message));
}
@Override
public void severe(String message, Throwable error) {
GeyserViaProxyPlugin.LOGGER.fatal(ConsoleFormatter.convert(message), error);
}
@Override
public void error(String message) {
GeyserViaProxyPlugin.LOGGER.error(ConsoleFormatter.convert(message));
}
@Override
public void error(String message, Throwable error) {
GeyserViaProxyPlugin.LOGGER.error(ConsoleFormatter.convert(message), error);
}
@Override
public void warning(String message) {
GeyserViaProxyPlugin.LOGGER.warn(ConsoleFormatter.convert(message));
}
@Override
public void info(String message) {
GeyserViaProxyPlugin.LOGGER.info(ConsoleFormatter.convert(message));
}
@Override
public void debug(String message) {
GeyserViaProxyPlugin.LOGGER.debug(ConsoleFormatter.convert(message));
}
@Override
public void setDebug(boolean debug) {
throw new UnsupportedOperationException();
}
@Override
public boolean isDebug() {
return false;
}
}

Datei anzeigen

@ -0,0 +1,45 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.platform.viaproxy;
import net.raphimc.viaproxy.plugins.PluginManager;
import org.geysermc.geyser.GeyserMain;
public class GeyserViaProxyMain extends GeyserMain {
public static void main(String[] args) {
new GeyserViaProxyMain().displayMessage();
}
public String getPluginType() {
return "ViaProxy";
}
public String getPluginFolder() {
return PluginManager.PLUGINS_DIR.getName();
}
}

Datei anzeigen

@ -0,0 +1,82 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.platform.viaproxy;
import net.lenni0451.lambdaevents.EventHandler;
import net.raphimc.viaproxy.plugins.PluginManager;
import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
import net.raphimc.viaproxy.plugins.events.ConsoleCommandEvent;
import net.raphimc.viaproxy.plugins.events.ProxyStartEvent;
import net.raphimc.viaproxy.plugins.events.ProxyStopEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.text.GeyserLocale;
import java.io.File;
public class GeyserViaProxyPlugin extends ViaProxyPlugin {
public static final Logger LOGGER = LogManager.getLogger("Geyser");
public static final File ROOT_FOLDER = new File(PluginManager.PLUGINS_DIR, "Geyser");
private GeyserViaProxyBootstrap bootstrap;
@Override
public void onEnable() {
ROOT_FOLDER.mkdirs();
this.bootstrap = new GeyserViaProxyBootstrap();
GeyserLocale.init(this.bootstrap);
this.bootstrap.onEnable();
GeyserImpl.getInstance().shutdown();
PluginManager.EVENT_MANAGER.register(this);
}
@EventHandler
public void onConsoleCommand(final ConsoleCommandEvent event) {
if (event.getCommand().equals("geyser") || event.getCommand().equals("/geyser")) {
event.setCancelled(true);
this.bootstrap.getGeyserCommandManager().runCommand(this.bootstrap.getGeyserLogger(), "geyser " + String.join(" ", event.getArgs()));
}
}
// Code below split apart from GeyserImpl.getInstance().reload();
@EventHandler
public void onProxyStart(final ProxyStartEvent event) {
GeyserImpl.getInstance().extensionManager().enableExtensions();
this.bootstrap.onEnable();
}
@EventHandler
public void onProxyStop(final ProxyStopEvent event) {
GeyserImpl.getInstance().shutdown();
}
}

Datei anzeigen

@ -0,0 +1,5 @@
name: "${name}-ViaProxy"
version: "${version}"
author: "${author}"
main: "org.geysermc.geyser.platform.viaproxy.GeyserViaProxyPlugin"
min-version: "3.0.21"

Datei anzeigen

@ -16,14 +16,14 @@ indra {
mitLicense() mitLicense()
javaVersions { javaVersions {
target(16) target(17)
} }
} }
tasks { tasks {
processResources { processResources {
// Spigot, BungeeCord, Velocity, Fabric // Spigot, BungeeCord, Velocity, Fabric, ViaProxy
filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json", "fabric.mod.json")) { filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json", "fabric.mod.json", "viaproxy.yml")) {
expand( expand(
"id" to "geyser", "id" to "geyser",
"name" to "Geyser", "name" to "Geyser",
@ -34,4 +34,4 @@ tasks {
) )
} }
} }
} }

Datei anzeigen

@ -12,7 +12,7 @@ allprojects {
java { java {
toolchain { toolchain {
languageVersion.set(JavaLanguageVersion.of(16)) languageVersion.set(JavaLanguageVersion.of(17))
} }
} }
@ -21,7 +21,8 @@ val platforms = setOf(
projects.bungeecord, projects.bungeecord,
projects.spigot, projects.spigot,
projects.standalone, projects.standalone,
projects.velocity projects.velocity,
projects.viaproxy
).map { it.dependencyProject } ).map { it.dependencyProject }
subprojects { subprojects {
@ -35,4 +36,4 @@ subprojects {
in platforms -> plugins.apply("geyser.platform-conventions") in platforms -> plugins.apply("geyser.platform-conventions")
else -> plugins.apply("geyser.base-conventions") else -> plugins.apply("geyser.base-conventions")
} }
} }

Datei anzeigen

@ -51,7 +51,7 @@ public class JavaLoginDisconnectTranslator extends PacketTranslator<ClientboundL
if (testForOutdatedServer(disconnectReason)) { if (testForOutdatedServer(disconnectReason)) {
String locale = session.locale(); String locale = session.locale();
PlatformType platform = session.getGeyser().getPlatformType(); PlatformType platform = session.getGeyser().getPlatformType();
String outdatedType = (platform == PlatformType.BUNGEECORD || platform == PlatformType.VELOCITY) ? String outdatedType = (platform == PlatformType.BUNGEECORD || platform == PlatformType.VELOCITY || platform == PlatformType.VIAPROXY) ?
"geyser.network.remote.outdated.proxy" : "geyser.network.remote.outdated.server"; "geyser.network.remote.outdated.proxy" : "geyser.network.remote.outdated.server";
disconnectMessage = GeyserLocale.getPlayerLocaleString(outdatedType, locale, GameProtocol.getJavaVersions().get(0)) + '\n' disconnectMessage = GeyserLocale.getPlayerLocaleString(outdatedType, locale, GameProtocol.getJavaVersions().get(0)) + '\n'
+ GeyserLocale.getPlayerLocaleString("geyser.network.remote.original_disconnect_message", locale, serverDisconnectMessage); + GeyserLocale.getPlayerLocaleString("geyser.network.remote.original_disconnect_message", locale, serverDisconnectMessage);

Datei anzeigen

@ -28,6 +28,7 @@ adapters = "1.10-SNAPSHOT"
commodore = "2.2" commodore = "2.2"
bungeecord = "a7c6ede" bungeecord = "a7c6ede"
velocity = "3.1.1" velocity = "3.1.1"
viaproxy = "3.0.21"
fabric-minecraft = "1.20.2" fabric-minecraft = "1.20.2"
fabric-loader = "0.14.21" fabric-loader = "0.14.21"
fabric-api = "0.89.0+1.20.2" fabric-api = "0.89.0+1.20.2"
@ -91,6 +92,7 @@ mcprotocollib = { group = "com.github.steveice10", name = "mcprotocollib", versi
raknet = { group = "org.cloudburstmc.netty", name = "netty-transport-raknet", version.ref = "raknet" } raknet = { group = "org.cloudburstmc.netty", name = "netty-transport-raknet", version.ref = "raknet" }
terminalconsoleappender = { group = "net.minecrell", name = "terminalconsoleappender", version.ref = "terminalconsoleappender" } terminalconsoleappender = { group = "net.minecrell", name = "terminalconsoleappender", version.ref = "terminalconsoleappender" }
velocity-api = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" } velocity-api = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" }
viaproxy = { group = "net.raphimc", name = "ViaProxy", version.ref = "viaproxy" }
viaversion = { group = "com.viaversion", name = "viaversion", version.ref = "viaversion" } viaversion = { group = "com.viaversion", name = "viaversion", version.ref = "viaversion" }
websocket = { group = "org.java-websocket", name = "Java-WebSocket", version.ref = "websocket" } websocket = { group = "org.java-websocket", name = "Java-WebSocket", version.ref = "websocket" }

Datei anzeigen

@ -64,6 +64,7 @@ include(":fabric")
include(":spigot") include(":spigot")
include(":standalone") include(":standalone")
include(":velocity") include(":velocity")
include(":viaproxy")
include(":common") include(":common")
include(":core") include(":core")
@ -72,4 +73,5 @@ project(":bungeecord").projectDir = file("bootstrap/bungeecord")
project(":fabric").projectDir = file("bootstrap/fabric") project(":fabric").projectDir = file("bootstrap/fabric")
project(":spigot").projectDir = file("bootstrap/spigot") project(":spigot").projectDir = file("bootstrap/spigot")
project(":standalone").projectDir = file("bootstrap/standalone") project(":standalone").projectDir = file("bootstrap/standalone")
project(":velocity").projectDir = file("bootstrap/velocity") project(":velocity").projectDir = file("bootstrap/velocity")
project(":viaproxy").projectDir = file("bootstrap/viaproxy")