Merge get and add compound methods.

This commit is contained in:
Brianna 2020-09-30 09:10:13 -05:00
parent a615e8ba7b
commit fbfdfe0393
15 changed files with 98 additions and 114 deletions

View File

@ -25,8 +25,6 @@ public interface NBTCompound {
NBTCompound remove(String tag);
NBTCompound addNewCompound(String tag);
boolean has(String tag);
NBTObject getNBTObject(String tag);

View File

@ -86,13 +86,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -145,7 +138,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override

View File

@ -86,13 +86,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -145,7 +138,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override

View File

@ -86,13 +86,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -145,7 +138,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override

View File

@ -86,13 +86,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -145,7 +138,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override

View File

@ -86,13 +86,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -145,7 +138,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override

View File

@ -86,13 +86,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -145,7 +138,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override

View File

@ -86,13 +86,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -145,7 +138,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override

View File

@ -86,13 +86,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -145,7 +138,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override

View File

@ -86,13 +86,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -145,7 +138,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override

View File

@ -87,13 +87,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -146,7 +139,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override

View File

@ -87,13 +87,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -146,7 +139,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override

View File

@ -87,13 +87,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -146,7 +139,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override

View File

@ -86,13 +86,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -145,7 +138,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override

View File

@ -86,13 +86,6 @@ public class NBTCompoundImpl implements NBTCompound {
return this;
}
@Override
public NBTCompound addNewCompound(String tag) {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public boolean has(String tag) {
return compound.hasKey(tag);
@ -145,7 +138,13 @@ public class NBTCompoundImpl implements NBTCompound {
@Override
public NBTCompound getCompound(String tag) {
return getNBTObject(tag).asCompound();
if (has(tag)) {
return getNBTObject(tag).asCompound();
} else {
NBTTagCompound newCompound = new NBTTagCompound();
compound.set(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
}
@Override