Skip to content

Commit

Permalink
Don't copy UUID
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jan 22, 2014
1 parent 6bdb377 commit f2d0269
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/main/java/net/citizensnpcs/api/npc/AbstractNPC.java
Expand Up @@ -26,7 +26,6 @@
import net.citizensnpcs.api.util.Messaging;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
Expand Down Expand Up @@ -76,7 +75,7 @@ public void setPersistent(String key, Object data) {
private final List<Runnable> runnables = Lists.newArrayList();
private final SpeechController speechController = new SimpleSpeechController(this);
protected final Map<Class<? extends Trait>, Trait> traits = Maps.newHashMap();
private UUID uuid;
private final UUID uuid;

protected AbstractNPC(UUID uuid, int id, String name, NPCRegistry registry) {
if (name.length() > 16) {
Expand Down Expand Up @@ -129,7 +128,7 @@ public void addTrait(Trait trait) {
public NPC clone() {
NPC copy = registry.createNPC(getTrait(MobType.class).getType(), getFullName());
DataKey key = new MemoryDataKey();
this.save(key);
save(key);
copy.load(key);

for (Trait trait : copy.getTraits()) {
Expand Down Expand Up @@ -281,9 +280,6 @@ public boolean isSpawned() {
@Override
public void load(final DataKey root) {
metadata.loadFrom(root.getRelative("metadata"));
if (root.keyExists("uuid")) {
uuid = UUID.fromString(root.getString("uuid"));
}

String traitNames = root.getString("traitnames");
Set<DataKey> keys = Sets.newHashSet(root.getRelative("traits").getSubKeys());
Expand Down Expand Up @@ -330,8 +326,9 @@ public void removeTrait(Class<? extends Trait> traitClass) {
if (trait != null) {
Bukkit.getPluginManager().callEvent(new NPCRemoveTraitEvent(this, trait));
removedTraits.add(trait.getName());
if (trait.isRunImplemented())
if (trait.isRunImplemented()) {
runnables.remove(trait);
}
HandlerList.unregisterAll(trait);
trait.onRemove();
}
Expand Down

0 comments on commit f2d0269

Please sign in to comment.