Skip to content

Commit

Permalink
Add copy() method as a replacement for clone()
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Dec 21, 2019
1 parent 6a51cbd commit 6219cb2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -10,7 +10,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bukkit.version>1.15-R0.1-SNAPSHOT</bukkit.version>
<bukkit.version>1.15.1-R0.1-SNAPSHOT</bukkit.version>
<powermock.version>1.4.12</powermock.version>
<build.number>Unknown</build.number>
</properties>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/citizensnpcs/api/npc/AbstractNPC.java
Expand Up @@ -121,6 +121,11 @@ public void addTrait(Trait trait) {

@Override
public NPC clone() {
return copy();
}

@Override
public NPC copy() {
NPC copy = registry.createNPC(getTrait(MobType.class).getType(), getFullName());
DataKey key = new MemoryDataKey();
save(key);
Expand All @@ -133,6 +138,7 @@ public NPC clone() {
return copy;
}


@Override
public MetadataStore data() {
return this.metadata;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/net/citizensnpcs/api/npc/NPC.java
Expand Up @@ -47,6 +47,11 @@ public interface NPC extends Agent, Cloneable {
* @return A clone of the NPC. May not be an exact copy depending on the {@link Trait}s installed.
*/
public NPC clone();

/**
* @return A clone of the NPC. May not be an exact copy depending on the {@link Trait}s installed.
*/
public NPC copy();

/**
* @return The metadata store of this NPC.
Expand Down

0 comments on commit 6219cb2

Please sign in to comment.