Archiviert
13
0

Fix IllegalArgumentException with watchable objects

Dieser Commit ist enthalten in:
Dan Mulloy 2015-08-09 18:27:00 -04:00
Ursprung e6c87129bd
Commit 368ed76677

Datei anzeigen

@ -424,7 +424,8 @@ public class MinecraftReflection {
* @return TRUE if it can, FALSE otherwise. * @return TRUE if it can, FALSE otherwise.
*/ */
public static boolean isBlockPosition(Object obj) { public static boolean isBlockPosition(Object obj) {
return obj != null && getBlockPositionClass().isAssignableFrom(obj.getClass()); Class<?> blockPosition = getBlockPositionClass();
return obj != null && blockPosition != null && blockPosition.isAssignableFrom(obj.getClass());
} }
/** /**
@ -1179,43 +1180,52 @@ public class MinecraftReflection {
try { try {
return getMinecraftClass("ChunkPosition"); return getMinecraftClass("ChunkPosition");
} catch (RuntimeException e) { } catch (RuntimeException e) {
/* Class<?> normalChunkGenerator = getCraftBukkitClass("generator.NormalChunkGenerator"); try {
Class<?> normalChunkGenerator = getCraftBukkitClass("generator.NormalChunkGenerator");
// ChunkPosition a(net.minecraft.server.World world, String string, int i, int i1, int i2) { // ChunkPosition a(net.minecraft.server.World world, String string, int i, int i1, int i2) {
FuzzyMethodContract selected = FuzzyMethodContract.newBuilder() FuzzyMethodContract selected = FuzzyMethodContract.newBuilder()
.banModifier(Modifier.STATIC) .banModifier(Modifier.STATIC)
.parameterMatches(getMinecraftObjectMatcher(), 0) .parameterMatches(getMinecraftObjectMatcher(), 0)
.parameterExactType(String.class, 1) .parameterExactType(String.class, 1)
.parameterExactType(int.class, 2) .parameterExactType(int.class, 2)
.parameterExactType(int.class, 3) .parameterExactType(int.class, 3)
.parameterExactType(int.class, 4) .parameterExactType(int.class, 4)
.build(); .build();
return setMinecraftClass("ChunkPosition", FuzzyReflection.fromClass(normalChunkGenerator).getMethod(selected).getReturnType()); */ return setMinecraftClass("ChunkPosition",
return null; FuzzyReflection.fromClass(normalChunkGenerator).getMethod(selected).getReturnType());
} catch (Throwable ex) {
return null;
}
} }
} }
/** /**
* Retrieves the BlockPosition class. * Retrieves the BlockPosition class.
*
* @return The BlockPosition class. * @return The BlockPosition class.
*/ */
public static Class<?> getBlockPositionClass() { public static Class<?> getBlockPositionClass() {
try { try {
return getMinecraftClass("BlockPosition"); return getMinecraftClass("BlockPosition");
} catch (RuntimeException e) { } catch (RuntimeException e) {
Class<?> normalChunkGenerator = getCraftBukkitClass("generator.NormalChunkGenerator"); try {
Class<?> normalChunkGenerator = getCraftBukkitClass("generator.NormalChunkGenerator");
// BlockPosition findNearestMapFeature(World, String, BlockPosition) // BlockPosition findNearestMapFeature(World, String, BlockPosition)
FuzzyMethodContract selected = FuzzyMethodContract.newBuilder() FuzzyMethodContract selected = FuzzyMethodContract.newBuilder()
.banModifier(Modifier.STATIC) .banModifier(Modifier.STATIC)
.parameterMatches(getMinecraftObjectMatcher(), 0) .parameterMatches(getMinecraftObjectMatcher(), 0)
.parameterExactType(String.class, 1) .parameterExactType(String.class, 1)
.parameterMatches(getMinecraftObjectMatcher(), 1) .parameterMatches(getMinecraftObjectMatcher(), 1)
.build(); .build();
return setMinecraftClass("BlockPosition", return setMinecraftClass("BlockPosition",
FuzzyReflection.fromClass(normalChunkGenerator).getMethod(selected).getReturnType()); FuzzyReflection.fromClass(normalChunkGenerator).getMethod(selected).getReturnType());
} catch (Throwable ex) {
return null;
}
} }
} }