Improve item default attribute API
This commit is contained in:
@@ -4860,6 +4860,23 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
|||||||
}
|
}
|
||||||
// Paper end - item rarity API
|
// Paper end - item rarity API
|
||||||
|
|
||||||
|
// Paper start - item default attributes API
|
||||||
|
/**
|
||||||
|
* Returns an immutable multimap of attributes for the slot.
|
||||||
|
* {@link #isItem()} must be true for this material.
|
||||||
|
*
|
||||||
|
* @param equipmentSlot the slot to get the attributes for
|
||||||
|
* @throws IllegalArgumentException if {@link #isItem()} is false
|
||||||
|
* @return an immutable multimap of attributes
|
||||||
|
* @deprecated use {@link #getDefaultAttributeModifiers(EquipmentSlot)}
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(forRemoval = true, since = "1.20.5")
|
||||||
|
public Multimap<Attribute, AttributeModifier> getItemAttributes(@NotNull EquipmentSlot equipmentSlot) {
|
||||||
|
return this.getDefaultAttributeModifiers(equipmentSlot);
|
||||||
|
}
|
||||||
|
// Paper end - item default attributes API
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not use for any reason.
|
* Do not use for any reason.
|
||||||
*
|
*
|
||||||
@@ -5567,13 +5584,34 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Paper start - improve default item attribute API
|
||||||
|
/**
|
||||||
|
* Return an immutable copy of all default {@link Attribute}s and their {@link AttributeModifier}s.
|
||||||
|
* <p>
|
||||||
|
* Default attributes are those that are always preset on some items, unless
|
||||||
|
* they are specifically overridden on that {@link ItemStack}. Examples include
|
||||||
|
* the attack damage on weapons or the armor value on armor.
|
||||||
|
* <p>
|
||||||
|
* Only available when {@link #isItem()} is true.
|
||||||
|
*
|
||||||
|
* @return the immutable {@link Multimap} with the respective default
|
||||||
|
* Attributes and modifiers, or an empty map if no attributes are set.
|
||||||
|
*/
|
||||||
|
public @NotNull @org.jetbrains.annotations.Unmodifiable Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers() {
|
||||||
|
final ItemType type = this.asItemType();
|
||||||
|
Preconditions.checkArgument(type != null, "The Material is not an item!");
|
||||||
|
return type.getDefaultAttributeModifiers();
|
||||||
|
}
|
||||||
|
// Paper end - improve default item attribute API
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an immutable copy of all default {@link Attribute}s and their
|
* Return an immutable copy of all default {@link Attribute}s and their
|
||||||
* {@link AttributeModifier}s for a given {@link EquipmentSlot}.
|
* {@link AttributeModifier}s for a given {@link EquipmentSlot}.
|
||||||
*
|
* <p>
|
||||||
* Default attributes are those that are always preset on some items, such
|
* Default attributes are those that are always preset on some items, unless
|
||||||
* as the attack damage on weapons or the armor value on armor.
|
* they are specifically overridden on that {@link ItemStack}. Examples include
|
||||||
*
|
* the attack damage on weapons or the armor value on armor.
|
||||||
|
* <p>
|
||||||
* Only available when {@link #isItem()} is true.
|
* Only available when {@link #isItem()} is true.
|
||||||
*
|
*
|
||||||
* @param slot the {@link EquipmentSlot} to check
|
* @param slot the {@link EquipmentSlot} to check
|
||||||
|
|||||||
@@ -2368,6 +2368,21 @@ public interface ItemType extends Keyed, Translatable, net.kyori.adventure.trans
|
|||||||
// @NotNull
|
// @NotNull
|
||||||
// EquipmentSlot getEquipmentSlot();
|
// EquipmentSlot getEquipmentSlot();
|
||||||
|
|
||||||
|
// Paper start - improve default item attribute API
|
||||||
|
/**
|
||||||
|
* Return an immutable copy of all default {@link Attribute}s and their
|
||||||
|
* {@link AttributeModifier}s.
|
||||||
|
* <p>
|
||||||
|
* Default attributes are those that are always preset on some items, unless
|
||||||
|
* they are specifically overridden on that {@link ItemStack}. Examples include
|
||||||
|
* the attack damage on weapons or the armor value on armor.
|
||||||
|
*
|
||||||
|
* @return the immutable {@link Multimap} with the respective default
|
||||||
|
* Attributes and modifiers, or an empty map if no attributes are set.
|
||||||
|
*/
|
||||||
|
@NotNull @org.jetbrains.annotations.Unmodifiable Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers();
|
||||||
|
// Paper end - improve default item attribute API
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an immutable copy of all default {@link Attribute}s and their
|
* Return an immutable copy of all default {@link Attribute}s and their
|
||||||
* {@link AttributeModifier}s for a given {@link EquipmentSlot}.
|
* {@link AttributeModifier}s for a given {@link EquipmentSlot}.
|
||||||
|
|||||||
Reference in New Issue
Block a user