Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-16 04:50:07 +01:00
Allow Floodgate to be run in Geyser Velocity
Dieser Commit ist enthalten in:
Ursprung
1c49036e3a
Commit
1d2103f265
@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(libs.baseApi)
|
||||
compileOnly(libs.baseApi)
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
@ -25,98 +25,77 @@
|
||||
|
||||
package org.geysermc.geyser.platform.bungeecord;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.api.event.PreLoginEvent;
|
||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.connection.InitialHandler;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.protocol.packet.Handshake;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.api.connection.Connection;
|
||||
import org.geysermc.floodgate.player.FloodgatePlayerImpl;
|
||||
import org.geysermc.floodgate.util.BedrockData;
|
||||
import org.geysermc.floodgate.util.ReflectionUtils;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.hybrid.IntegratedHybridProvider;
|
||||
import org.geysermc.geyser.hybrid.ProxyHybridProvider;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public final class BungeeHybridListener implements Listener {
|
||||
// TODO consolidate with Floodgate
|
||||
private static final Field CHANNEL_WRAPPER;
|
||||
private static final Field PLAYER_NAME;
|
||||
|
||||
static {
|
||||
CHANNEL_WRAPPER =
|
||||
ReflectionUtils.getFieldOfType(InitialHandler.class, ChannelWrapper.class);
|
||||
checkNotNull(CHANNEL_WRAPPER, "ChannelWrapper field cannot be null");
|
||||
|
||||
PLAYER_NAME = ReflectionUtils.getField(InitialHandler.class, "name");
|
||||
checkNotNull(PLAYER_NAME, "Initial name field cannot be null");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPreLogin(PreLoginEvent event) {
|
||||
// well, no reason to check if the player will be kicked anyway
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PendingConnection connection = event.getConnection();
|
||||
Connection player = getPlayer(connection);
|
||||
if (player != null) {
|
||||
connection.setOnlineMode(false);
|
||||
connection.setUniqueId(player.javaUuid());
|
||||
ReflectionUtils.setValue(connection, PLAYER_NAME, player.javaUsername());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onServerConnect(ServerConnectEvent event) {
|
||||
boolean sendFloodgateData = false; // TODO
|
||||
if (!sendFloodgateData) {
|
||||
return; // TODO just don't register event?
|
||||
}
|
||||
|
||||
PendingConnection connection = event.getPlayer().getPendingConnection();
|
||||
Connection player = getPlayer(connection);
|
||||
if (player != null) {
|
||||
Handshake handshake = ReflectionUtils.getCastedValue(connection, "handshake");
|
||||
BedrockData data = ((FloodgatePlayerImpl) player).toBedrockData(); // FIXME
|
||||
String encryptedData = ((ProxyHybridProvider) GeyserImpl.getInstance().getHybridProvider())
|
||||
.createEncryptedDataString(data);
|
||||
|
||||
String address = handshake.getHost();
|
||||
|
||||
// our data goes before all the other data
|
||||
int addressFinished = address.indexOf('\0');
|
||||
String originalAddress;
|
||||
String remaining;
|
||||
if (addressFinished != -1) {
|
||||
originalAddress = address.substring(0, addressFinished);
|
||||
remaining = address.substring(addressFinished);
|
||||
} else {
|
||||
originalAddress = address;
|
||||
remaining = "";
|
||||
}
|
||||
|
||||
handshake.setHost(originalAddress + '\0' + encryptedData + remaining);
|
||||
// Bungeecord will add its data after our data
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Connection getPlayer(PendingConnection connection) {
|
||||
ChannelWrapper wrapper = ReflectionUtils.getCastedValue(connection, CHANNEL_WRAPPER);
|
||||
Channel channel = wrapper.getHandle();
|
||||
|
||||
return channel.attr(IntegratedHybridProvider.SESSION_KEY).get(); // TODO re-use Floodgate's attribute key here?
|
||||
}
|
||||
// // TODO consolidate with Floodgate
|
||||
// private static final Field CHANNEL_WRAPPER;
|
||||
// private static final Field PLAYER_NAME;
|
||||
//
|
||||
// static {
|
||||
// CHANNEL_WRAPPER =
|
||||
// ReflectionUtils.getFieldOfType(InitialHandler.class, ChannelWrapper.class);
|
||||
// checkNotNull(CHANNEL_WRAPPER, "ChannelWrapper field cannot be null");
|
||||
//
|
||||
// PLAYER_NAME = ReflectionUtils.getField(InitialHandler.class, "name");
|
||||
// checkNotNull(PLAYER_NAME, "Initial name field cannot be null");
|
||||
// }
|
||||
//
|
||||
// @EventHandler(priority = EventPriority.LOWEST)
|
||||
// public void onPreLogin(PreLoginEvent event) {
|
||||
// // well, no reason to check if the player will be kicked anyway
|
||||
// if (event.isCancelled()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// PendingConnection connection = event.getConnection();
|
||||
// Connection player = getPlayer(connection);
|
||||
// if (player != null) {
|
||||
// connection.setOnlineMode(false);
|
||||
// connection.setUniqueId(player.javaUuid());
|
||||
// ReflectionUtils.setValue(connection, PLAYER_NAME, player.javaUsername());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @EventHandler(priority = EventPriority.LOW)
|
||||
// public void onServerConnect(ServerConnectEvent event) {
|
||||
// boolean sendFloodgateData = false; // TODO
|
||||
// if (!sendFloodgateData) {
|
||||
// return; // TODO just don't register event?
|
||||
// }
|
||||
//
|
||||
// PendingConnection connection = event.getPlayer().getPendingConnection();
|
||||
// Connection player = getPlayer(connection);
|
||||
// if (player != null) {
|
||||
// Handshake handshake = ReflectionUtils.getCastedValue(connection, "handshake");
|
||||
// BedrockData data = ((FloodgateConnection) player).toBedrockData(); // FIXME
|
||||
// String encryptedData = ((ProxyHybridProvider) GeyserImpl.getInstance().getHybridProvider())
|
||||
// .createEncryptedDataString(data);
|
||||
//
|
||||
// String address = handshake.getHost();
|
||||
//
|
||||
// // our data goes before all the other data
|
||||
// int addressFinished = address.indexOf('\0');
|
||||
// String originalAddress;
|
||||
// String remaining;
|
||||
// if (addressFinished != -1) {
|
||||
// originalAddress = address.substring(0, addressFinished);
|
||||
// remaining = address.substring(addressFinished);
|
||||
// } else {
|
||||
// originalAddress = address;
|
||||
// remaining = "";
|
||||
// }
|
||||
//
|
||||
// handshake.setHost(originalAddress + '\0' + encryptedData + remaining);
|
||||
// // Bungeecord will add its data after our data
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Nullable
|
||||
// private Connection getPlayer(PendingConnection connection) {
|
||||
// ChannelWrapper wrapper = ReflectionUtils.getCastedValue(connection, CHANNEL_WRAPPER);
|
||||
// Channel channel = wrapper.getHandle();
|
||||
//
|
||||
// return channel.attr(IntegratedHybridProvider.SESSION_KEY).get(); // TODO re-use Floodgate's attribute key here?
|
||||
// }
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.floodgate.BungeePlatform;
|
||||
import org.geysermc.floodgate.pluginmessage.BungeeSkinApplier;
|
||||
import org.geysermc.floodgate.skin.SkinApplier;
|
||||
@ -50,6 +49,7 @@ import org.geysermc.geyser.ping.IGeyserPingPassthrough;
|
||||
import org.geysermc.geyser.platform.bungeecord.command.GeyserBungeeCommandExecutor;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -110,7 +110,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
||||
this.geyserLogger = new GeyserBungeeLogger(getLogger(), geyserConfig.isDebugMode());
|
||||
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
||||
|
||||
this.geyser = GeyserImpl.load(PlatformType.BUNGEECORD, this);
|
||||
this.geyser = GeyserImpl.load(PlatformType.BUNGEECORD, this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,7 +36,6 @@ import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserBootstrap;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.GeyserLogger;
|
||||
@ -53,6 +52,7 @@ import org.geysermc.geyser.platform.fabric.command.GeyserFabricCommandExecutor;
|
||||
import org.geysermc.geyser.platform.fabric.world.GeyserFabricWorldManager;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -42,7 +42,6 @@ import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.floodgate.pluginmessage.SpigotSkinApplier;
|
||||
import org.geysermc.floodgate.skin.SkinApplier;
|
||||
import org.geysermc.floodgate.util.SpigotVersionSpecificMethods;
|
||||
@ -71,6 +70,7 @@ import org.geysermc.geyser.platform.spigot.world.manager.GeyserSpigotNativeWorld
|
||||
import org.geysermc.geyser.platform.spigot.world.manager.GeyserSpigotWorldManager;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -158,7 +158,7 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
||||
|
||||
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
||||
|
||||
this.geyser = GeyserImpl.load(PlatformType.SPIGOT, this);
|
||||
this.geyser = GeyserImpl.load(PlatformType.SPIGOT, this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,7 +27,6 @@ package org.geysermc.geyser.platform.sponge;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserBootstrap;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
@ -37,10 +36,11 @@ 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.platform.sponge.command.GeyserSpongeCommandManager;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.platform.sponge.command.GeyserSpongeCommandExecutor;
|
||||
import org.geysermc.geyser.platform.sponge.command.GeyserSpongeCommandManager;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
import org.spongepowered.api.Server;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.config.ConfigDir;
|
||||
@ -141,7 +141,7 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
|
||||
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
||||
this.geyserLogger = new GeyserSpongeLogger(logger, geyserConfig.isDebugMode());
|
||||
|
||||
this.geyser = GeyserImpl.load(PlatformType.SPONGE, this);
|
||||
this.geyser = GeyserImpl.load(PlatformType.SPONGE, this, null);
|
||||
|
||||
this.geyserCommandManager = new GeyserSpongeCommandManager(geyser);
|
||||
this.geyserCommandManager.init();
|
||||
|
@ -38,7 +38,6 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.core.Appender;
|
||||
import org.apache.logging.log4j.core.Logger;
|
||||
import org.apache.logging.log4j.core.appender.ConsoleAppender;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserBootstrap;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||
@ -51,6 +50,7 @@ import org.geysermc.geyser.platform.standalone.gui.GeyserStandaloneGUI;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.geysermc.geyser.util.LoopbackUtil;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -216,7 +216,7 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
|
||||
// Allow libraries like Protocol to have their debug information passthrough
|
||||
logger.get().setLevel(geyserConfig.isDebugMode() ? Level.DEBUG : Level.INFO);
|
||||
|
||||
geyser = GeyserImpl.load(PlatformType.STANDALONE, this);
|
||||
geyser = GeyserImpl.load(PlatformType.STANDALONE, this, null);
|
||||
GeyserImpl.start();
|
||||
|
||||
geyserCommandManager = new GeyserCommandManager(geyser);
|
||||
|
@ -1,5 +1,6 @@
|
||||
dependencies {
|
||||
annotationProcessor(libs.velocity.api)
|
||||
implementation("org.geysermc.floodgate", "velocity", "2.2.0-SNAPSHOT")
|
||||
api(projects.core)
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
package org.geysermc.geyser.platform.velocity;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.velocitypowered.api.command.CommandManager;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ListenerBoundEvent;
|
||||
@ -36,7 +37,7 @@ import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.util.Codec;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.floodgate.FloodgatePlatform;
|
||||
import org.geysermc.geyser.GeyserBootstrap;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
@ -48,8 +49,10 @@ import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
|
||||
import org.geysermc.geyser.ping.IGeyserPingPassthrough;
|
||||
import org.geysermc.geyser.platform.velocity.command.GeyserVelocityCommandExecutor;
|
||||
import org.geysermc.geyser.platform.velocity.floodgate.FloodgateVelocityPlatform;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -85,6 +88,9 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||
@Getter
|
||||
private final Path configFolder = Paths.get("plugins/" + GeyserImpl.NAME + "-Velocity/");
|
||||
|
||||
@Inject
|
||||
private Injector guice;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
@ -130,7 +136,12 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||
this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode());
|
||||
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
||||
|
||||
this.geyser = GeyserImpl.load(PlatformType.VELOCITY, this);
|
||||
FloodgatePlatform platform = null;
|
||||
if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE) {
|
||||
platform = guice.getInstance(FloodgateVelocityPlatform.class);
|
||||
}
|
||||
|
||||
this.geyser = GeyserImpl.load(PlatformType.VELOCITY, this, platform);
|
||||
|
||||
// Remove this in like a year
|
||||
try {
|
||||
@ -142,15 +153,15 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
|
||||
if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && proxyServer.getPluginManager().getPlugin("floodgate").isEmpty()) {
|
||||
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " "
|
||||
+ GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
||||
return;
|
||||
} else if (geyserConfig.isAutoconfiguredRemote() && proxyServer.getPluginManager().getPlugin("floodgate").isPresent()) {
|
||||
// Floodgate installed means that the user wants Floodgate authentication
|
||||
geyserLogger.debug("Auto-setting to Floodgate authentication.");
|
||||
geyserConfig.getRemote().setAuthType(AuthType.FLOODGATE);
|
||||
}
|
||||
// if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && proxyServer.getPluginManager().getPlugin("floodgate").isEmpty()) {
|
||||
// geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " "
|
||||
// + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
||||
// return;
|
||||
// } else if (geyserConfig.isAutoconfiguredRemote() && proxyServer.getPluginManager().getPlugin("floodgate").isPresent()) {
|
||||
// // Floodgate installed means that the user wants Floodgate authentication
|
||||
// geyserLogger.debug("Auto-setting to Floodgate authentication.");
|
||||
// geyserConfig.getRemote().setAuthType(AuthType.FLOODGATE);
|
||||
// }
|
||||
|
||||
geyserConfig.loadFloodgate(this, proxyServer, configFolder.toFile());
|
||||
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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.velocity.floodgate;
|
||||
|
||||
import com.google.inject.Module;
|
||||
import org.geysermc.floodgate.VelocityPlatform;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.floodgate.GeyserLoadStage;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
public class FloodgateVelocityPlatform extends VelocityPlatform {
|
||||
@Override
|
||||
protected List<Module> loadStageModules() {
|
||||
// Geyser being a dumb dumb
|
||||
super.dataDirectory = Paths.get("plugins/" + GeyserImpl.NAME + "-Velocity/");
|
||||
|
||||
var loaded = super.loadStageModules();
|
||||
loaded.add(new GeyserLoadStage());
|
||||
return loaded;
|
||||
}
|
||||
}
|
@ -7,8 +7,8 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api("org.geysermc.floodgate", "core", "2.2.0-SNAPSHOT")
|
||||
api(projects.geyserApi)
|
||||
api(projects.common)
|
||||
|
||||
// Jackson JSON and YAML serialization
|
||||
api(libs.bundles.jackson)
|
||||
@ -60,10 +60,6 @@ dependencies {
|
||||
compileOnly(projects.ap)
|
||||
|
||||
annotationProcessor(projects.ap)
|
||||
|
||||
implementation("org.geysermc.floodgate", "core", "2.2.0-SNAPSHOT") {
|
||||
exclude("org.geysermc", "api")
|
||||
}
|
||||
}
|
||||
|
||||
configurations.api {
|
||||
|
@ -27,9 +27,9 @@ package org.geysermc.connector;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.BedrockServer;
|
||||
import org.geysermc.api.Geyser;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -47,11 +47,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.api.Geyser;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.cumulus.form.Form;
|
||||
import org.geysermc.cumulus.form.util.FormBuilder;
|
||||
import org.geysermc.floodgate.api.InstanceHolder;
|
||||
import org.geysermc.floodgate.api.impl.FloodgateApiWrapper;
|
||||
import org.geysermc.floodgate.FloodgatePlatform;
|
||||
import org.geysermc.floodgate.news.NewsItemAction;
|
||||
import org.geysermc.geyser.api.GeyserApi;
|
||||
import org.geysermc.geyser.api.event.EventBus;
|
||||
@ -155,11 +153,18 @@ public class GeyserImpl implements GeyserApi {
|
||||
|
||||
private static GeyserImpl instance;
|
||||
|
||||
private GeyserImpl(PlatformType platformType, GeyserBootstrap bootstrap) {
|
||||
instance = this;
|
||||
private final FloodgatePlatform floodgatePlatform;
|
||||
|
||||
Geyser.set(this);
|
||||
InstanceHolder.set(new FloodgateApiWrapper(this), null, null, null, null); // TODO
|
||||
private GeyserImpl(PlatformType platformType, GeyserBootstrap bootstrap, FloodgatePlatform floodgatePlatform) {
|
||||
instance = this;
|
||||
this.floodgatePlatform = floodgatePlatform;
|
||||
|
||||
if (floodgatePlatform != null) {
|
||||
floodgatePlatform.load();
|
||||
floodgatePlatform.enable();
|
||||
} else {
|
||||
Geyser.set(this);
|
||||
}
|
||||
|
||||
this.platformType = platformType;
|
||||
this.bootstrap = bootstrap;
|
||||
@ -613,9 +618,9 @@ public class GeyserImpl implements GeyserApi {
|
||||
return Integer.parseInt(BUILD_NUMBER);
|
||||
}
|
||||
|
||||
public static GeyserImpl load(PlatformType platformType, GeyserBootstrap bootstrap) {
|
||||
public static GeyserImpl load(PlatformType platformType, GeyserBootstrap bootstrap, FloodgatePlatform floodgatePlatform) {
|
||||
if (instance == null) {
|
||||
return new GeyserImpl(platformType, bootstrap);
|
||||
return new GeyserImpl(platformType, bootstrap, floodgatePlatform);
|
||||
}
|
||||
|
||||
return instance;
|
||||
|
@ -29,38 +29,22 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
import org.geysermc.geyser.api.command.CommandExecutor;
|
||||
import org.geysermc.geyser.api.command.CommandSource;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserDefineCommandsEvent;
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
import org.geysermc.geyser.command.defaults.AdvancedTooltipsCommand;
|
||||
import org.geysermc.geyser.command.defaults.AdvancementsCommand;
|
||||
import org.geysermc.geyser.command.defaults.ConnectionTestCommand;
|
||||
import org.geysermc.geyser.command.defaults.DumpCommand;
|
||||
import org.geysermc.geyser.command.defaults.ExtensionsCommand;
|
||||
import org.geysermc.geyser.command.defaults.HelpCommand;
|
||||
import org.geysermc.geyser.command.defaults.ListCommand;
|
||||
import org.geysermc.geyser.command.defaults.OffhandCommand;
|
||||
import org.geysermc.geyser.command.defaults.ReloadCommand;
|
||||
import org.geysermc.geyser.command.defaults.SettingsCommand;
|
||||
import org.geysermc.geyser.command.defaults.StatisticsCommand;
|
||||
import org.geysermc.geyser.command.defaults.StopCommand;
|
||||
import org.geysermc.geyser.command.defaults.VersionCommand;
|
||||
import org.geysermc.geyser.command.defaults.*;
|
||||
import org.geysermc.geyser.event.type.GeyserDefineCommandsEventImpl;
|
||||
import org.geysermc.geyser.extension.command.GeyserExtensionCommand;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class GeyserCommandManager {
|
||||
|
@ -26,13 +26,13 @@
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.LoopbackUtil;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
import org.geysermc.geyser.util.WebUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -30,7 +30,6 @@ import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
@ -39,6 +38,7 @@ import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.AsteriskSerializer;
|
||||
import org.geysermc.geyser.text.ChatColor;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
import org.geysermc.geyser.util.WebUtils;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
@ -33,6 +32,7 @@ import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.ChatColor;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
@ -25,12 +25,12 @@
|
||||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
public class ReloadCommand extends GeyserCommand {
|
||||
|
||||
|
@ -25,12 +25,12 @@
|
||||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
@ -34,6 +33,7 @@ import org.geysermc.geyser.network.GameProtocol;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.ChatColor;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
import org.geysermc.geyser.util.WebUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -27,9 +27,9 @@ package org.geysermc.geyser.dump;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.text.AsteriskSerializer;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -37,7 +37,6 @@ import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.api.util.BedrockPlatform;
|
||||
import org.geysermc.floodgate.util.FloodgateInfoHolder;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.GeyserApi;
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
@ -233,8 +232,11 @@ public class DumpInfo {
|
||||
private final Object config;
|
||||
|
||||
Floodgate() {
|
||||
this.gitInfo = FloodgateInfoHolder.getGitProperties();
|
||||
this.config = FloodgateInfoHolder.getConfig();
|
||||
//todo we can get the information from Floodgate directly now
|
||||
this.gitInfo = null;
|
||||
this.config = null;
|
||||
// this.gitInfo = FloodgateInfoHolder.getGitProperties();
|
||||
// this.config = FloodgateInfoHolder.getConfig();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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.floodgate;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.name.Named;
|
||||
|
||||
public class GeyserLoadStage extends AbstractModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
@Named("configFile")
|
||||
private String floodgateConfigName() {
|
||||
return "floodgate.yml";
|
||||
}
|
||||
}
|
@ -26,10 +26,8 @@
|
||||
package org.geysermc.geyser.hybrid;
|
||||
|
||||
import org.geysermc.floodgate.crypto.FloodgateCipher;
|
||||
import org.geysermc.floodgate.pluginmessage.PluginMessageChannels;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.PluginMessageUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@ -37,14 +35,15 @@ public final class FloodgateHybridProvider implements HybridProvider {
|
||||
private final FloodgateCipher cipher;
|
||||
|
||||
public FloodgateHybridProvider(GeyserImpl geyser) {
|
||||
cipher = HybridProvider.getOrCreateKey(geyser);
|
||||
cipher = geyser.getFloodgatePlatform().getInstance(FloodgateCipher.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSkinUpload(GeyserSession session, String value, String signature) {
|
||||
byte[] bytes = (value + '\0' + signature)
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
PluginMessageUtils.sendMessage(session, PluginMessageChannels.SKIN, bytes);
|
||||
//todo
|
||||
// PluginMessageUtils.sendMessage(session, PluginMessageChannels.SKIN, bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,66 +25,11 @@
|
||||
|
||||
package org.geysermc.geyser.hybrid;
|
||||
|
||||
import org.geysermc.floodgate.crypto.AesCipher;
|
||||
import org.geysermc.floodgate.crypto.AesKeyProducer;
|
||||
import org.geysermc.floodgate.crypto.Base64Topping;
|
||||
import org.geysermc.floodgate.crypto.FloodgateCipher;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.GeyserLogger;
|
||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.Key;
|
||||
|
||||
public interface HybridProvider {
|
||||
void onSkinUpload(GeyserSession session, String value, String signature);
|
||||
|
||||
FloodgateCipher getCipher();
|
||||
|
||||
static FloodgateCipher getOrCreateKey(GeyserImpl geyser) {
|
||||
GeyserLogger logger = geyser.getLogger();
|
||||
GeyserConfiguration config = geyser.getConfig();
|
||||
try {
|
||||
// TODO make this common code with Floodgate. Like, make sure Geyser's core and Floodgate's core points to the same thing
|
||||
FloodgateCipher cipher = new AesCipher(new Base64Topping());
|
||||
|
||||
Path keyPath = config.getFloodgateKeyPath();
|
||||
if (!Files.exists(keyPath)) {
|
||||
generateFloodgateKey(cipher, keyPath); // Should also init the cipher for us.
|
||||
// TODO good?
|
||||
logger.info("We just created a Floodgate key at " + keyPath + ". You will need to copy this file into " +
|
||||
"your Floodgate config folder(s).");
|
||||
} else {
|
||||
Key key = new AesKeyProducer().produceFrom(keyPath);
|
||||
cipher.init(key);
|
||||
}
|
||||
logger.debug(GeyserLocale.getLocaleStringLog("geyser.auth.floodgate.loaded_key"));
|
||||
return cipher;
|
||||
} catch (Exception exception) {
|
||||
logger.severe(GeyserLocale.getLocaleStringLog("geyser.auth.floodgate.bad_key"), exception);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static void generateFloodgateKey(FloodgateCipher cipher, Path keyPath) throws Exception {
|
||||
Key key = new AesKeyProducer().produce();
|
||||
cipher.init(key);
|
||||
|
||||
String test = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
byte[] encrypted = cipher.encryptFromString(test);
|
||||
String decrypted = cipher.decryptToString(encrypted);
|
||||
|
||||
if (!test.equals(decrypted)) {
|
||||
throw new RuntimeException("Failed to decrypt test message.\n" +
|
||||
"Original message: " + test + "." +
|
||||
"Decrypted message: " + decrypted + ".\n" +
|
||||
"The encrypted message itself: " + new String(encrypted)
|
||||
);
|
||||
}
|
||||
|
||||
Files.write(keyPath, key.getEncoded());
|
||||
}
|
||||
}
|
||||
|
@ -26,35 +26,18 @@
|
||||
package org.geysermc.geyser.hybrid;
|
||||
|
||||
import org.geysermc.floodgate.crypto.FloodgateCipher;
|
||||
import org.geysermc.floodgate.util.BedrockData;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public final class ProxyHybridProvider extends IntegratedHybridProvider {
|
||||
private final FloodgateCipher cipher;
|
||||
|
||||
public ProxyHybridProvider(GeyserImpl geyser) {
|
||||
super(geyser);
|
||||
this.cipher = HybridProvider.getOrCreateKey(geyser);
|
||||
this.cipher = geyser.getFloodgatePlatform().getInstance(FloodgateCipher.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloodgateCipher getCipher() {
|
||||
return cipher;
|
||||
}
|
||||
|
||||
// TODO copied from ProxyFloodgateApi
|
||||
public byte[] createEncryptedData(BedrockData bedrockData) {
|
||||
try {
|
||||
return cipher.encryptFromString(bedrockData.toString());
|
||||
} catch (Exception exception) {
|
||||
throw new IllegalStateException("We failed to create the encrypted data, " +
|
||||
"but creating encrypted data is mandatory!", exception);
|
||||
}
|
||||
}
|
||||
|
||||
public String createEncryptedDataString(BedrockData bedrockData) {
|
||||
return new String(createEncryptedData(bedrockData), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
@ -29,12 +29,12 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundTa
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundLightUpdatePacket;
|
||||
import com.nukkitx.protocol.bedrock.BedrockPacket;
|
||||
import io.netty.channel.EventLoop;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.registry.loader.RegistryLoaders;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
|
@ -94,7 +94,6 @@ import org.checkerframework.common.value.qual.IntRange;
|
||||
import org.geysermc.api.util.BedrockPlatform;
|
||||
import org.geysermc.api.util.InputMode;
|
||||
import org.geysermc.api.util.UiProfile;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.cumulus.form.Form;
|
||||
import org.geysermc.cumulus.form.util.FormBuilder;
|
||||
import org.geysermc.floodgate.crypto.FloodgateCipher;
|
||||
@ -136,10 +135,7 @@ import org.geysermc.geyser.text.MinecraftLocale;
|
||||
import org.geysermc.geyser.text.TextDecoration;
|
||||
import org.geysermc.geyser.translator.inventory.InventoryTranslator;
|
||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||
import org.geysermc.geyser.util.ChunkUtils;
|
||||
import org.geysermc.geyser.util.DimensionUtils;
|
||||
import org.geysermc.geyser.util.LoginEncryptionUtils;
|
||||
import org.geysermc.geyser.util.MathUtils;
|
||||
import org.geysermc.geyser.util.*;
|
||||
|
||||
import java.net.ConnectException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
@ -36,7 +36,6 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||
import org.geysermc.geyser.level.physics.Axis;
|
||||
import org.geysermc.geyser.level.physics.BoundingBox;
|
||||
@ -49,6 +48,7 @@ import org.geysermc.geyser.translator.collision.BlockCollision;
|
||||
import org.geysermc.geyser.util.BlockEntityUtils;
|
||||
import org.geysermc.geyser.util.BlockUtils;
|
||||
import org.geysermc.geyser.util.ChunkUtils;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
@ -26,12 +26,12 @@
|
||||
package org.geysermc.geyser.translator.protocol.bedrock;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.packet.CommandRequestPacket;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
@Translator(packet = CommandRequestPacket.class)
|
||||
public class BedrockCommandRequestTranslator extends PacketTranslator<CommandRequestPacket> {
|
||||
|
@ -26,16 +26,6 @@
|
||||
package org.geysermc.geyser.translator.protocol.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.nukkitx.protocol.bedrock.packet.TransferPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.UnknownPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import org.geysermc.cumulus.Forms;
|
||||
import org.geysermc.cumulus.form.Form;
|
||||
import org.geysermc.cumulus.form.util.FormType;
|
||||
import org.geysermc.floodgate.pluginmessage.PluginMessageChannels;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.GeyserLogger;
|
||||
import org.geysermc.geyser.api.network.AuthType;
|
||||
@ -43,8 +33,6 @@ import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Translator(packet = ClientboundCustomPayloadPacket.class)
|
||||
public class JavaCustomPayloadTranslator extends PacketTranslator<ClientboundCustomPayloadPacket> {
|
||||
private final GeyserLogger logger = GeyserImpl.getInstance().getLogger();
|
||||
@ -58,75 +46,76 @@ public class JavaCustomPayloadTranslator extends PacketTranslator<ClientboundCus
|
||||
|
||||
String channel = packet.getChannel();
|
||||
|
||||
if (channel.equals(PluginMessageChannels.FORM)) {
|
||||
byte[] data = packet.getData();
|
||||
|
||||
// receive: first byte is form type, second and third are the id, remaining is the form data
|
||||
// respond: first and second byte id, remaining is form response data
|
||||
|
||||
FormType type = FormType.fromOrdinal(data[0]);
|
||||
if (type == null) {
|
||||
throw new NullPointerException("Got type " + data[0] + " which isn't a valid form type!");
|
||||
}
|
||||
|
||||
String dataString = new String(data, 3, data.length - 3, Charsets.UTF_8);
|
||||
|
||||
Form form = Forms.fromJson(dataString, type, (ignored, response) -> {
|
||||
byte[] finalData;
|
||||
if (response == null) {
|
||||
// Response data can be null as of 1.19.20 (same behaviour as empty response data)
|
||||
// Only need to send the form id
|
||||
finalData = new byte[]{data[1], data[2]};
|
||||
} else {
|
||||
byte[] raw = response.getBytes(StandardCharsets.UTF_8);
|
||||
finalData = new byte[raw.length + 2];
|
||||
|
||||
finalData[0] = data[1];
|
||||
finalData[1] = data[2];
|
||||
System.arraycopy(raw, 0, finalData, 2, raw.length);
|
||||
}
|
||||
|
||||
session.sendDownstreamPacket(new ServerboundCustomPayloadPacket(channel, finalData));
|
||||
});
|
||||
session.sendForm(form);
|
||||
|
||||
} else if (channel.equals(PluginMessageChannels.TRANSFER)) {
|
||||
byte[] data = packet.getData();
|
||||
|
||||
// port (4 bytes), address (remaining data)
|
||||
if (data.length < 5) {
|
||||
throw new NullPointerException("Transfer data should be at least 5 bytes long");
|
||||
}
|
||||
|
||||
int port = data[0] << 24 | (data[1] & 0xFF) << 16 | (data[2] & 0xFF) << 8 | data[3] & 0xFF;
|
||||
String address = new String(data, 4, data.length - 4);
|
||||
|
||||
if (logger.isDebug()) {
|
||||
logger.info("Transferring client to: " + address + ":" + port);
|
||||
}
|
||||
|
||||
TransferPacket transferPacket = new TransferPacket();
|
||||
transferPacket.setAddress(address);
|
||||
transferPacket.setPort(port);
|
||||
session.sendUpstreamPacket(transferPacket);
|
||||
|
||||
} else if (channel.equals(PluginMessageChannels.PACKET)) {
|
||||
logger.debug("A packet has been sent using the Floodgate api");
|
||||
byte[] data = packet.getData();
|
||||
|
||||
// packet id, packet data
|
||||
if (data.length < 2) {
|
||||
throw new IllegalStateException("Packet data should be at least 2 bytes long");
|
||||
}
|
||||
|
||||
int packetId = data[0] & 0xFF;
|
||||
ByteBuf packetData = Unpooled.wrappedBuffer(data, 1, data.length - 1);
|
||||
|
||||
var toSend = new UnknownPacket();
|
||||
toSend.setPacketId(packetId);
|
||||
toSend.setPayload(packetData);
|
||||
|
||||
session.sendUpstreamPacket(toSend);
|
||||
}
|
||||
//todo
|
||||
// if (channel.equals(PluginMessageChannels.FORM)) {
|
||||
// byte[] data = packet.getData();
|
||||
//
|
||||
// // receive: first byte is form type, second and third are the id, remaining is the form data
|
||||
// // respond: first and second byte id, remaining is form response data
|
||||
//
|
||||
// FormType type = FormType.fromOrdinal(data[0]);
|
||||
// if (type == null) {
|
||||
// throw new NullPointerException("Got type " + data[0] + " which isn't a valid form type!");
|
||||
// }
|
||||
//
|
||||
// String dataString = new String(data, 3, data.length - 3, Charsets.UTF_8);
|
||||
//
|
||||
// Form form = Forms.fromJson(dataString, type, (ignored, response) -> {
|
||||
// byte[] finalData;
|
||||
// if (response == null) {
|
||||
// // Response data can be null as of 1.19.20 (same behaviour as empty response data)
|
||||
// // Only need to send the form id
|
||||
// finalData = new byte[]{data[1], data[2]};
|
||||
// } else {
|
||||
// byte[] raw = response.getBytes(StandardCharsets.UTF_8);
|
||||
// finalData = new byte[raw.length + 2];
|
||||
//
|
||||
// finalData[0] = data[1];
|
||||
// finalData[1] = data[2];
|
||||
// System.arraycopy(raw, 0, finalData, 2, raw.length);
|
||||
// }
|
||||
//
|
||||
// session.sendDownstreamPacket(new ServerboundCustomPayloadPacket(channel, finalData));
|
||||
// });
|
||||
// session.sendForm(form);
|
||||
//
|
||||
// } else if (channel.equals(PluginMessageChannels.TRANSFER)) {
|
||||
// byte[] data = packet.getData();
|
||||
//
|
||||
// // port (4 bytes), address (remaining data)
|
||||
// if (data.length < 5) {
|
||||
// throw new NullPointerException("Transfer data should be at least 5 bytes long");
|
||||
// }
|
||||
//
|
||||
// int port = data[0] << 24 | (data[1] & 0xFF) << 16 | (data[2] & 0xFF) << 8 | data[3] & 0xFF;
|
||||
// String address = new String(data, 4, data.length - 4);
|
||||
//
|
||||
// if (logger.isDebug()) {
|
||||
// logger.info("Transferring client to: " + address + ":" + port);
|
||||
// }
|
||||
//
|
||||
// TransferPacket transferPacket = new TransferPacket();
|
||||
// transferPacket.setAddress(address);
|
||||
// transferPacket.setPort(port);
|
||||
// session.sendUpstreamPacket(transferPacket);
|
||||
//
|
||||
// } else if (channel.equals(PluginMessageChannels.PACKET)) {
|
||||
// logger.debug("A packet has been sent using the Floodgate api");
|
||||
// byte[] data = packet.getData();
|
||||
//
|
||||
// // packet id, packet data
|
||||
// if (data.length < 2) {
|
||||
// throw new IllegalStateException("Packet data should be at least 2 bytes long");
|
||||
// }
|
||||
//
|
||||
// int packetId = data[0] & 0xFF;
|
||||
// ByteBuf packetData = Unpooled.wrappedBuffer(data, 1, data.length - 1);
|
||||
//
|
||||
// var toSend = new UnknownPacket();
|
||||
// toSend.setPacketId(packetId);
|
||||
// toSend.setPayload(packetData);
|
||||
//
|
||||
// session.sendUpstreamPacket(toSend);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,13 @@ import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundLog
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.network.GameProtocol;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -35,7 +35,6 @@ import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import org.geysermc.floodgate.pluginmessage.PluginMessageChannels;
|
||||
import org.geysermc.geyser.api.network.AuthType;
|
||||
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
|
||||
import org.geysermc.geyser.level.JavaDimension;
|
||||
@ -142,7 +141,8 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
||||
|
||||
// register the plugin messaging channels used in Floodgate
|
||||
if (session.remoteServer().authType() == AuthType.FLOODGATE) {
|
||||
session.sendDownstreamPacket(new ServerboundCustomPayloadPacket("minecraft:register", PluginMessageChannels.getFloodgateRegisterData()));
|
||||
//todo
|
||||
// session.sendDownstreamPacket(new ServerboundCustomPayloadPacket("minecraft:register", PluginMessageChannels.getFloodgateRegisterData()));
|
||||
}
|
||||
|
||||
if (!newDimension.equals(session.getDimension())) {
|
||||
|
@ -33,7 +33,6 @@ import com.nukkitx.nbt.NbtMapBuilder;
|
||||
import com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.BlockEventPacket;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMaps;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||
import org.geysermc.geyser.level.physics.Direction;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
@ -41,6 +40,7 @@ import org.geysermc.geyser.session.cache.PistonCache;
|
||||
import org.geysermc.geyser.translator.level.block.entity.PistonBlockEntity;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
@Translator(packet = ClientboundBlockEventPacket.class)
|
||||
public class JavaBlockEventTranslator extends PacketTranslator<ClientboundBlockEventPacket> {
|
||||
|
@ -29,12 +29,12 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.Clientb
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.registry.BlockRegistries;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.translator.sound.BlockSoundInteractionTranslator;
|
||||
import org.geysermc.geyser.util.PlatformType;
|
||||
|
||||
@Translator(packet = ClientboundBlockUpdatePacket.class)
|
||||
public class JavaBlockUpdateTranslator extends PacketTranslator<ClientboundBlockUpdatePacket> {
|
||||
|
@ -23,7 +23,7 @@
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.common;
|
||||
package org.geysermc.geyser.util;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren