mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 20:50:41 +01:00
4d20922b79
* Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: e86f4dc4 PR-1041: Improve getPlayer(String) docs to clarify it matches the name 9738f005 Fix spawner API documentation 69ebd9fd PR-1034: Add TrialSpawnerSpawnEvent 23cffd9c PR-973: Improve spawner API and add API for Trial Spawners 8bf19163 PR-1038: Clarify HumanEntity#openInventory(InventoryView) JavaDoc 1ff76351 SPIGOT-7732, SPIGOT-7786: Add freezing damage modifier 02161cb4 PR-1034: Add CreatureSpawnEvent.SpawnReason#TRIAL_SPAWNER f9cb6f34 SPIGOT-7777: All entity potion effects are removed on death 25d548eb PR-1031: Expose Creeper igniter ccbf0915 SPIGOT-7770: Reserve spaces in shaped recipes for blank ingredients 17f7097c Clarify ambiguity around what is API 71714f0c Remove note from InventoryView JavaDoc aaf49731 PR-1030: Deprecate more unused methods in UnsafeValues 3a9dc689 SPIGOT-7771: Material.getDefaultAttributes always returns an empty map CraftBukkit Changes: c3ceeb6f7 SPIGOT-7814: Call PlayerShearEntityEvent for Bogged 97b1e4f58 Fix wolf armor not dropping from use of shears fd2ef563a SPIGOT-7812: Revert "SPIGOT-7809: Restore shield/banner conversion for base colours" f672c351b SPIGOT-7811: Enchantments are applied on sweeping attack even if damage event is cancelled cfe29350b SPIGOT-7808: Fix implementation of Enchantment#getName() for bad name return 19335f69e SPIGOT-7809: Restore shield/banner conversion for base colours ae4f5a0be SPIGOT-7805: Fix jukebox deserialization 62e3b73a4 SPIGOT-7804: Fix written book serialization aac911d26 SPIGOT-7800, SPIGOT-7801: Keep vanilla behaviour for items dropped on player death 13ece474f PR-1429: Implement TrialSpawnerSpawnEvent bf13e9113 PR-1354: Improve spawner API and add API for Trial Spawners 515fe49e1 Increase outdated build delay 9cd5a19a0 SPIGOT-7794: Cancelling InventoryItemMoveEvent destroys items ce40c7b14 SPIGOT-7796: Kickplayer newlines not working 5167256ff SPIGOT-7795: Fix damage/stats ignore the invulnerable damage time f993563ee Improve cross-world teleportation handling ab29122cf PR-1433: HumanEntity#openInventory(InventoryView) should only support views belonging to the player 764a541c5 SPIGOT-7732: Issue with the "hurt()" method of EntityLiving and invulnerable time 820084b5f SPIGOT-7791: Skull BlockState with null profile causes NullPointerException 5e46f1c82 SPIGOT-7785: Teleporting a player at the right moment can mess up vanilla teleportation cbd95a6b3 SPIGOT-7772: Include hidden / non-sampled players in player count 3153debc5 SPIGOT-7790: Server crashes after bee nest is forced to update e77bb26bb SPIGOT-7788: The healing power of friendship advancement is never granted ee3d7258a SPIGOT-7789: Fix NPE in CraftMetaFirework applyToItem 2889b3a11 PR-1429: Add CreatureSpawnEvent.SpawnReason#TRIAL_SPAWNER cdd05bc7f SPIGOT-7777: Speed attribute stays after death; missing EntityPotionEffectEvent call d0e6af2d4 PR-1428: Expose Creeper igniter d01c70e93 PR-1425: Fix bytecode transformation taking care of class-to-interface compatibility. b2b08f68c SPIGOT-7770: Fix certain shaped recipes not registering 3f8e4161f PR-1426: Deprecate more unused methods in UnsafeValues 2c9dd879e SPIGOT-7771: Material.getDefaultAttributes always returns an empty map Spigot Changes: 491f3675 Rebuild patches 0a642bd7 Rebuild patches 8897571b Rebuild patches cb8cf80c Fix newlines in custom restart message 1aabe506 Rebuild patches
170 lines
13 KiB
Diff
170 lines
13 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Nassim Jahnke <nassim@njahnke.dev>
|
|
Date: Sat, 6 Jan 2024 14:31:00 +0100
|
|
Subject: [PATCH] Fixup NamespacedKey handling
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/inventory/LoomMenu.java b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
index 4f3f6ea43030853bd9df067358a1f4d16c40e6d4..531336c44c46555fef8c001fe8ca00c93624ad42 100644
|
|
--- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
+++ b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
|
@@ -171,12 +171,28 @@ public class LoomMenu extends AbstractContainerMenu {
|
|
return stillValid(this.access, player, Blocks.LOOM);
|
|
}
|
|
|
|
+ private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); // Paper - handle custom banner pattern, skip the event
|
|
+ private static boolean PRINTED_PATTERN_TYPE_NAG = false; // Paper - handle custom banner pattern, skip the event
|
|
+
|
|
@Override
|
|
public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) {
|
|
if (id >= 0 && id < this.selectablePatterns.size()) {
|
|
+ // Paper start - handle custom banner pattern, skip the event (todo remove once this is supported)
|
|
+ java.util.Optional<org.bukkit.block.banner.PatternType> patternType = org.bukkit.craftbukkit.CraftRegistry.unwrapAndConvertHolder(org.bukkit.Registry.BANNER_PATTERN, this.selectablePatterns.get(id));
|
|
+ if (patternType.isEmpty()) {
|
|
+ if (!PRINTED_PATTERN_TYPE_NAG) {
|
|
+ LOGGER.warn("A datapack added a custom banner pattern, those are not supported yet in the API, skipping the PlayerLoomPatternSelectEvent for {}.", player.getScoreboardName());
|
|
+ PRINTED_PATTERN_TYPE_NAG = true;
|
|
+ }
|
|
+ this.selectedBannerPatternIndex.set(id);
|
|
+ this.setupResultSlot((Holder) this.selectablePatterns.get(id));
|
|
+ return true;
|
|
+ }
|
|
+ // Paper end - handle custom banner pattern
|
|
+
|
|
// Paper start - Add PlayerLoomPatternSelectEvent
|
|
int selectablePatternIndex = id;
|
|
- io.papermc.paper.event.player.PlayerLoomPatternSelectEvent event = new io.papermc.paper.event.player.PlayerLoomPatternSelectEvent((Player) player.getBukkitEntity(), ((CraftInventoryLoom) getBukkitView().getTopInventory()), org.bukkit.craftbukkit.block.banner.CraftPatternType.minecraftHolderToBukkit((this.selectablePatterns.get(selectablePatternIndex))));
|
|
+ io.papermc.paper.event.player.PlayerLoomPatternSelectEvent event = new io.papermc.paper.event.player.PlayerLoomPatternSelectEvent((Player) player.getBukkitEntity(), ((CraftInventoryLoom) getBukkitView().getTopInventory()), patternType.get());
|
|
if (!event.callEvent()) {
|
|
player.containerMenu.sendAllDataToRemote();
|
|
return false;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
|
|
index e34deaf398dc6722c3128bdd6b9bc16da2d33bf7..f028daa4f23a1f1868c9922991259739cadc5da2 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
|
|
@@ -38,7 +38,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
|
|
}
|
|
|
|
public static org.bukkit.loot.LootTable minecraftToBukkit(ResourceKey<LootTable> minecraft) {
|
|
- return (minecraft == null) ? null : Bukkit.getLootTable(CraftLootTable.minecraftToBukkitKey(minecraft));
|
|
+ return (minecraft == null || minecraft.location().getPath().isEmpty()) ? null : Bukkit.getLootTable(CraftLootTable.minecraftToBukkitKey(minecraft)); // Paper - fix some NamespacedKey parsing
|
|
}
|
|
|
|
public static NamespacedKey minecraftToBukkitKey(ResourceKey<LootTable> minecraft) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
|
index 334447e222d88bb24676bb154e7057a4147d0f41..d21b7e39d71c785f47f790e1ad4be33a8e8e6e51 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
|
@@ -111,6 +111,16 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
|
+ ", this can happen if a plugin creates its own registry entry with out properly registering it.");
|
|
}
|
|
|
|
+ // Paper start - fixup upstream being dum
|
|
+ public static <T extends org.bukkit.Keyed, M> java.util.Optional<T> unwrapAndConvertHolder(final io.papermc.paper.registry.RegistryKey<T> registryKey, final Holder<M> value) {
|
|
+ return unwrapAndConvertHolder(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(registryKey), value);
|
|
+ }
|
|
+
|
|
+ public static <T extends org.bukkit.Keyed, M> java.util.Optional<T> unwrapAndConvertHolder(final Registry<T> registry, final Holder<M> value) {
|
|
+ return value.unwrapKey().map(key -> registry.get(CraftNamespacedKey.fromMinecraft(key.location())));
|
|
+ }
|
|
+ // Paper end - fixup upstream being dum
|
|
+
|
|
// Paper - move to PaperRegistries
|
|
|
|
// Paper - NOTE: As long as all uses of the method below relate to *serialization* via ConfigurationSerializable, it's fine
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java
|
|
index cc97638e038ea64ad180ebfded2528aa07d1809e..10e4318782107644f67818109784fff60d017e0a 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java
|
|
@@ -37,6 +37,7 @@ public class CraftAttribute {
|
|
string = FieldRename.convertAttributeName(ApiVersion.CURRENT, string);
|
|
string = string.toLowerCase(Locale.ROOT);
|
|
NamespacedKey key = NamespacedKey.fromString(string);
|
|
+ if (key == null) return null; // Paper - Fixup NamespacedKey handling
|
|
|
|
// Now also convert from when keys where saved
|
|
return CraftRegistry.get(Registry.ATTRIBUTE, key, ApiVersion.CURRENT);
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
|
|
index afed8bdb9bd6a135e9b5f7bd9bfc61964cb240f7..26088d4039599e7bd1ad8017d845e7b1c15be9e1 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
|
|
@@ -38,7 +38,11 @@ public class CraftBanner extends CraftBlockEntityState<BannerBlockEntity> implem
|
|
if (banner.getPatterns() != null) {
|
|
for (int i = 0; i < banner.getPatterns().layers().size(); i++) {
|
|
BannerPatternLayers.Layer p = banner.getPatterns().layers().get(i);
|
|
- this.patterns.add(new Pattern(DyeColor.getByWoolData((byte) p.color().getId()), CraftPatternType.minecraftHolderToBukkit(p.pattern())));
|
|
+ // Paper start - fix upstream not handling custom banner pattern
|
|
+ java.util.Optional<org.bukkit.block.banner.PatternType> type = org.bukkit.craftbukkit.CraftRegistry.unwrapAndConvertHolder(org.bukkit.Registry.BANNER_PATTERN, p.pattern());
|
|
+ if (type.isEmpty()) continue;
|
|
+ this.patterns.add(new Pattern(DyeColor.getByWoolData((byte) p.color().getId()), type.get()));
|
|
+ // Paper end
|
|
}
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
|
|
index 2c57fd269484ed79814d974877585f9f7e6393d3..865977ce17fbb8793a1eefd71079729e83f5cfaf 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
|
|
@@ -38,8 +38,9 @@ public class CraftMetaArmor extends CraftMetaItem implements ArmorMeta {
|
|
super(tag);
|
|
|
|
getOrEmpty(tag, CraftMetaArmor.TRIM).ifPresent((trimCompound) -> {
|
|
- TrimMaterial trimMaterial = CraftTrimMaterial.minecraftHolderToBukkit(trimCompound.material());
|
|
- TrimPattern trimPattern = CraftTrimPattern.minecraftHolderToBukkit(trimCompound.pattern());
|
|
+ TrimMaterial trimMaterial = org.bukkit.craftbukkit.CraftRegistry.unwrapAndConvertHolder(io.papermc.paper.registry.RegistryKey.TRIM_MATERIAL, trimCompound.material()).orElse(null); // Paper - fix upstream not being correct
|
|
+ TrimPattern trimPattern = org.bukkit.craftbukkit.CraftRegistry.unwrapAndConvertHolder(io.papermc.paper.registry.RegistryKey.TRIM_PATTERN, trimCompound.pattern()).orElse(null); // Paper - fix upstream not being correct
|
|
+ if (trimMaterial == null || trimPattern == null) return; // Paper - just delete the trim because upstream is not doing this right
|
|
|
|
this.trim = new ArmorTrim(trimMaterial, trimPattern);
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java
|
|
index 1c1a2d66d1ebcbe2ded732e759d0f9d471d43b56..c56fb1eeea79176c4dbb1e9c0a8023f86220fe6a 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java
|
|
@@ -42,7 +42,7 @@ public class CraftMetaBanner extends CraftMetaItem implements BannerMeta {
|
|
for (int i = 0; i < Math.min(patterns.size(), 20); i++) {
|
|
BannerPatternLayers.Layer p = patterns.get(i);
|
|
DyeColor color = DyeColor.getByWoolData((byte) p.color().getId());
|
|
- PatternType pattern = CraftPatternType.minecraftHolderToBukkit(p.pattern());
|
|
+ PatternType pattern = org.bukkit.craftbukkit.CraftRegistry.unwrapAndConvertHolder(org.bukkit.Registry.BANNER_PATTERN, p.pattern()).orElse(null); // Paper - fix upstream not handling custom banner pattern
|
|
|
|
if (color != null && pattern != null) {
|
|
this.patterns.add(new Pattern(color, pattern));
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java
|
|
index 478059eb3ad76b41e6a20e9b489a2a4fb19e7c7c..3599ef1675b6091e9b67fb5241886460f106f9b4 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMusicInstrument.java
|
|
@@ -30,7 +30,7 @@ public class CraftMetaMusicInstrument extends CraftMetaItem implements MusicInst
|
|
super(tag);
|
|
|
|
getOrEmpty(tag, CraftMetaMusicInstrument.GOAT_HORN_INSTRUMENT).ifPresent((instrument) -> {
|
|
- this.instrument = CraftMusicInstrument.minecraftHolderToBukkit(instrument);
|
|
+ this.instrument = org.bukkit.craftbukkit.CraftRegistry.unwrapAndConvertHolder(org.bukkit.Registry.INSTRUMENT, instrument).orElse(null); // Paper - fix upstream not handling custom instruments
|
|
});
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java
|
|
index 82a50b06c08b632f77d73745e1fa9bd22dfd950a..f1d8ed4a2b8959873b02d57f6a40323a841f3d7f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionType.java
|
|
@@ -69,6 +69,7 @@ public class CraftPotionType implements PotionType.InternalPotionData {
|
|
string = FieldRename.convertPotionTypeName(ApiVersion.CURRENT, string);
|
|
string = string.toLowerCase(Locale.ROOT);
|
|
NamespacedKey key = NamespacedKey.fromString(string);
|
|
+ if (key == null) return null; // Paper - Fixup NamespacedKey handling
|
|
|
|
// Now also convert from when keys where saved
|
|
return CraftRegistry.get(Registry.POTION, key, ApiVersion.CURRENT);
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
|
|
index dc88ba24ed3b0024c39a30c2d90628fc708d63cf..944bed9b6c803df1a312383fed9de7d61e7d2c70 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
|
|
@@ -13,7 +13,7 @@ public final class CraftNamespacedKey {
|
|
return null;
|
|
}
|
|
ResourceLocation minecraft = ResourceLocation.tryParse(string);
|
|
- return (minecraft == null) ? null : CraftNamespacedKey.fromMinecraft(minecraft);
|
|
+ return (minecraft == null || minecraft.getPath().isEmpty()) ? null : CraftNamespacedKey.fromMinecraft(minecraft); // Paper - Bukkit's parser does not match Vanilla for empty paths
|
|
}
|
|
|
|
public static NamespacedKey fromString(String string) {
|