From 9be92dcfcb1c737025397c92b18ed027a6c7f4fa Mon Sep 17 00:00:00 2001 From: Player Date: Tue, 1 Apr 2014 14:40:24 +0200 Subject: [PATCH] Registry: Complain about bogus registrations --- .../FMLControlledNamespacedRegistry.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry.java b/src/main/java/cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry.java index 43960245b1..85f8a9bded 100644 --- a/src/main/java/cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry.java +++ b/src/main/java/cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry.java @@ -210,6 +210,8 @@ public class FMLControlledNamespacedRegistry extends RegistryNamespaced { int add(int id, String name, I thing, BitSet availabilityMap) { + if (name == null) throw new NullPointerException("Can't use a null-name for the registry."); + if (name.isEmpty()) throw new IllegalArgumentException("Can't use an empty name for the registry."); if (thing == null) throw new NullPointerException("Can't add null-object to the registry."); if (name.equals(optionalDefaultName)) { @@ -232,6 +234,20 @@ public class FMLControlledNamespacedRegistry extends RegistryNamespaced { String prefix = mc.getModId(); name = prefix + ":"+ name; } + + if (getRaw(name) != null) + { + FMLLog.warning("****************************************"); + FMLLog.warning("* The name %s has been registered twice, for %s and %s.", name, getRaw(name), thing); + FMLLog.warning("****************************************"); + } + if (getId(thing) >= 0) + { + FMLLog.warning("****************************************"); + FMLLog.warning("* The object %s has been registered twice, using the names %s and %s.", thing, getNameForObject(thing), name); + FMLLog.warning("****************************************"); + } + super.addObject(idToUse, name, thing); FMLLog.finer("Add : %s %d %s", name, idToUse, thing); return idToUse;