mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
#691: Add Material#getDefaultAttributeModifiers
By: coll1234567 <joshl5324@gmail.com>
This commit is contained in:
parent
0503e4faed
commit
489aef2efc
@ -1,11 +1,14 @@
|
||||
package org.bukkit;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.block.data.AnaloguePowerable;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
@ -9757,4 +9760,24 @@ public enum Material implements Keyed {
|
||||
// </editor-fold>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Only available when {@link #isItem()} is true.
|
||||
*
|
||||
* @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
|
||||
public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(@NotNull EquipmentSlot slot) {
|
||||
Validate.isTrue(isItem(), "The Material is not an item!");
|
||||
|
||||
return Bukkit.getUnsafe().getDefaultAttributeModifiers(this, slot);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,11 @@
|
||||
package org.bukkit;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import org.bukkit.advancement.Advancement;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.plugin.InvalidPluginException;
|
||||
@ -69,4 +73,6 @@ public interface UnsafeValues {
|
||||
* @return true if a file matching this key was found and deleted
|
||||
*/
|
||||
boolean removeAdvancement(NamespacedKey key);
|
||||
|
||||
Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(Material material, EquipmentSlot slot);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user