mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-26 04:35:50 +01:00
Update for 1.3.2, reuse instances when loading
This commit is contained in:
parent
1a9c6ae0a0
commit
88936787c0
@ -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";
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
@ -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 (traitKey.keyExists("enabled") && !traitKey.getBoolean("enabled"))
|
||||
continue;
|
||||
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(
|
||||
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);
|
||||
}
|
||||
try {
|
||||
trait.load(traitKey);
|
||||
} catch (NPCLoadException ex) {
|
||||
|
Loading…
Reference in New Issue
Block a user