From e61abecd39fd22fd96bf92294a22d0ef3cb1c845 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Thu, 25 Jun 2020 13:19:09 +1000 Subject: [PATCH] SPIGOT-5805: NPE when getting an Attribute from a Player By: md_5 --- .../java/org/bukkit/attribute/Attribute.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/attribute/Attribute.java b/paper-api/src/main/java/org/bukkit/attribute/Attribute.java index 25df04ca6b..13eac9ad2c 100644 --- a/paper-api/src/main/java/org/bukkit/attribute/Attribute.java +++ b/paper-api/src/main/java/org/bukkit/attribute/Attribute.java @@ -1,6 +1,5 @@ package org.bukkit.attribute; -import java.util.Locale; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.jetbrains.annotations.NotNull; @@ -13,56 +12,60 @@ public enum Attribute implements Keyed { /** * Maximum health of an Entity. */ - GENERIC_MAX_HEALTH, + GENERIC_MAX_HEALTH("generic.max_health"), /** * Range at which an Entity will follow others. */ - GENERIC_FOLLOW_RANGE, + GENERIC_FOLLOW_RANGE("generic.follow_range"), /** * Resistance of an Entity to knockback. */ - GENERIC_KNOCKBACK_RESISTANCE, + GENERIC_KNOCKBACK_RESISTANCE("generic.knockback_resistance"), /** * Movement speed of an Entity. */ - GENERIC_MOVEMENT_SPEED, + GENERIC_MOVEMENT_SPEED("generic.movement_speed"), /** * Flying speed of an Entity. */ - GENERIC_FLYING_SPEED, + GENERIC_FLYING_SPEED("generic.flying_speed"), /** * Attack damage of an Entity. */ - GENERIC_ATTACK_DAMAGE, + GENERIC_ATTACK_DAMAGE("generic.attack_damage"), + /** + * Attack knockback of an Entity. + */ + GENERIC_ATTACK_KNOCKBACK("generic.attack_knockback"), /** * Attack speed of an Entity. */ - GENERIC_ATTACK_SPEED, + GENERIC_ATTACK_SPEED("generic.attack_speed"), /** * Armor bonus of an Entity. */ - GENERIC_ARMOR, + GENERIC_ARMOR("generic.armor"), /** * Armor durability bonus of an Entity. */ - GENERIC_ARMOR_TOUGHNESS, + GENERIC_ARMOR_TOUGHNESS("generic.armor_toughness"), /** * Luck bonus of an Entity. */ - GENERIC_LUCK, + GENERIC_LUCK("generic.luck"), /** * Strength with which a horse will jump. */ - HORSE_JUMP_STRENGTH, + HORSE_JUMP_STRENGTH("horse.jump_strength"), /** * Chance of a zombie to spawn reinforcements. */ - ZOMBIE_SPAWN_REINFORCEMENTS; + ZOMBIE_SPAWN_REINFORCEMENTS("zombie.spawn_reinforcements"); private final NamespacedKey key; - private Attribute() { - this.key = NamespacedKey.minecraft(this.name().toLowerCase(Locale.ROOT)); + private Attribute(String key) { + this.key = NamespacedKey.minecraft(key); } @NotNull