Skip to content

Commit

Permalink
make listtag/compoundtag cloneable
Browse files Browse the repository at this point in the history
  • Loading branch information
Brokkonaut committed Aug 16, 2023
1 parent 3fdaca0 commit 4b29150
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
Expand Up @@ -3,7 +3,7 @@
import java.util.Set;
import java.util.UUID;

public interface CompoundTag {
public interface CompoundTag extends Cloneable {

boolean containsKey(String name);

Expand All @@ -17,6 +17,8 @@ public interface CompoundTag {

void size();

void merge(CompoundTag source);

CompoundTag getCompound(String name);

CompoundTag getCompound(String name, boolean createIfMissing);
Expand Down Expand Up @@ -96,4 +98,6 @@ public interface CompoundTag {

@Override
boolean equals(Object obj);

public CompoundTag clone();
}
Expand Up @@ -2,7 +2,7 @@

import java.util.UUID;

public interface ListTag {
public interface ListTag extends Cloneable {
int size();

boolean isEmpty();
Expand Down Expand Up @@ -134,4 +134,6 @@ public interface ListTag {
boolean addUUID(int index, UUID v);

boolean setUUID(int index, UUID v);

public ListTag clone();
}
Expand Up @@ -51,6 +51,11 @@ public void size() {
handle.size();
}

@Override
public void merge(de.cubeside.nmsutils.nbt.CompoundTag source) {
handle.merge(((CompoundTagImpl) source).handle);
}

@Override
public CompoundTagImpl getCompound(String name) {
return getCompound(name, false);
Expand Down Expand Up @@ -309,4 +314,9 @@ public int hashCode() {
public boolean equals(Object obj) {
return obj instanceof CompoundTagImpl o && handle.equals(o.handle);
}

@Override
public CompoundTagImpl clone() {
return new CompoundTagImpl(handle.copy());
}
}
Expand Up @@ -414,4 +414,9 @@ public int hashCode() {
public boolean equals(Object obj) {
return obj instanceof ListTagImpl o && handle.equals(o.handle);
}

@Override
public ListTagImpl clone() {
return new ListTagImpl(handle.copy());
}
}
Expand Up @@ -51,6 +51,11 @@ public void size() {
handle.size();
}

@Override
public void merge(de.cubeside.nmsutils.nbt.CompoundTag source) {
handle.merge(((CompoundTagImpl) source).handle);
}

@Override
public CompoundTagImpl getCompound(String name) {
return getCompound(name, false);
Expand Down Expand Up @@ -309,4 +314,9 @@ public int hashCode() {
public boolean equals(Object obj) {
return obj instanceof CompoundTagImpl o && handle.equals(o.handle);
}

@Override
public CompoundTagImpl clone() {
return new CompoundTagImpl(handle.copy());
}
}
Expand Up @@ -414,4 +414,9 @@ public int hashCode() {
public boolean equals(Object obj) {
return obj instanceof ListTagImpl o && handle.equals(o.handle);
}

@Override
public ListTagImpl clone() {
return new ListTagImpl(handle.copy());
}
}

0 comments on commit 4b29150

Please sign in to comment.