Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Ownable
Represents an object that has a concept of ownership, expressed through an AnimalTamer.

This interface is used to extract an owner identifier—typically a player name—for insertion into a MacroStringMap used in macro replacement. Implementing this interface enables support for the {OBJECT.OWNER} macro in localized message templates.

Ownership in this context is not limited to entity taming. It may also refer to logical or permission-based ownership, such as a player who owns or controls a placed structure or data-bound object—e.g., the owner of a DeathChest, or a protected area. The use of AnimalTamer allows support for a broad range of owner-capable entities, including OfflinePlayer, which is important for messages about players who may be offline.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Predicate<org.bukkit.entity.AnimalTamer>
    Predicate used to validate an owner.
  • Method Summary

    Modifier and Type
    Method
    Description
    Extracts the macro value for the owner's name and adds it to a MacroStringMap, using the {OBJECT.OWNER} key.
    formatOwner(org.bukkit.entity.AnimalTamer owner)
    Returns a formatted string representing the owner's name, if available and valid.
    org.bukkit.entity.AnimalTamer
    Returns the AnimalTamer representing the owner of this object.
  • Field Details

    • VALID_OWNER

      static final Predicate<org.bukkit.entity.AnimalTamer> VALID_OWNER
      Predicate used to validate an owner. An owner is considered valid if it is non-null and has a non-blank name.
  • Method Details

    • getOwner

      org.bukkit.entity.AnimalTamer getOwner()
      Returns the AnimalTamer representing the owner of this object. This may include tamed entities, or other objects with an ownership link.
      Returns:
      the owner of this object, or null if no owner is defined
    • extractOwner

      default MacroStringMap extractOwner(MacroKey baseKey, AdapterContextContainer ctx)
      Extracts the macro value for the owner's name and adds it to a MacroStringMap, using the {OBJECT.OWNER} key.
      Parameters:
      baseKey - the macro key prefix (e.g., OBJECT) used to construct the full macro key
      ctx - the adapter context container, which holds formatting dependencies
      Returns:
      a MacroStringMap containing the extracted owner name, or an empty map if the owner is null or invalid
    • formatOwner

      static Optional<String> formatOwner(org.bukkit.entity.AnimalTamer owner)
      Returns a formatted string representing the owner's name, if available and valid.
      Parameters:
      owner - the AnimalTamer to format
      Returns:
      an Optional<String> containing the owner's name, or empty if not valid