diff --git a/patches/api/Add-Offline-PDC-API.patch b/patches/api/Add-Offline-PDC-API.patch new file mode 100644 index 0000000000..3c9c2fb25c --- /dev/null +++ b/patches/api/Add-Offline-PDC-API.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> +Date: Sat, 9 Jul 2022 17:17:04 +0200 +Subject: [PATCH] Add Offline PDC API + + +diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/OfflinePlayer.java ++++ b/src/main/java/org/bukkit/OfflinePlayer.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + * player that is stored on the disk and can, thus, be retrieved without the + * player needing to be online. + */ +-public interface OfflinePlayer extends ServerOperator, AnimalTamer, ConfigurationSerializable { ++public interface OfflinePlayer extends ServerOperator, AnimalTamer, ConfigurationSerializable, io.papermc.paper.persistence.PersistentDataViewHolder { // Paper - Add Offline PDC API + + /** + * Checks if this player is currently online +@@ -0,0 +0,0 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio + */ + @Nullable + public Location getLocation(); ++ // Paper start - add pdc to offline player ++ /** ++ * Yields a view of the persistent data container for this offline player. ++ * In case this {@link OfflinePlayer} instance was created for an offline player, the returned view will wrap the persistent ++ * data on disk. ++ *
++ * As such, this method as well as queries to the {@link io.papermc.paper.persistence.PersistentDataContainerView}
++ * may produce blocking IO requests to read the requested data from disk.
++ * Caution in its usage is hence advised.
++ *
++ * @return the persistent data container view
++ * @see io.papermc.paper.persistence.PersistentDataViewHolder#getPersistentDataContainer()
++ */
++ @Override
++ io.papermc.paper.persistence.@NotNull PersistentDataContainerView getPersistentDataContainer();
++ // Paper end - add pdc to offline player
+ }
diff --git a/patches/server/Add-Offline-PDC-API.patch b/patches/server/Add-Offline-PDC-API.patch
new file mode 100644
index 0000000000..72b5b916cd
--- /dev/null
+++ b/patches/server/Add-Offline-PDC-API.patch
@@ -0,0 +1,45 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
+Date: Sat, 9 Jul 2022 17:28:42 +0200
+Subject: [PATCH] Add Offline PDC API
+
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
++++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
+@@ -0,0 +0,0 @@ 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)) {
diff --git a/patches/server/Make-a-PDC-view-accessible-directly-from-ItemStack.patch b/patches/server/Make-a-PDC-view-accessible-directly-from-ItemStack.patch
index cc96816461..5e22921271 100644
--- a/patches/server/Make-a-PDC-view-accessible-directly-from-ItemStack.patch
+++ b/patches/server/Make-a-PDC-view-accessible-directly-from-ItemStack.patch
@@ -16,19 +16,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
++import java.util.Collections;
++import java.util.HashSet;
++import java.util.Set;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtIo;
+import net.minecraft.nbt.Tag;
+import org.bukkit.NamespacedKey;
+import org.bukkit.craftbukkit.persistence.CraftPersistentDataAdapterContext;
++import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
+import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry;
+import org.bukkit.persistence.PersistentDataAdapterContext;
++import org.bukkit.persistence.PersistentDataContainer;
+import org.bukkit.persistence.PersistentDataType;
-+import org.checkerframework.checker.nullness.qual.NonNull;
-+import org.checkerframework.checker.nullness.qual.Nullable;
-+import org.checkerframework.framework.qual.DefaultQualifier;
++import org.jspecify.annotations.NullMarked;
++import org.jspecify.annotations.Nullable;
+
-+@DefaultQualifier(NonNull.class)
++@NullMarked
+public abstract class PaperPersistentDataContainerView implements PersistentDataContainerView {
+
+ protected final CraftPersistentDataTypeRegistry registry;
@@ -48,7 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ Preconditions.checkArgument(key != null, "The NamespacedKey key cannot be null");
+ Preconditions.checkArgument(type != null, "The provided type cannot be null");
+
-+ final @Nullable Tag value = this.getTag(key.toString());
++ final Tag value = this.getTag(key.toString());
+ if (value == null) {
+ return false;
+ }
@@ -67,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ Preconditions.checkArgument(key != null, "The NamespacedKey key cannot be null");
+ Preconditions.checkArgument(type != null, "The provided type cannot be null");
+
-+ final @Nullable Tag value = this.getTag(key.toString());
++ final Tag value = this.getTag(key.toString());
+ if (value == null) {
+ return null;
+ }
@@ -82,13 +86,43 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ @Override
++ public Set