This commit is contained in:
aPunch 2012-03-12 14:13:20 -05:00
parent 4c022b1a37
commit 4a17a478bf

View File

@ -20,10 +20,9 @@ import net.citizensnpcs.trait.Powered;
import net.citizensnpcs.trait.text.Text; import net.citizensnpcs.trait.text.Text;
import net.citizensnpcs.trait.waypoint.Waypoints; import net.citizensnpcs.trait.waypoint.Waypoints;
import com.google.common.collect.Maps;
public class CitizensTraitManager implements TraitManager { public class CitizensTraitManager implements TraitManager {
private final Map<String, Class<? extends Trait>> registered = new HashMap<String, Class<? extends Trait>>(); private final Map<String, Class<? extends Trait>> registered = new HashMap<String, Class<? extends Trait>>();
private final Map<Class<? extends Trait>, Constructor<? extends Trait>> CACHED_CTORS = new HashMap<Class<? extends Trait>, Constructor<? extends Trait>>();
public CitizensTraitManager() { public CitizensTraitManager() {
// Register Citizens traits // Register Citizens traits
@ -77,7 +76,6 @@ public class CitizensTraitManager implements TraitManager {
if (clazz == null) if (clazz == null)
return null; return null;
Trait t = getTrait(clazz, npc); Trait t = getTrait(clazz, npc);
//t.setName(name);
return (T) t; return (T) t;
} }
@ -94,9 +92,8 @@ public class CitizensTraitManager implements TraitManager {
constructor = null; constructor = null;
} }
CACHED_CTORS.put(trait, constructor); CACHED_CTORS.put(trait, constructor);
} else { } else
constructor = CACHED_CTORS.get(trait); constructor = CACHED_CTORS.get(trait);
}
try { try {
if (constructor == null || npc == null) if (constructor == null || npc == null)
@ -107,6 +104,4 @@ public class CitizensTraitManager implements TraitManager {
return null; return null;
} }
} }
private final Map<Class<? extends Trait>, Constructor<? extends Trait>> CACHED_CTORS = Maps.newHashMap();
} }