java.lang.Object
com.winterhavenmc.library.messagebuilder.pipeline.adapters.location.LocationAdapter
All Implemented Interfaces:
Adapter

public class LocationAdapter extends Object implements Adapter
Adapter for objects that expose a Location, either directly or via a Locatable interface.

This adapter provides macro key support for structured location data, including:

  • [OBJECT.LOCATION} – the full location string, including world and coordinates
  • [OBJECT.LOCATION.WORLD}, [OBJECT.LOCATION.X}, Y, Z – individual components

The world name is resolved using the WorldNameResolver if Multiverse is installed and enabled, allowing server-defined aliases to appear in resolved messages.

This adapter supports the following object types:

  • Locatable – objects implementing the Locatable interface
  • Entity
  • OfflinePlayer
  • Chest and DoubleChest
  • Block and BlockState
  • Inventory
  • Raid
  • LootContext
  • Location itself

Each type is adapted to a Locatable using a method reference that returns the underlying Location.

See Also:
  • Constructor Details

    • LocationAdapter

      public LocationAdapter()
  • Method Details

    • adapt

      public Optional<Locatable> adapt(Object obj)
      Description copied from interface: Adapter
      Attempts to adapt the given object to a type-specific representation for macro extraction.

      This method may return a known interface (e.g., Nameable) or a domain object suitable for field extraction by a resolver. If the object is not compatible, an empty Optional is returned.

      Specified by:
      adapt in interface Adapter
      Parameters:
      obj - the object to evaluate and adapt
      Returns:
      an optional adapted representation, or empty if not supported