Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions paper-api/src/main/java/org/bukkit/attribute/Attribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.Translatable;
import org.bukkit.entity.EntityType;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -169,6 +170,13 @@ private static Attribute getAttribute(@NotNull String key) {
@NotNull
Sentiment getSentiment();

/**
* {@return the default value of this attribute}
* <p>
* Default attribute values may differ between entity types, use {@link EntityType#getDefaultAttributes()} to get default attribute values for a specific entity type.
*/
double getDefaultValue();

/**
* @param name of the attribute.
* @return the attribute with the given name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ public interface AttributeInstance {
* Gets the default value of the Attribute attached to this instance.
*
* @return server default value
*
* @deprecated This method is placed misleadingly as it does not return the default value in the current entity's context, but in the server's context.
* Use {@link Attribute#getDefaultValue()} as a replacement and see the note there about default values for specific entity types.
* @see Attribute#getDefaultValue()
* @see org.bukkit.entity.EntityType#getDefaultAttributes()
*/
@Deprecated(since = "1.21.11")
double getDefaultValue();
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public Sentiment getSentiment() {
return Sentiment.valueOf(this.getHandle().sentiment.name());
}

@Override
public double getDefaultValue() {
return this.getHandle().getDefaultValue();
}

@Override
public String getTranslationKey() {
return this.getHandle().getDescriptionId();
Expand Down
Loading