Skip to content

Commit 76a3af8

Browse files
games647dmulloy2
authored andcommitted
Strictly match the sendPacket method
Related to #322
1 parent be5d42e commit 76a3af8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftMethods.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.comphenix.protocol.PacketType;
1717
import com.comphenix.protocol.events.PacketContainer;
1818
import com.comphenix.protocol.reflect.FuzzyReflection;
19+
import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract;
1920

2021
/**
2122
* Static methods for accessing Minecraft methods.
@@ -43,7 +44,13 @@ public static Method getSendPacketMethod() {
4344
Class<?> serverHandlerClass = MinecraftReflection.getPlayerConnectionClass();
4445

4546
try {
46-
sendPacketMethod = FuzzyReflection.fromClass(serverHandlerClass).getMethodByName("sendPacket.*");
47+
sendPacketMethod = FuzzyReflection
48+
.fromClass(serverHandlerClass)
49+
.getMethod(FuzzyMethodContract.newBuilder()
50+
.nameRegex("sendPacket.*")
51+
.returnTypeVoid()
52+
.parameterCount(1)
53+
.build());
4754
} catch (IllegalArgumentException e) {
4855
// We can't use the method below on Netty
4956
if (MinecraftReflection.isUsingNetty()) {

0 commit comments

Comments
 (0)