PaperMC/Spigot-Server-Patches/0432-Be-more-tolerant-of-invalid-attributes.patch
Aikar 36f34f01c0
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears 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:
da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots
3abebc9f #492: Let Tameable extend Animals rather than Entity
941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent
4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME

CraftBukkit Changes:
933e9094 #664: Add methods to get/set ItemStacks in EquipmentSlots
18722312 #662: Expose ItemStack and hand used in PlayerShearEntityEvent
2020-05-06 06:05:22 -04:00

29 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach@zachbr.io>
Date: Thu, 6 Feb 2020 19:20:27 -0600
Subject: [PATCH] Be more tolerant of invalid attributes
Prior to this commit, the player would be disconnected if they ever encountered an attribute with a name that did
not match Bukkit's expected vanilla scheme. It appears that datapacks can set whatever attribute name they want,
ignoring vanilla's typical scheme.
In a more perfect world the API would expose some way to interact with these attributes, however Bukkit is not
particularly flexible in this area. Perhaps this is an area for future expansion at a later time.
diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
index 77e584b129ab21959b7c33ac45e5841935e86ac8..007d28b16ce16295c7d398c09557b8c0777657c6 100644
--- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
+++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
@@ -47,6 +47,12 @@ public class CraftAttributeMap implements Attributable {
public static Attribute fromMinecraft(String nms) {
String[] split = nms.split("\\.", 2);
+ // Paper start - Datapacks can set their own attributes that may not match our expectations, ignore them
+ if (split.length != 2) {
+ return null;
+ }
+ // Paper end
+
String generic = split[0];
String descriptor = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, split[1]); // movementSpeed -> MOVEMENT_SPEED
String fin = generic + "_" + descriptor;