Fix / Implement merge changes

This commit is contained in:
DerFrZocker 2021-12-25 12:17:55 +01:00
parent fe6439528f
commit d5bd36a2d4
No known key found for this signature in database
GPG key ID: 713F71FFFE1DDF91
3 changed files with 22 additions and 11 deletions

View file

@ -2657,13 +2657,13 @@ public interface Material extends Keyed, Comparable<Material> {
* @param slot the {@link EquipmentSlot} to check * @param slot the {@link EquipmentSlot} to check
* @return the immutable {@link Multimap} with the respective default * @return the immutable {@link Multimap} with the respective default
* Attributes and modifiers, or an empty map if no attributes are set. * Attributes and modifiers, or an empty map if no attributes are set.
* @see Material#asItemType()
* @see ItemType#getDefaultAttributeModifiers()
* @deprecated Can only get default attribute modifiers from ItemType
*/ */
@NotNull @NotNull
public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(@NotNull EquipmentSlot slot) { @Deprecated
Validate.isTrue(isItem(), "The Material is not an item!"); Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(@NotNull EquipmentSlot slot);
return Bukkit.getUnsafe().getDefaultAttributeModifiers(this, slot);
}
/** /**
* @param other to compare to. * @param other to compare to.

View file

@ -1,11 +1,7 @@
package org.bukkit; package org.bukkit;
import com.google.common.collect.Multimap;
import org.bukkit.advancement.Advancement; import org.bukkit.advancement.Advancement;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
import org.bukkit.plugin.InvalidPluginException; import org.bukkit.plugin.InvalidPluginException;
@ -74,8 +70,6 @@ public interface UnsafeValues {
*/ */
boolean removeAdvancement(NamespacedKey key); boolean removeAdvancement(NamespacedKey key);
Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(Material material, EquipmentSlot slot);
Material getLegacyMaterial(String name); Material getLegacyMaterial(String name);
@Deprecated @Deprecated

View file

@ -1,6 +1,9 @@
package org.bukkit.inventory; package org.bukkit.inventory;
import com.google.common.collect.Multimap;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -1173,4 +1176,18 @@ public interface ItemType extends Material {
*/ */
@NotNull @NotNull
EquipmentSlot getEquipmentSlot(); EquipmentSlot getEquipmentSlot();
/**
* Return an immutable copy of all default {@link Attribute}s and their
* {@link AttributeModifier}s for a given {@link EquipmentSlot}.
*
* Default attributes are those that are always preset on some items, such
* as the attack damage on weapons or the armor value on armor.
*
* @param slot the {@link EquipmentSlot} to check
* @return the immutable {@link Multimap} with the respective default
* Attributes and modifiers, or an empty map if no attributes are set.
*/
@NotNull
Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(@NotNull EquipmentSlot slot);
} }