Search in sources :

Example 1 with NPCCloneEvent

use of net.citizensnpcs.api.event.NPCCloneEvent in project CitizensAPI by CitizensDev.

the class AbstractNPC method copy.

@Override
public NPC copy() {
    NPC copy = registry.createNPC(getOrAddTrait(MobType.class).getType(), getFullName());
    DataKey key = new MemoryDataKey();
    save(key);
    copy.load(key);
    for (Trait trait : copy.getTraits()) {
        trait.onCopy();
    }
    Bukkit.getPluginManager().callEvent(new NPCCloneEvent(this, copy));
    return copy;
}
Also used : NPCCloneEvent(net.citizensnpcs.api.event.NPCCloneEvent) DataKey(net.citizensnpcs.api.util.DataKey) MemoryDataKey(net.citizensnpcs.api.util.MemoryDataKey) MemoryDataKey(net.citizensnpcs.api.util.MemoryDataKey) Trait(net.citizensnpcs.api.trait.Trait)

Aggregations

NPCCloneEvent (net.citizensnpcs.api.event.NPCCloneEvent)1 Trait (net.citizensnpcs.api.trait.Trait)1 DataKey (net.citizensnpcs.api.util.DataKey)1 MemoryDataKey (net.citizensnpcs.api.util.MemoryDataKey)1