Remove debugging throws

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

View File

@ -384,9 +384,11 @@ 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);
} catch (Exception e) { } catch (Exception e) {
@ -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());
if (fieldMap != null) {
String forgeName = fieldMap.get(fieldName);
if (forgeName != null) {
try { try {
return clazz.getField(forgeName); return clazz.getField(ForgeFieldMappings.get(clazz.getName()).get(fieldName));
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException ex) {
ex.printStackTrace();
} catch (NullPointerException 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);
if (innerMap != null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (Class<?> cl : parameters) { for (Class<?> cl : parameters) {
sb.append(methodSignaturePart(cl)); sb.append(methodSignaturePart(cl));
} }
String trName = innerMap.get(sb.toString()); return clazz.getMethod(innerMap.get(sb.toString()), parameters);
if (trName != null) { } catch (NoSuchMethodException e) {
try { e.printStackTrace();
return clazz.getMethod(trName, parameters); } catch (NullPointerException ignored) {
} 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);