Update for 1.3.2, reuse instances when loading

This commit is contained in:
fullwall 2012-08-26 21:04:07 +08:00
parent 1a9c6ae0a0
commit 88936787c0
3 changed files with 17 additions and 10 deletions

View File

@ -401,5 +401,5 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
private static final String COMPATIBLE_MC_VERSION = "1.3.1";
private static final String COMPATIBLE_MC_VERSION = "1.3.2";
}

View File

@ -550,7 +550,7 @@ public class NPCCommands {
permission = "npc.speed")
public void speed(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
float newSpeed = (float) args.getDouble(1);
npc.getNavigator().setSpeed(newSpeed);
npc.getNavigator().getDefaultParameters().speed(newSpeed);
Messaging.sendF(sender, ChatColor.GREEN + "NPC speed set to %f.", newSpeed);
}

View File

@ -78,16 +78,23 @@ public abstract class CitizensNPC extends AbstractNPC {
metadata.loadFrom(root.getRelative("metadata"));
// Load traits
for (DataKey traitKey : root.getRelative("traits").getSubKeys()) {
Trait trait = CitizensAPI.getTraitFactory().getTrait(traitKey.name());
if (trait == null) {
Messaging.severeF(
"Skipped broken or missing trait '%s' while loading ID '%d'. Has the name changed?",
traitKey.name(), getId());
continue;
}
if (traitKey.keyExists("enabled") && !traitKey.getBoolean("enabled"))
continue;
addTrait(trait);
Class<? extends Trait> clazz = CitizensAPI.getTraitFactory().getTraitClass(traitKey.name());
Trait trait;
if (hasTrait(clazz)) {
trait = getTrait(clazz);
} else {
trait = CitizensAPI.getTraitFactory().getTrait(traitKey.name());
if (trait == null) {
Messaging
.severeF(
"Skipped broken or missing trait '%s' while loading ID '%d'. Has the name changed?",
traitKey.name(), getId());
continue;
}
addTrait(trait);
}
try {
trait.load(traitKey);
} catch (NPCLoadException ex) {