Updated Upstream (Bukkit/CraftBukkit)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
01bb6ba7 PR-936: Add new PersistentDataContainer methods and clean up docs
bc145b90 PR-940: Create registry for banner pattern and cat type

CraftBukkit Changes:
cb2ea54de SPIGOT-7440, PR-1292: Fire EntityTeleportEvent for end gateways
4fea66e44 PR-1299: Add new PersistentDataContainer methods and clean up docs
b483a20db PR-1303: Create registry for banner pattern and cat type
4642dd526 SPIGOT-7535: Fix maps not having an ID and also call MapInitializeEvent in more places
This commit is contained in:
Jake Potrebic 2023-12-08 11:00:39 -08:00
parent 7c36ea0a5c
commit 40d0f2da71
13 changed files with 56 additions and 138 deletions

View file

@ -1,30 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: u9g <winworkswow@gmail.com>
Date: Mon, 3 Jan 2022 23:27:21 -0500
Subject: [PATCH] Add new overload to PersistentDataContainer#has
Adds the new overload: PersistentDataContainer#has(NamespacedKey key)
diff --git a/src/main/java/org/bukkit/persistence/PersistentDataContainer.java b/src/main/java/org/bukkit/persistence/PersistentDataContainer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/persistence/PersistentDataContainer.java
+++ b/src/main/java/org/bukkit/persistence/PersistentDataContainer.java
@@ -0,0 +0,0 @@ public interface PersistentDataContainer {
*/
@NotNull
PersistentDataAdapterContext getAdapterContext();
+
+ // Paper start
+ /**
+ * Returns if the persistent metadata provider has metadata registered
+ * matching the provided key.
+ *
+ * @param key the key for which existence should be checked.
+ *
+ * @return whether the key exists
+ *
+ * @throws NullPointerException if the key to look up is null
+ */
+ boolean has(@NotNull NamespacedKey key);
+ // Paper end
}

View file

@ -10,10 +10,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/persistence/PersistentDataContainer.java --- a/src/main/java/org/bukkit/persistence/PersistentDataContainer.java
+++ b/src/main/java/org/bukkit/persistence/PersistentDataContainer.java +++ b/src/main/java/org/bukkit/persistence/PersistentDataContainer.java
@@ -0,0 +0,0 @@ public interface PersistentDataContainer { @@ -0,0 +0,0 @@ public interface PersistentDataContainer {
* @throws NullPointerException if the key to look up is null
*/ */
boolean has(@NotNull NamespacedKey key); @NotNull
PersistentDataAdapterContext getAdapterContext();
+ +
+ // Paper start - byte array serialization
+ /** + /**
+ * Serialize this {@link PersistentDataContainer} instance to a + * Serialize this {@link PersistentDataContainer} instance to a
+ * byte array. + * byte array.
@ -43,8 +44,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param bytes the byte array to read from + * @param bytes the byte array to read from
+ * @throws java.io.IOException if the byte array has an invalid format + * @throws java.io.IOException if the byte array has an invalid format
+ */ + */
+ default void readFromBytes(byte @NotNull [] bytes) throws java.io.IOException { + default void readFromBytes(final byte @NotNull [] bytes) throws java.io.IOException {
+ this.readFromBytes(bytes, true); + this.readFromBytes(bytes, true);
+ } + }
// Paper end + // Paper end - byte array serialization
} }

View file

@ -1,40 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Wed, 8 Jun 2022 18:23:17 -0400
Subject: [PATCH] Keyed Cat Type
diff --git a/src/main/java/org/bukkit/entity/Cat.java b/src/main/java/org/bukkit/entity/Cat.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/Cat.java
+++ b/src/main/java/org/bukkit/entity/Cat.java
@@ -0,0 +0,0 @@ public interface Cat extends Tameable, Sittable, io.papermc.paper.entity.CollarC
/**
* Represents the various different cat types there are.
*/
- public enum Type {
+ public enum Type implements org.bukkit.Keyed { // Paper
TABBY,
BLACK,
RED,
@@ -0,0 +0,0 @@ public interface Cat extends Tameable, Sittable, io.papermc.paper.entity.CollarC
WHITE,
JELLIE,
ALL_BLACK;
+
+ // Paper start
+ private final org.bukkit.NamespacedKey key;
+
+ Type() {
+ this.key = org.bukkit.NamespacedKey.minecraft(name().toLowerCase(java.util.Locale.ROOT));
+ }
+
+ @NotNull
+ @Override
+ public org.bukkit.NamespacedKey getKey() {
+ return key;
+ }
+ // Paper end
}
// Paper Start - More cat api

View file

@ -327,8 +327,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/entity/Cat.java --- a/src/main/java/org/bukkit/entity/Cat.java
+++ b/src/main/java/org/bukkit/entity/Cat.java +++ b/src/main/java/org/bukkit/entity/Cat.java
@@ -0,0 +0,0 @@ public interface Cat extends Tameable, Sittable { @@ -0,0 +0,0 @@ public interface Cat extends Tameable, Sittable {
JELLIE, return key;
ALL_BLACK; }
} }
+ +
+ // Paper Start - More cat api + // Paper Start - More cat api

View file

@ -1,24 +1,18 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: u9g <winworkswow@gmail.com> From: u9g <winworkswow@gmail.com>
Date: Mon, 3 Jan 2022 23:32:42 -0500 Date: Mon, 3 Jan 2022 23:32:42 -0500
Subject: [PATCH] Add new overload to PersistentDataContainer#has Subject: [PATCH] Add missing IAE check for PersistentDataContainer#has
Adds the new overload: PersistentDataContainer#has(NamespacedKey key)
diff --git a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java diff --git a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java --- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
+++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
@@ -0,0 +0,0 @@ public class CraftPersistentDataContainer implements PersistentDataContainer { @@ -0,0 +0,0 @@ public class CraftPersistentDataContainer implements PersistentDataContainer {
public void clear() {
this.customDataTags.clear(); @Override
} public boolean has(NamespacedKey key) {
+ + Preconditions.checkArgument(key != null, "The provided key for the custom value was null"); // Paper
+ @Override return this.customDataTags.get(key.toString()) != null;
+ public boolean has(NamespacedKey key) {
+ Preconditions.checkArgument(key != null, "The provided key for the custom value was null");
+
+ return this.customDataTags.containsKey(key.toString());
+ }
// Paper end
} }

View file

@ -10,29 +10,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java --- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
+++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
@@ -0,0 +0,0 @@ public class CraftPersistentDataContainer implements PersistentDataContainer { @@ -0,0 +0,0 @@ public class CraftPersistentDataContainer implements PersistentDataContainer {
this.customDataTags.clear();
return this.customDataTags.containsKey(key.toString());
} }
// Paper end
+ +
+ // Paper start - byte array serialization
+ @Override + @Override
+ public byte[] serializeToBytes() throws java.io.IOException { + public byte[] serializeToBytes() throws java.io.IOException {
+ net.minecraft.nbt.CompoundTag root = this.toTagCompound(); + final net.minecraft.nbt.CompoundTag root = this.toTagCompound();
+ java.io.ByteArrayOutputStream byteArrayOutput = new java.io.ByteArrayOutputStream(); + final java.io.ByteArrayOutputStream byteArrayOutput = new java.io.ByteArrayOutputStream();
+ try (java.io.DataOutputStream dataOutput = new java.io.DataOutputStream(byteArrayOutput)) { + try (final java.io.DataOutputStream dataOutput = new java.io.DataOutputStream(byteArrayOutput)) {
+ net.minecraft.nbt.NbtIo.write(root, dataOutput); + net.minecraft.nbt.NbtIo.write(root, dataOutput);
+ return byteArrayOutput.toByteArray(); + return byteArrayOutput.toByteArray();
+ } + }
+ } + }
+ +
+ @Override + @Override
+ public void readFromBytes(byte[] bytes, boolean clear) throws java.io.IOException { + public void readFromBytes(final byte[] bytes, final boolean clear) throws java.io.IOException {
+ if (clear) { + if (clear) {
+ this.clear(); + this.clear();
+ } + }
+ try (java.io.DataInputStream dataInput = new java.io.DataInputStream(new java.io.ByteArrayInputStream(bytes))) { + try (final java.io.DataInputStream dataInput = new java.io.DataInputStream(new java.io.ByteArrayInputStream(bytes))) {
+ net.minecraft.nbt.CompoundTag compound = net.minecraft.nbt.NbtIo.read(dataInput); + final net.minecraft.nbt.CompoundTag compound = net.minecraft.nbt.NbtIo.read(dataInput);
+ this.putAll(compound); + this.putAll(compound);
+ } + }
+ } + }
// Paper end + // Paper end - byte array serialization
} }

View file

@ -48,14 +48,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java --- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
+++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
@@ -0,0 +0,0 @@ public class CraftPersistentDataContainer implements PersistentDataContainer { @@ -0,0 +0,0 @@ public class CraftPersistentDataContainer implements PersistentDataContainer {
this.putAll(compound);
} }
} }
// Paper end - byte array serialization
+ +
+ // Paper start - deep clone tags
+ public Map<String, Tag> getTagsCloned() { + public Map<String, Tag> getTagsCloned() {
+ final Map<String, Tag> tags = new HashMap<>(); + final Map<String, Tag> tags = new HashMap<>();
+ this.customDataTags.forEach((key, tag) -> tags.put(key, tag.copy())); + this.customDataTags.forEach((key, tag) -> tags.put(key, tag.copy()));
+ return tags; + return tags;
+ } + }
// Paper end + // Paper end - deep clone tags
} }

View file

@ -3,6 +3,8 @@ From: Warrior <50800980+Warriorrrr@users.noreply.github.com>
Date: Sun, 24 Sep 2023 18:35:28 +0200 Date: Sun, 24 Sep 2023 18:35:28 +0200
Subject: [PATCH] Fix missing map initialize event call Subject: [PATCH] Fix missing map initialize event call
== AT ==
public net.minecraft.world.level.storage.DimensionDataStorage readSavedData(Ljava/util/function/Function;Lnet/minecraft/util/datafix/DataFixTypes;Ljava/lang/String;)Lnet/minecraft/world/level/saveddata/SavedData;
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -12,7 +14,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Nullable @Nullable
@Override @Override
public MapItemSavedData getMapData(String id) { public MapItemSavedData getMapData(String id) {
- return (MapItemSavedData) this.getServer().overworld().getDataStorage().get(MapItemSavedData.factory(), id); - // CraftBukkit start
- MapItemSavedData worldmap = (MapItemSavedData) this.getServer().overworld().getDataStorage().get(MapItemSavedData.factory(), id);
- if (worldmap != null) {
- worldmap.id = id;
+ // Paper start - Call missing map initialize event & set id + // Paper start - Call missing map initialize event & set id
+ final DimensionDataStorage storage = this.getServer().overworld().getDataStorage(); + final DimensionDataStorage storage = this.getServer().overworld().getDataStorage();
+ +
@ -26,23 +31,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ new MapInitializeEvent(map.mapView).callEvent(); + new MapInitializeEvent(map.mapView).callEvent();
+ return map; + return map;
+ } + }
+ } + } else if (existing instanceof MapItemSavedData mapItemSavedData) {
+ mapItemSavedData.id = id;
}
- return worldmap;
- // CraftBukkit end
+ +
+ return existing instanceof MapItemSavedData data ? data : null; + return existing instanceof MapItemSavedData data ? data : null;
+ // Paper end + // Paper end
} }
@Override @Override
diff --git a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
+++ b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
@@ -0,0 +0,0 @@ public class DimensionDataStorage {
}
@Nullable
- private <T extends SavedData> T readSavedData(Function<CompoundTag, T> readFunction, DataFixTypes dataFixTypes, String id) {
+ public <T extends SavedData> T readSavedData(Function<CompoundTag, T> readFunction, DataFixTypes dataFixTypes, String id) { // Paper
try {
File file = this.getDataFile(id);
if (file.exists()) {

View file

@ -11,22 +11,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { @@ -0,0 +0,0 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity {
} }
// CraftBukkit end
- org.bukkit.event.entity.EntityTeleportEvent teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(entity1, blockposition1.getX() + 0.5, blockposition1.getY() + 0.5, blockposition1.getZ() + 0.5); // Paper - diff on change
- if (teleEvent.isCancelled()) {
+ // Paper start - EntityTeleportEndGatewayEvent + // Paper start - EntityTeleportEndGatewayEvent
+ org.bukkit.Location location = new org.bukkit.Location(world.getWorld(), blockposition1.getX() + 0.5D, blockposition1.getY(), blockposition1.getZ() + 0.5D); + org.bukkit.Location location = new org.bukkit.Location(world.getWorld(), blockposition1.getX() + 0.5D, blockposition1.getY(), blockposition1.getZ() + 0.5D);
+ location.setPitch(entity1.getXRot()); + location.setPitch(entity1.getXRot());
+ location.setYaw(entity1.getBukkitYaw()); + location.setYaw(entity1.getBukkitYaw());
+
+ org.bukkit.entity.Entity bukkitEntity = entity1.getBukkitEntity(); + org.bukkit.entity.Entity bukkitEntity = entity1.getBukkitEntity();
+ com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent event = new com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent(bukkitEntity, bukkitEntity.getLocation(), location, new org.bukkit.craftbukkit.block.CraftEndGateway(world.getWorld(), blockEntity)); + org.bukkit.event.entity.EntityTeleportEvent teleEvent = new com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent(bukkitEntity, bukkitEntity.getLocation(), location, new org.bukkit.craftbukkit.block.CraftEndGateway(world.getWorld(), blockEntity));
+ if (!event.callEvent()) { + if (!teleEvent.callEvent()) {
+ return; + // Paper end - EntityTeleportEndGatewayEvent
+ } return;
+ // Paper end
entity1.setPortalCooldown();
- entity1.teleportToWithTicket((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D); // Paper - diff on change
+ entity1.teleportToWithTicket(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); // Paper
} }
TheEndGatewayBlockEntity.triggerCooldown(world, pos, state, blockEntity);

View file

@ -545,7 +545,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java
@@ -0,0 +0,0 @@ public class CraftCat extends CraftTameableAnimal implements Cat { @@ -0,0 +0,0 @@ public class CraftCat extends CraftTameableAnimal implements Cat {
.byId(bukkit.ordinal()); return registry.get(CraftNamespacedKey.toMinecraft(bukkit.getKey()));
} }
} }
+ +

View file

@ -11,7 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
@@ -0,0 +0,0 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { @@ -0,0 +0,0 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity {
// CraftBukkit start - Fire PlayerTeleportEvent // CraftBukkit start - Fire PlayerTeleportEvent/EntityTeleportEvent
if (entity1 instanceof ServerPlayer) { if (entity1 instanceof ServerPlayer) {
org.bukkit.craftbukkit.entity.CraftPlayer player = (CraftPlayer) entity1.getBukkitEntity(); org.bukkit.craftbukkit.entity.CraftPlayer player = (CraftPlayer) entity1.getBukkitEntity();
- org.bukkit.Location location = CraftLocation.toBukkit(blockposition1, world.getWorld()).add(0.5D, 0.5D, 0.5D); - org.bukkit.Location location = CraftLocation.toBukkit(blockposition1, world.getWorld()).add(0.5D, 0.5D, 0.5D);
@ -25,11 +25,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (teleEvent.isCancelled()) { if (teleEvent.isCancelled()) {
return; return;
@@ -0,0 +0,0 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { @@ -0,0 +0,0 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity {
// CraftBukkit end
entity1.setPortalCooldown();
- entity1.teleportToWithTicket((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D);
+ entity1.teleportToWithTicket((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D); // Paper - diff on change
} }
TheEndGatewayBlockEntity.triggerCooldown(world, pos, state, blockEntity); - org.bukkit.event.entity.EntityTeleportEvent teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(entity1, blockposition1.getX() + 0.5, blockposition1.getY() + 0.5, blockposition1.getZ() + 0.5);
+ org.bukkit.event.entity.EntityTeleportEvent teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(entity1, blockposition1.getX() + 0.5, blockposition1.getY() + 0.5, blockposition1.getZ() + 0.5); // Paper - diff on change
if (teleEvent.isCancelled()) {
return;
}

@ -1 +1 @@
Subproject commit cdfe62e472085016a8225f356eec9efede9d8b5a Subproject commit 01bb6ba7d0add97af46db9ae8c2c991912033aa7

@ -1 +1 @@
Subproject commit 51eea725f7b2b683ce04c7d2aeb76705086d78e6 Subproject commit cb2ea54def89e749d9d1f6a4a7ea029110f03a43