Skip to content

Commit

Permalink
Ignore new ServerData packet that was throwing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanKeir committed Sep 19, 2022
1 parent 78666de commit bb7511d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plugins {
// --
// Variables
// --
version = '2.6.0'
version = '2.6.1'
group = 'net.tcpshield.tcpshield'
archivesBaseName = 'TCPShield'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ public class VelocityHandshakeHandler {

private final TCPShieldPlugin plugin;


private static Class<?> CONNECTED_PLAYER_CONNECTION_CLASS;

static {
try {
CONNECTED_PLAYER_CONNECTION_CLASS = Class.forName("com.velocitypowered.proxy.connection.client.ConnectedPlayer");
} catch (Exception e) {
// ignore for old velocity versions
}
}

public VelocityHandshakeHandler(TCPShieldPlugin plugin) {
this.plugin = plugin;
}
Expand All @@ -42,6 +53,12 @@ public void onHandshake(ConnectionHandshakeEvent e) {
@Subscribe(order = PostOrder.FIRST)
public void onProxyPing(ProxyPingEvent e) {
InboundConnection connection = e.getConnection();

if (connection.getClass() == CONNECTED_PLAYER_CONNECTION_CLASS) {
// new ServerData (0x42) packet on connect, we don't care about it
return;
}

handleEvent(connection, "onProxyPing");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.tcpshield.tcpshield.provider.PlayerProvider;
import net.tcpshield.tcpshield.util.ReflectionUtil;
import net.tcpshield.tcpshield.util.exception.manipulate.PlayerManipulationException;
import net.tcpshield.tcpshield.util.exception.phase.HandshakeException;
import net.tcpshield.tcpshield.util.exception.phase.InitializationException;
import net.tcpshield.tcpshield.util.exception.phase.ReflectionException;

Expand All @@ -27,6 +26,7 @@ public class VelocityPlayer implements PlayerProvider {
private static final Method CLOSE_CHANNEL_METHOD;

// new velocity support

private static Class<?> LOGIN_INBOUND_CONNECTION_CLASS;
private static Field LOGIN_INBOUND_CONNECTION_DELEGATE_FIELD;

Expand Down Expand Up @@ -149,7 +149,7 @@ public ConnectionType getConnectionType() {
}

enum ConnectionType {
LOGIN_INBOUND, INITIAL_INBOUND, LEGACY;
LOGIN_INBOUND, INITIAL_INBOUND, LEGACY
}

}
2 changes: 1 addition & 1 deletion src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: TCPShield
version: 2.6.0
version: 2.6.1
main: net.tcpshield.tcpshield.bungee.TCPShieldBungee
author: https://tcpshield.com
softdepends:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: TCPShield
version: 2.6.0
version: 2.6.1
main: net.tcpshield.tcpshield.bukkit.TCPShieldBukkit
softdepend:
- ProtocolLib
Expand Down
17 changes: 1 addition & 16 deletions src/main/resources/velocity-plugin.json
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
{
"id": "tcpshield",
"name": "TCPShield",
"version": "2.6.0",
"description": "TCPShield IP parsing capabilities for Velocity",
"authors": [
"TCPShield"
],
"dependencies": [
{
"id": "floodgate",
"optional": true
}
],
"main": "net.tcpshield.tcpshield.velocity.TCPShieldVelocity"
}
{"id":"tcpshield","name":"TCPShield","version":"2.6.1","description":"TCPShield IP parsing capabilities for Velocity","authors":["TCPShield"],"dependencies":[{"id":"floodgate","optional":true}],"main":"net.tcpshield.tcpshield.velocity.TCPShieldVelocity"}

0 comments on commit bb7511d

Please sign in to comment.