<1.1.1> Fix java players on MC 1.13+ kicked by EaglerXVelocity

This commit is contained in:
lax1dude 2024-09-24 20:39:44 -07:00
parent daf4cec182
commit 8a081266f4
10 changed files with 60 additions and 21 deletions

View File

@ -44,6 +44,7 @@ The settings.yml file is primarily used for configuring the built-in skin and ca
- **`disable_fnaw_skins_everywhere:`** Boolean, default value is `false`, can be used to globally disable FNAW skins if your players bitch about them a lot and are too lazy to just disable the FNAW skins locally on their clients.
- **`disable_fnaw_skins_on_servers:`** List of strings, default value is nothing (`[]`), contains a list of names of registered servers on your Velocity proxy that the FNAW skins should be disabled on. Good for explicitly disabling them for PVP but allowing them everywhere else.
- **`enable_backend_rpc_api:`** Boolean, default value is `false`, if support for servers running the EaglerXBukkitAPI plugin should be enabled or not.
- **use_modernized_channel_names:`** Boolean, default value is `false`, if "modernized" plugin channel names compatible with Minecraft 1.13+ should be used for EaglerXBukkitAPI plugin message packets
### `listeners.yml`

View File

@ -21,6 +21,7 @@ import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.network.ConnectionManager;
import com.velocitypowered.proxy.network.TransportType;
@ -197,6 +198,8 @@ public class EaglerXVelocity {
}
proxy.getChannelRegistrar().register(new LegacyChannelIdentifier(EaglerBackendRPCProtocol.CHANNEL_NAME));
proxy.getChannelRegistrar().register(new LegacyChannelIdentifier(EaglerBackendRPCProtocol.CHANNEL_NAME_READY));
proxy.getChannelRegistrar().register(MinecraftChannelIdentifier.from(EaglerBackendRPCProtocol.CHANNEL_NAME_MODERN));
proxy.getChannelRegistrar().register(MinecraftChannelIdentifier.from(EaglerBackendRPCProtocol.CHANNEL_NAME_READY_MODERN));
proxy.getChannelRegistrar().register(EaglerPacketEventListener.GET_DOMAIN_CHANNEL);
if(closeInactiveConnections != null) {
@ -308,10 +311,14 @@ public class EaglerXVelocity {
updateServiceTasks.cancel();
updateServiceTasks = null;
}
skinService.shutdown();
skinService = null;
capeService.shutdown();
capeService = null;
if(skinService != null) {
skinService.shutdown();
skinService = null;
}
if(capeService != null) {
capeService.shutdown();
capeService = null;
}
if(defaultAuthSystem != null) {
defaultAuthSystem.destroy();
defaultAuthSystem = null;

View File

@ -23,7 +23,7 @@ public class EaglerXVelocityVersion {
public static final String PLUGIN_ID = "eaglerxvelocity";
public static final String NAME = "EaglercraftXVelocity";
public static final String DESCRIPTION = "Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks";
public static final String VERSION = "1.1.0";
public static final String VERSION = "1.1.1";
public static final String[] AUTHORS = new String[] { "lax1dude", "ayunami2000" };
}

View File

@ -190,6 +190,7 @@ public class EaglerVelocityConfig {
boolean disableFNAWSkinsEverywhere = configYml.getBoolean("disable_fnaw_skins_everywhere", false);
Set<String> disableFNAWSkinsOnServers = new HashSet<>((Collection<String>)configYml.getList("disable_fnaw_skins_on_servers"));
boolean enableBackendRPCAPI = configYml.getBoolean("enable_backend_rpc_api", false);
boolean useModernizedChannelNames = configYml.getBoolean("use_modernized_channel_names", false);
final EaglerVelocityConfig ret = new EaglerVelocityConfig(serverName, serverUUID, websocketKeepAliveTimeout,
websocketHandshakeTimeout, builtinHttpServerTimeout, websocketCompressionLevel, serverListeners,
@ -197,7 +198,8 @@ public class EaglerVelocityConfig {
skinRateLimitPlayer, skinRateLimitGlobal, skinCacheURI, keepObjectsDays, keepProfilesDays, maxObjects,
maxProfiles, antagonistsRateLimit, sqliteDriverClass, sqliteDriverPath, eaglerPlayersVanillaSkin,
enableIsEaglerPlayerProperty, authConfig, updatesConfig, iceServers, voiceChat, disableVoiceOnServers,
disableFNAWSkinsEverywhere, disableFNAWSkinsOnServers, enableBackendRPCAPI, pauseMenuConfig);
disableFNAWSkinsEverywhere, disableFNAWSkinsOnServers, enableBackendRPCAPI, useModernizedChannelNames,
pauseMenuConfig);
if(eaglerPlayersVanillaSkin != null) {
VanillaDefaultSkinProfileLoader.lookupVanillaSkinUser(ret);
@ -334,6 +336,7 @@ public class EaglerVelocityConfig {
private final Set<String> disableFNAWSkinsOnServers;
private boolean isCrackedFlag;
private final boolean enableBackendRPCAPI;
private final boolean useModernizedChannelNames;
private final EaglerPauseMenuConfig pauseMenuConf;
Property[] eaglerPlayersVanillaSkinCached = new Property[] { isEaglerProperty };
@ -504,6 +507,10 @@ public class EaglerVelocityConfig {
return enableBackendRPCAPI;
}
public boolean getUseModernizedChannelNames() {
return useModernizedChannelNames;
}
public EaglerPauseMenuConfig getPauseMenuConf() {
return pauseMenuConf;
}
@ -518,7 +525,7 @@ public class EaglerVelocityConfig {
boolean enableIsEaglerPlayerProperty, EaglerAuthConfig authConfig, EaglerUpdateConfig updateConfig,
Collection<String> iceServers, boolean enableVoiceChat, Set<String> disableVoiceOnServers,
boolean disableFNAWSkinsEverywhere, Set<String> disableFNAWSkinsOnServers, boolean enableBackendRPCAPI,
EaglerPauseMenuConfig pauseMenuConf) {
boolean useModernizedChannelNames, EaglerPauseMenuConfig pauseMenuConf) {
this.serverName = serverName;
this.serverUUID = serverUUID;
this.serverListeners = serverListeners;
@ -551,6 +558,7 @@ public class EaglerVelocityConfig {
this.disableFNAWSkinsEverywhere = disableFNAWSkinsEverywhere;
this.disableFNAWSkinsOnServers = disableFNAWSkinsOnServers;
this.enableBackendRPCAPI = enableBackendRPCAPI;
this.useModernizedChannelNames = useModernizedChannelNames;
this.pauseMenuConf = pauseMenuConf;
}

View File

@ -22,6 +22,7 @@ import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
import com.velocitypowered.api.proxy.server.ServerInfo;
import com.velocitypowered.api.util.GameProfile;
import com.velocitypowered.api.util.GameProfile.Property;
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
import net.kyori.adventure.text.Component;
@ -68,9 +69,6 @@ public class EaglerPacketEventListener {
@Subscribe(order = PostOrder.FIRST)
public void onPluginMessage(final PluginMessageEvent event) {
ChannelIdentifier tagObj = event.getIdentifier();
if(!(tagObj instanceof LegacyChannelIdentifier)) {
return;
}
String tag = tagObj.getId();
if(event.getSource() instanceof ConnectedPlayer) {
final ConnectedPlayer player = (ConnectedPlayer)event.getSource();
@ -89,12 +87,12 @@ public class EaglerPacketEventListener {
return;
}
}
if(EaglerBackendRPCProtocol.CHANNEL_NAME.equals(tag)) {
if(EaglerBackendRPCProtocol.CHANNEL_NAME.equals(tag) || EaglerBackendRPCProtocol.CHANNEL_NAME_MODERN.equals(tag)) {
player.disconnect(Component.text("Nope!"));
event.setResult(ForwardResult.handled());
return;
}
if(EaglerBackendRPCProtocol.CHANNEL_NAME_READY.equals(tag)) {
if(EaglerBackendRPCProtocol.CHANNEL_NAME_READY.equals(tag) || EaglerBackendRPCProtocol.CHANNEL_NAME_READY_MODERN.equals(tag)) {
event.setResult(ForwardResult.handled());
return;
}
@ -103,7 +101,7 @@ public class EaglerPacketEventListener {
ConnectedPlayer player = (ConnectedPlayer)event.getTarget();
EaglerPlayerData eagPlayerData = EaglerPipeline.getEaglerHandle(player);
if(eagPlayerData != null) {
if(EaglerBackendRPCProtocol.CHANNEL_NAME.equals(tag)) {
if(EaglerBackendRPCProtocol.CHANNEL_NAME.equals(tag) || EaglerBackendRPCProtocol.CHANNEL_NAME_MODERN.equals(tag)) {
event.setResult(ForwardResult.handled());
try {
eagPlayerData.handleBackendRPCPacket((ServerConnection)event.getSource(), event.getData());
@ -120,7 +118,7 @@ public class EaglerPacketEventListener {
}
}
}else {
if(EaglerBackendRPCProtocol.CHANNEL_NAME.equals(tag)) {
if(EaglerBackendRPCProtocol.CHANNEL_NAME.equals(tag) || EaglerBackendRPCProtocol.CHANNEL_NAME_MODERN.equals(tag)) {
event.setResult(ForwardResult.handled());
try {
BackendRPCSessionHandler.handlePacketOnVanilla((ServerConnection)event.getSource(), player, event.getData());
@ -190,7 +188,8 @@ public class EaglerPacketEventListener {
try {
ConnectedPlayer player = (ConnectedPlayer) event.getPlayer();
ServerConnection server = player.getConnectedServer();
BackendRPCSessionHandler.sendPluginMessage(server, EaglerBackendRPCProtocol.CHANNEL_NAME_READY, EMPTY_BYTE_ARRAY);
BackendRPCSessionHandler.sendPluginMessage(server,
BackendRPCSessionHandler.getReadyChNameFor((VelocityServerConnection) server), EMPTY_BYTE_ARRAY);
EaglerPlayerData playerObj = EaglerPipeline.getEaglerHandle(player);
if(playerObj != null) {
ServerInfo sv = server.getServerInfo();

View File

@ -56,6 +56,7 @@ public class BackendRPCSessionHandler {
protected final EaglerPlayerData eaglerHandler;
private ServerConnection currentServer = null;
private String channelName = null;
private EaglerBackendRPCProtocol currentProtocol = null;
private EaglerBackendRPCHandler currentHandler = null;
private int subscribedEvents = 0;
@ -151,7 +152,7 @@ public class BackendRPCSessionHandler {
eaglerHandler.getSocketAddress(), packet.getClass().getSimpleName(), eaglerHandler.getName(),
ret.length, len);
}
sendPluginMessage(server, EaglerBackendRPCProtocol.CHANNEL_NAME, ret);
sendPluginMessage(server, channelName, ret);
}
public void handleConnectionLost() {
@ -162,6 +163,7 @@ public class BackendRPCSessionHandler {
private void handleDestroyContext() {
currentServer = null;
channelName = null;
currentProtocol = null;
currentHandler = null;
subscribedEvents = 0;
@ -179,6 +181,7 @@ public class BackendRPCSessionHandler {
if(!(packet instanceof CPacketRPCEnabled)) {
throw new WrongRPCPacketException();
}
channelName = getChNameFor((VelocityServerConnection)server);
if(!containsProtocol(((CPacketRPCEnabled)packet).supportedProtocols, EaglerBackendRPCProtocol.V1.vers)) {
EaglerXVelocity.logger().error("[{}]: Unsupported backend RPC protocol version for user \"{}\"", eaglerHandler.getSocketAddress(), eaglerHandler.getName());
sendRPCPacket(EaglerBackendRPCProtocol.INIT, server, new SPacketRPCEnabledFailure(SPacketRPCEnabledFailure.FAILURE_CODE_OUTDATED_SERVER));
@ -223,7 +226,7 @@ public class BackendRPCSessionHandler {
EaglerXVelocity.logger().error("(Note: this player is not using Eaglercraft!)");
return;
}
sendPluginMessage(server, EaglerBackendRPCProtocol.CHANNEL_NAME, bao.toByteArray());
sendPluginMessage(server, getChNameFor((VelocityServerConnection)server), bao.toByteArray());
return;
}
EaglerXVelocity.logger().warn("[{}]: Tried to open backend RPC protocol connection for non-eagler player \"{}\"", player.getRemoteAddress(), player.getUsername());
@ -236,7 +239,7 @@ public class BackendRPCSessionHandler {
EaglerXVelocity.logger().error("[{}]: Failed to write backend RPC protocol version for user \"{}\"", player.getRemoteAddress(), player.getUsername(), ex);
return;
}
sendPluginMessage(server, EaglerBackendRPCProtocol.CHANNEL_NAME, bao.toByteArray());
sendPluginMessage(server, getChNameFor((VelocityServerConnection)server), bao.toByteArray());
}
public void setSubscribedEvents(int eventsToEnable) {
@ -304,4 +307,24 @@ public class BackendRPCSessionHandler {
}
}
private static int getVerSafe(VelocityServerConnection server) {
try {
return server.getConnection().getProtocolVersion().getProtocol();
}catch(Throwable t) {
return -1;
}
}
public static String getChNameFor(VelocityServerConnection server) {
return (EaglerXVelocity.getEagler().getConfig().getUseModernizedChannelNames() || getVerSafe(server) >= 393)
? EaglerBackendRPCProtocol.CHANNEL_NAME_MODERN
: EaglerBackendRPCProtocol.CHANNEL_NAME;
}
public static String getReadyChNameFor(VelocityServerConnection server) {
return (EaglerXVelocity.getEagler().getConfig().getUseModernizedChannelNames() || getVerSafe(server) >= 393)
? EaglerBackendRPCProtocol.CHANNEL_NAME_READY_MODERN
: EaglerBackendRPCProtocol.CHANNEL_NAME_READY;
}
}

View File

@ -24,4 +24,5 @@ enable_is_eagler_player_property: true
disable_voice_chat_on_servers: []
disable_fnaw_skins_everywhere: false
disable_fnaw_skins_on_servers: []
enable_backend_rpc_api: false
enable_backend_rpc_api: false
use_modernized_channel_names: false

View File

@ -1 +1 @@
{"id":"eaglerxvelocity","name":"EaglercraftXVelocity","version":"1.1.0","description":"Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks","authors":["lax1dude", "ayunami2000"],"dependencies":[],"main":"net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.EaglerXVelocity"}
{"id":"eaglerxvelocity","name":"EaglercraftXVelocity","version":"1.1.1","description":"Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks","authors":["lax1dude", "ayunami2000"],"dependencies":[],"main":"net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.EaglerXVelocity"}

View File

@ -1 +1 @@
1.1.0
1.1.1