mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-24 11:38:26 +01:00
Change
This commit is contained in:
parent
4c022b1a37
commit
4a17a478bf
@ -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();
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user