Packet constructor can now handle primitive parameter types.

This commit is contained in:
Kristian S. Stangeland 2012-10-21 16:33:41 +02:00
parent 43c0b5d8f1
commit 63c468eff0

View File

@ -25,6 +25,7 @@ import net.minecraft.server.Packet;
import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.FieldAccessException; import com.comphenix.protocol.reflect.FieldAccessException;
import com.comphenix.protocol.reflect.PrimitiveUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -176,7 +177,17 @@ public class PacketConstructor {
// Determine if the types are similar // Determine if the types are similar
if (params.length == types.length) { if (params.length == types.length) {
for (int i = 0; i < params.length; i++) { for (int i = 0; i < params.length; i++) {
if (!params[i].isAssignableFrom(types[i])) { Class<?> inputType = types[i];
Class<?> paramType = params[i];
// The input type is always wrapped
if (PrimitiveUtils.isPrimitive(paramType)) {
// Wrap it
paramType = PrimitiveUtils.wrap(paramType);
}
// Compare assignability
if (!paramType.isAssignableFrom(inputType)) {
return false; return false;
} }
} }