From 76a3af84a1c1e2fa5db1c261449608771db9253a Mon Sep 17 00:00:00 2001 From: games647 Date: Fri, 28 Apr 2017 02:49:37 +0200 Subject: [PATCH] Strictly match the sendPacket method Related to #322 --- .../com/comphenix/protocol/utility/MinecraftMethods.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftMethods.java b/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftMethods.java index 095070e6..1c8f3b86 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftMethods.java +++ b/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftMethods.java @@ -16,6 +16,7 @@ import net.sf.cglib.proxy.MethodProxy; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.reflect.FuzzyReflection; +import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract; /** * Static methods for accessing Minecraft methods. @@ -43,7 +44,13 @@ public class MinecraftMethods { Class serverHandlerClass = MinecraftReflection.getPlayerConnectionClass(); try { - sendPacketMethod = FuzzyReflection.fromClass(serverHandlerClass).getMethodByName("sendPacket.*"); + sendPacketMethod = FuzzyReflection + .fromClass(serverHandlerClass) + .getMethod(FuzzyMethodContract.newBuilder() + .nameRegex("sendPacket.*") + .returnTypeVoid() + .parameterCount(1) + .build()); } catch (IllegalArgumentException e) { // We can't use the method below on Netty if (MinecraftReflection.isUsingNetty()) {