Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ void updateYamls() {

def yaml = new Yaml(options)

def bukkitYamlFile = new File('src/main/resources/plugin.yml')
def bungeeYamlFile = new File('src/main/resources/bungee.yml')
def bukkitYamlFile = new File(projectDir, 'src/main/resources/plugin.yml')
def bungeeYamlFile = new File(projectDir, 'src/main/resources/bungee.yml')

def files = [bukkitYamlFile, bungeeYamlFile]
files.each { file ->
Expand All @@ -163,7 +163,7 @@ void updateYamls() {
}

void updateJsons() {
def velocityJson = new File('src/main/resources/velocity-plugin.json')
def velocityJson = new File(projectDir, 'src/main/resources/velocity-plugin.json')

def files = [velocityJson]
files.each { file ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class VelocityPlayer implements PlayerProvider {
*/
private static final Class<?> INITIAL_INBOUND_CONNECTION_CLASS;
private static final Field MINECRAFT_CONNECTION_FIELD;
private static final Class<?> LEGACY_INBOUND_CONNECTION_CLASS;
private static final Field LEGACY_MINECRAFT_CONNECTION_FIELD;
private static final Field REMOTE_ADDRESS_FIELD;
private static final Method CLOSE_CHANNEL_METHOD;
Expand All @@ -30,7 +31,8 @@ public class VelocityPlayer implements PlayerProvider {
try {
INITIAL_INBOUND_CONNECTION_CLASS = Class.forName("com.velocitypowered.proxy.connection.client.InitialInboundConnection");
MINECRAFT_CONNECTION_FIELD = ReflectionUtil.getPrivateField(INITIAL_INBOUND_CONNECTION_CLASS, "connection");
LEGACY_MINECRAFT_CONNECTION_FIELD = ReflectionUtil.getPrivateField(Class.forName("com.velocitypowered.proxy.connection.client.HandshakeSessionHandler$LegacyInboundConnection"), "connection");
LEGACY_INBOUND_CONNECTION_CLASS = Class.forName("com.velocitypowered.proxy.connection.client.HandshakeSessionHandler$LegacyInboundConnection");
LEGACY_MINECRAFT_CONNECTION_FIELD = ReflectionUtil.getPrivateField(LEGACY_INBOUND_CONNECTION_CLASS, "connection");

Class<?> minecraftConnection = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection");
REMOTE_ADDRESS_FIELD = ReflectionUtil.getPrivateField(minecraftConnection, "remoteAddress");
Expand Down Expand Up @@ -94,6 +96,9 @@ public void setIP(InetSocketAddress ip) throws PlayerManipulationException {
@Override
public void disconnect() {
try {
if (!INITIAL_INBOUND_CONNECTION_CLASS.isAssignableFrom(inboundConnection.getClass()) && !LEGACY_INBOUND_CONNECTION_CLASS.isAssignableFrom(inboundConnection.getClass()))
return;

Object minecraftConnection = legacy ? LEGACY_MINECRAFT_CONNECTION_FIELD.get(inboundConnection) : MINECRAFT_CONNECTION_FIELD.get(inboundConnection);

CLOSE_CHANNEL_METHOD.invoke(minecraftConnection);
Expand Down