#1299: Add new PersistentDataContainer methods and clean up docs
By: Jishuna <joshl5324@gmail.com>
This commit is contained in:
@@ -54,6 +54,11 @@ public class CraftPersistentDataContainer implements PersistentDataContainer {
|
||||
return registry.isInstanceOf(type.getPrimitiveType(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(NamespacedKey key) {
|
||||
return this.customDataTags.get(key.toString()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T, Z> Z get(NamespacedKey key, PersistentDataType<T, Z> type) {
|
||||
Preconditions.checkArgument(key != null, "The NamespacedKey key cannot be null");
|
||||
@@ -99,6 +104,18 @@ public class CraftPersistentDataContainer implements PersistentDataContainer {
|
||||
return this.customDataTags.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTo(PersistentDataContainer other, boolean replace) {
|
||||
Preconditions.checkArgument(other != null, "The target container cannot be null");
|
||||
|
||||
CraftPersistentDataContainer target = (CraftPersistentDataContainer) other;
|
||||
if (replace) {
|
||||
target.customDataTags.putAll(customDataTags);
|
||||
} else {
|
||||
customDataTags.forEach(target.customDataTags::putIfAbsent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersistentDataAdapterContext getAdapterContext() {
|
||||
return this.adapterContext;
|
||||
|
||||
Reference in New Issue
Block a user