mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +01:00
Add Offline PDC API
This commit is contained in:
parent
66e26ebe48
commit
f207099765
1 changed files with 28 additions and 0 deletions
|
@ -325,6 +325,34 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
}
|
||||
// Paper end
|
||||
|
||||
// Paper start - Add Offline PDC API
|
||||
private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry();
|
||||
private io.papermc.paper.persistence.@org.checkerframework.checker.nullness.qual.MonotonicNonNull PersistentDataContainerView persistentDataContainerView;
|
||||
|
||||
@Override
|
||||
public io.papermc.paper.persistence.PersistentDataContainerView getPersistentDataContainer() {
|
||||
if (this.persistentDataContainerView == null) {
|
||||
this.persistentDataContainerView = new io.papermc.paper.persistence.PaperPersistentDataContainerView(DATA_TYPE_REGISTRY) {
|
||||
|
||||
private CompoundTag getPersistentTag() {
|
||||
return net.minecraft.Optionull.map(CraftOfflinePlayer.this.getData(), data -> data.getCompound("BukkitValues"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTagCompound() {
|
||||
return java.util.Objects.requireNonNullElseGet(this.getPersistentTag(), CompoundTag::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.nbt.Tag getTag(String key) {
|
||||
return net.minecraft.Optionull.map(this.getPersistentTag(), tag -> tag.get(key));
|
||||
}
|
||||
};
|
||||
}
|
||||
return this.persistentDataContainerView;
|
||||
}
|
||||
// Paper end - Add Offline PDC API
|
||||
|
||||
@Override
|
||||
public Location getLastDeathLocation() {
|
||||
if (this.getData().contains("LastDeathLocation", 10)) {
|
||||
|
|
Loading…
Reference in a new issue