Archiviert
13
0

A few minor tweaks

Dieser Commit ist enthalten in:
Dan Mulloy 2016-03-07 19:05:58 -05:00
Ursprung ec38ac7292
Commit 16c7ebef73
4 geänderte Dateien mit 30 neuen und 24 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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