From ea47aec970747fdbf5778bfd0a2c7bbe8bb6310b Mon Sep 17 00:00:00 2001 From: Stan Hebben Date: Mon, 22 Dec 2014 09:36:02 +0100 Subject: [PATCH] Made initialization of registered classes more robust against exceptions. --- .../minetweaker/runtime/GlobalRegistry.java | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/MineTweaker3-API/src/main/java/minetweaker/runtime/GlobalRegistry.java b/MineTweaker3-API/src/main/java/minetweaker/runtime/GlobalRegistry.java index 7f73123..d380272 100644 --- a/MineTweaker3-API/src/main/java/minetweaker/runtime/GlobalRegistry.java +++ b/MineTweaker3-API/src/main/java/minetweaker/runtime/GlobalRegistry.java @@ -70,15 +70,19 @@ public class GlobalRegistry { globals.put(name, symbol); } - public static void registerExpansion(Class cls) { - for (Annotation annotation : cls.getAnnotations()) { - if (annotation instanceof ZenExpansion) { - ZenExpansion eAnnotation = (ZenExpansion) annotation; - if (!expansions.containsKey(eAnnotation.value())) { - expansions.put(eAnnotation.value(), new TypeExpansion(eAnnotation.value())); + public static void registerExpansion(Class cls) { + try { + for (Annotation annotation : cls.getAnnotations()) { + if (annotation instanceof ZenExpansion) { + ZenExpansion eAnnotation = (ZenExpansion) annotation; + if (!expansions.containsKey(eAnnotation.value())) { + expansions.put(eAnnotation.value(), new TypeExpansion(eAnnotation.value())); + } + expansions.get(eAnnotation.value()).expand(cls, types); } - expansions.get(eAnnotation.value()).expand(cls, types); } + } catch (Throwable ex) { + ex.printStackTrace(); } } @@ -90,11 +94,15 @@ public class GlobalRegistry { bracketHandlers.add(handler); } - public static void registerNativeClass(Class cls) { - ZenTypeNative type = new ZenTypeNative(cls); - type.complete(types); - - root.put(type.getName(), new SymbolType(type), errors); + public static void registerNativeClass(Class cls) { + try { + ZenTypeNative type = new ZenTypeNative(cls); + type.complete(types); + + root.put(type.getName(), new SymbolType(type), errors); + } catch (Throwable ex) { + ex.printStackTrace(); + } } public static TypeRegistry getTypeRegistry() {