Archiviert
13
0

Fix getEntityModifier() for MPCP 1.6.2.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-07-21 03:20:13 +02:00
Ursprung 6054d559e1
Commit 5f54b95998

Datei anzeigen

@ -21,8 +21,8 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -35,6 +35,7 @@ import org.bukkit.entity.Player;
import com.comphenix.protocol.reflect.FieldAccessException; import com.comphenix.protocol.reflect.FieldAccessException;
import com.comphenix.protocol.reflect.FieldUtils; import com.comphenix.protocol.reflect.FieldUtils;
import com.comphenix.protocol.reflect.FuzzyReflection; import com.comphenix.protocol.reflect.FuzzyReflection;
import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract;
import com.comphenix.protocol.utility.MinecraftReflection; import com.comphenix.protocol.utility.MinecraftReflection;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -211,18 +212,14 @@ class EntityUtilities {
try { try {
hashGetMethod = type.getMethod("get", int.class); hashGetMethod = type.getMethod("get", int.class);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
// Then it's probably the lowest named method that takes an int-parameter and returns a object
Class<?>[] params = { int.class }; hashGetMethod = FuzzyReflection.fromClass(type).getMethod(
FuzzyMethodContract.newBuilder().banModifier(Modifier.STATIC).
// Then it's probably the lowest named method that takes an int-parameter parameterCount(1).
for (Method method : type.getMethods()) { parameterExactType(int.class).
if (Arrays.equals(params, method.getParameterTypes())) { returnTypeExact(Object.class).
if (hashGetMethod == null || build()
method.getName().compareTo(hashGetMethod.getName()) < 0) { );
hashGetMethod = method;
}
}
}
} }
} }