mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
#671: Implement PersistentDataContainer#getKeys()
This commit is contained in:
parent
50484a657e
commit
b900513035
1 changed files with 16 additions and 0 deletions
|
@ -1,9 +1,11 @@
|
||||||
package org.bukkit.craftbukkit.persistence;
|
package org.bukkit.craftbukkit.persistence;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import net.minecraft.server.NBTBase;
|
import net.minecraft.server.NBTBase;
|
||||||
import net.minecraft.server.NBTTagCompound;
|
import net.minecraft.server.NBTTagCompound;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
@ -70,6 +72,20 @@ public final class CraftPersistentDataContainer implements PersistentDataContain
|
||||||
return z != null ? z : defaultValue;
|
return z != null ? z : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<NamespacedKey> getKeys() {
|
||||||
|
Set<NamespacedKey> keys = new HashSet<>();
|
||||||
|
|
||||||
|
this.customDataTags.keySet().forEach(key -> {
|
||||||
|
String[] keyData = key.split(":", 2);
|
||||||
|
if (keyData.length == 2) {
|
||||||
|
keys.add(new NamespacedKey(keyData[0], keyData[1]));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(NamespacedKey key) {
|
public void remove(NamespacedKey key) {
|
||||||
Validate.notNull(key, "The provided key for the custom value was null");
|
Validate.notNull(key, "The provided key for the custom value was null");
|
||||||
|
|
Loading…
Reference in a new issue