Interface Attributes


public interface Attributes
Utility class for handling Bukkit Attributes with version compatibility.

This class provides a method to retrieve Bukkit Attributes by name, accommodating differences in how attributes are referenced across different Minecraft server versions.

  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static org.bukkit.attribute.Attribute
    Retrieves a Bukkit Attribute by its name, handling version differences.
  • Method Details

    • getAttributeByName

      static org.bukkit.attribute.Attribute getAttributeByName(String name)
      Retrieves a Bukkit Attribute by its name, handling version differences.

      For versions 1.21.3 and earlier, it attempts to find the attribute directly by name, falling back to "GENERIC_" prefix if not found. For versions 1.21.4 and later, it uses NamespacedKey to look up the attribute, converting underscores to dots for names that contain them.

      Parameters:
      name - The name of the attribute (e.g., "GENERIC_MAX_HEALTH" or "generic.max_health").
      Returns:
      The corresponding Attribute, or null if not found or if the server version is unrecognized.
      Throws:
      IllegalStateException - If the server version is unrecognized.