A few minor tweaks

This commit is contained in:
Dan Mulloy 2016-03-07 19:05:58 -05:00
parent ec38ac7292
commit 16c7ebef73
4 changed files with 30 additions and 24 deletions

View File

@ -57,7 +57,7 @@ public class BukkitCloner implements Cloner {
addClass(4, MinecraftReflection.getServerPingClass());
}
if (MinecraftReflection.dataWatcherItemExists()) {
if (MinecraftReflection.watcherObjectExists()) {
addClass(5, MinecraftReflection.getDataWatcherSerializerClass());
addClass(6, MinecraftReflection.getMinecraftKeyClass());
}

View File

@ -89,7 +89,7 @@ public class ImmutableDetector implements Cloner {
}
// Check for known immutable classes in 1.9
if (MinecraftReflection.dataWatcherItemExists()) {
if (MinecraftReflection.watcherObjectExists()) {
if (type.equals(MinecraftReflection.getDataWatcherSerializerClass())
|| type.equals(MinecraftReflection.getMinecraftClass("SoundEffect"))) {
return true;

View File

@ -1286,14 +1286,20 @@ public class MinecraftReflection {
/**
* Retrieve the WatchableObject class.
* @return The WatchableObject class.
* @deprecated Replaced by {@link #getDataWatcherItemClass()}
*/
@Deprecated
public static Class<?> getWatchableObjectClass() {
if (dataWatcherItemExists()) {
return getDataWatcherItemClass();
}
/**
* Retrieve the DataWatcher Item class.
* @return The class
*/
public static Class<?> getDataWatcherItemClass() {
try {
return getMinecraftClass("WatchableObject", "DataWatcher$WatchableObject");
return getMinecraftClass("DataWatcher$Item", "DataWatcher$WatchableObject", "WatchableObject");
} catch (RuntimeException e) {
Method selected = FuzzyReflection.fromClass(getDataWatcherClass(), true).
getMethod(FuzzyMethodContract.newBuilder().
@ -1303,32 +1309,36 @@ public class MinecraftReflection {
build());
// Use the second parameter
return setMinecraftClass("WatchableObject", selected.getParameterTypes()[1]);
return setMinecraftClass("DataWatcher$Item", selected.getParameterTypes()[1]);
}
}
public static Class<?> getDataWatcherItemClass() {
// TODO Implement a fallback
return getMinecraftClass("DataWatcher$Item");
}
public static Class<?> getDataWatcherObjectClass() {
// TODO Implement a fallback
return getMinecraftClass("DataWatcherObject");
}
public static boolean watcherObjectExists() {
try {
return getDataWatcherObjectClass() != null;
} catch (RuntimeException e) {
return false;
}
}
public static Class<?> getDataWatcherSerializerClass() {
// TODO Implement a fallback
return getMinecraftClass("DataWatcherSerializer");
}
public static boolean dataWatcherItemExists() {
try {
getDataWatcherItemClass();
return true;
} catch (RuntimeException e) {
return false;
public static Class<?> getDataWatcherRegistryClass() {
// TODO Implement a fallback
return getMinecraftClass("DataWatcherRegistry");
}
public static Class<?> getMinecraftKeyClass() {
// TODO Implement a fallback
return getMinecraftClass("MinecraftKey");
}
/**
@ -2077,8 +2087,4 @@ public class MinecraftReflection {
throw new RuntimeException("Cannot construct packet serializer.", e);
}
}
public static Class<?> getMinecraftKeyClass() {
return getMinecraftClass("MinecraftKey");
}
}

View File

@ -674,7 +674,7 @@ public class WrappedDataWatcher extends AbstractWrapper implements Iterable<Wrap
return;
}
List<Field> candidates = FuzzyReflection.fromClass(MinecraftReflection.getMinecraftClass("DataWatcherRegistry"), true)
List<Field> candidates = FuzzyReflection.fromClass(MinecraftReflection.getDataWatcherRegistryClass(), true)
.getFieldListByType(MinecraftReflection.getDataWatcherSerializerClass());
for (Field candidate : candidates) {
Type generic = candidate.getGenericType();