diff --git a/src/main/java/valkyrienwarfare/ValkyrienWarfareMod.java b/src/main/java/valkyrienwarfare/ValkyrienWarfareMod.java index 9fb6ba5ef..91cee108a 100644 --- a/src/main/java/valkyrienwarfare/ValkyrienWarfareMod.java +++ b/src/main/java/valkyrienwarfare/ValkyrienWarfareMod.java @@ -301,10 +301,16 @@ public void fmlConstruct(FMLConstructionEvent event) { } } - allAddons.forEach(className -> { + ALLADDONS: for (String className : allAddons) { try { Class abstractclass = Class.forName(className); if (abstractclass.isAnnotationPresent(VWAddon.class)) { + for (Module registered : addons) { + if (registered.getClass().getCanonicalName().equals(abstractclass.getCanonicalName())) { + System.out.println("Addon " + abstractclass.getCanonicalName() + " already registered, skipping..."); + continue ALLADDONS; + } + } Module module = (Module) abstractclass.newInstance(); registerAddon(module); } else { @@ -314,7 +320,7 @@ public void fmlConstruct(FMLConstructionEvent event) { e.printStackTrace(); System.out.println("Not loading addon: " + className); } - }); + }; } @EventHandler