diff --git a/README_EAGLERXVELOCITY.md b/README_EAGLERXVELOCITY.md index 8711c9f2..3d899adf 100644 --- a/README_EAGLERXVELOCITY.md +++ b/README_EAGLERXVELOCITY.md @@ -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` diff --git a/gateway/EaglercraftXVelocity/EaglerXVelocity-Latest.jar b/gateway/EaglercraftXVelocity/EaglerXVelocity-Latest.jar index e2280916..c65364f5 100644 Binary files a/gateway/EaglercraftXVelocity/EaglerXVelocity-Latest.jar and b/gateway/EaglercraftXVelocity/EaglerXVelocity-Latest.jar differ diff --git a/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/EaglerXVelocity.java b/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/EaglerXVelocity.java index 598a2d86..c11b5b2c 100644 --- a/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/EaglerXVelocity.java +++ b/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/EaglerXVelocity.java @@ -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; diff --git a/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/EaglerXVelocityVersion.java b/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/EaglerXVelocityVersion.java index 78f912ea..89a417f0 100644 --- a/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/EaglerXVelocityVersion.java +++ b/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/EaglerXVelocityVersion.java @@ -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" }; } diff --git a/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/config/EaglerVelocityConfig.java b/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/config/EaglerVelocityConfig.java index 93c7e6e9..15adb7f5 100644 --- a/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/config/EaglerVelocityConfig.java +++ b/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/config/EaglerVelocityConfig.java @@ -190,6 +190,7 @@ public class EaglerVelocityConfig { boolean disableFNAWSkinsEverywhere = configYml.getBoolean("disable_fnaw_skins_everywhere", false); Set disableFNAWSkinsOnServers = new HashSet<>((Collection)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 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 iceServers, boolean enableVoiceChat, Set disableVoiceOnServers, boolean disableFNAWSkinsEverywhere, Set 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; } diff --git a/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/handlers/EaglerPacketEventListener.java b/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/handlers/EaglerPacketEventListener.java index ff477fe3..b0fef0c6 100644 --- a/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/handlers/EaglerPacketEventListener.java +++ b/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/handlers/EaglerPacketEventListener.java @@ -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(); diff --git a/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/server/backend_rpc_protocol/BackendRPCSessionHandler.java b/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/server/backend_rpc_protocol/BackendRPCSessionHandler.java index f8cc6b35..486eecdb 100644 --- a/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/server/backend_rpc_protocol/BackendRPCSessionHandler.java +++ b/gateway/EaglercraftXVelocity/src/main/java/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/server/backend_rpc_protocol/BackendRPCSessionHandler.java @@ -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; + } + } diff --git a/gateway/EaglercraftXVelocity/src/main/resources/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/config/default_settings.yml b/gateway/EaglercraftXVelocity/src/main/resources/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/config/default_settings.yml index d20586eb..99c36e1b 100644 --- a/gateway/EaglercraftXVelocity/src/main/resources/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/config/default_settings.yml +++ b/gateway/EaglercraftXVelocity/src/main/resources/net/lax1dude/eaglercraft/v1_8/plugin/gateway_velocity/config/default_settings.yml @@ -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 \ No newline at end of file +enable_backend_rpc_api: false +use_modernized_channel_names: false \ No newline at end of file diff --git a/gateway/EaglercraftXVelocity/src/main/resources/velocity-plugin.json b/gateway/EaglercraftXVelocity/src/main/resources/velocity-plugin.json index a8a94115..3c28e44b 100644 --- a/gateway/EaglercraftXVelocity/src/main/resources/velocity-plugin.json +++ b/gateway/EaglercraftXVelocity/src/main/resources/velocity-plugin.json @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/gateway_version_velocity b/gateway_version_velocity index 1cc5f657..8cfbc905 100644 --- a/gateway_version_velocity +++ b/gateway_version_velocity @@ -1 +1 @@ -1.1.0 \ No newline at end of file +1.1.1 \ No newline at end of file