Add some data to NPC before NPCSpawnEvent is called

This commit is contained in:
fullwall 2016-01-07 20:24:48 +08:00
parent 5fc5f23d8b
commit 3792407d80

View File

@ -209,6 +209,12 @@ public class CitizensNPC extends AbstractNPC {
NMS.setHeadYaw(mcEntity, at.getYaw());
getEntity().setMetadata(NPC_METADATA_MARKER, new FixedMetadataValue(CitizensAPI.getPlugin(), true));
// Set the spawned state
getTrait(CurrentLocation.class).setLocation(at);
getTrait(Spawned.class).setSpawned(true);
NPCSpawnEvent spawnEvent = new NPCSpawnEvent(this, at);
Bukkit.getPluginManager().callEvent(spawnEvent);
@ -218,12 +224,6 @@ public class CitizensNPC extends AbstractNPC {
return false;
}
getEntity().setMetadata(NPC_METADATA_MARKER, new FixedMetadataValue(CitizensAPI.getPlugin(), true));
// Set the spawned state
getTrait(CurrentLocation.class).setLocation(at);
getTrait(Spawned.class).setSpawned(true);
navigator.onSpawn();
// Modify NPC using traits after the entity has been created