Remove debugging throws

This commit is contained in:
riking 2014-06-14 22:45:01 -07:00
parent 7c20a7c3a3
commit d1253467a8

View File

@ -384,8 +384,10 @@ public class ReflectionManager {
return Class.forName(forgeName); return Class.forName(forgeName);
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
} else } else {
// Throw, because the default cannot possibly work
throw new RuntimeException("Missing Forge mapping for " + className); throw new RuntimeException("Missing Forge mapping for " + className);
}
} }
try { try {
return Class.forName("net.minecraft.server." + getBukkitVersion() + "." + className); return Class.forName("net.minecraft.server." + getBukkitVersion() + "." + className);
@ -419,18 +421,12 @@ public class ReflectionManager {
public static Field getNmsField(Class clazz, String fieldName) { public static Field getNmsField(Class clazz, String fieldName) {
if (isForge) { if (isForge) {
Map<String, String> fieldMap = ForgeFieldMappings.get(clazz.getName()); try {
if (fieldMap != null) { return clazz.getField(ForgeFieldMappings.get(clazz.getName()).get(fieldName));
String forgeName = fieldMap.get(fieldName); } catch (NoSuchFieldException ex) {
if (forgeName != null) { ex.printStackTrace();
try { } catch (NullPointerException ignored) {
return clazz.getField(forgeName); }
} catch (NoSuchFieldException ignored) {
}
} else
throw new RuntimeException("No field mapping for " + clazz.getName() + "." + fieldName);
} else
throw new RuntimeException("No field mappings for " + clazz.getName());
} }
try { try {
return clazz.getField(fieldName); return clazz.getField(fieldName);
@ -456,26 +452,17 @@ public class ReflectionManager {
public static Method getNmsMethod(Class<?> clazz, String methodName, Class<?>... parameters) { public static Method getNmsMethod(Class<?> clazz, String methodName, Class<?>... parameters) {
if (isForge) { if (isForge) {
Map<String, Map<String, String>> middleMap = ForgeMethodMappings.get(clazz.getName()); try {
if (middleMap != null) { Map<String, String> innerMap = ForgeMethodMappings.get(clazz.getName()).get(methodName);
Map<String, String> innerMap = middleMap.get(methodName); StringBuilder sb = new StringBuilder();
if (innerMap != null) { for (Class<?> cl : parameters) {
StringBuilder sb = new StringBuilder(); sb.append(methodSignaturePart(cl));
for (Class<?> cl : parameters) { }
sb.append(methodSignaturePart(cl)); return clazz.getMethod(innerMap.get(sb.toString()), parameters);
} } catch (NoSuchMethodException e) {
String trName = innerMap.get(sb.toString()); e.printStackTrace();
if (trName != null) { } catch (NullPointerException ignored) {
try { }
return clazz.getMethod(trName, parameters);
} catch (NoSuchMethodException ignored) {
}
} else
throw new RuntimeException("No method mapping for " + clazz.getName() + "." + methodName + "(" + sb.toString() + ")");
} else
throw new RuntimeException("No method mapping for " + clazz.getName() + "." + methodName);
} else
throw new RuntimeException("No method mappings for " + clazz.getName());
} }
try { try {
return clazz.getMethod(methodName, parameters); return clazz.getMethod(methodName, parameters);