Interface Locatable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents an object that has a
Location
, which can be extracted
and used for macro substitution in messages.
This interface is used by the LocationAdapter
to extract structured location data for use in messages. It supports both full string representations and
granular subfields such as world name and block coordinates.
Any plugin-defined object can implement this interface to automatically enable macro expansion of the form:
{OBJECT.LOCATION}
– full formatted location string{OBJECT.LOCATION.WORLD}
– world name (optionally aliased by Multiverse){OBJECT.LOCATION.X}
,{OBJECT.LOCATION.Y}, {OBJECT.LOCATION.Z}
– localized coordinate values
The resulting macro values are extracted via extractLocation(MacroKey, AdapterContextContainer)
.
This method is used internally by the MessageBuilder pipeline and should not need to be called directly.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Enumeration of subfields extractable from aLocation
. -
Method Summary
Modifier and TypeMethodDescriptiondefault MacroStringMap
extractLocation
(MacroKey baseKey, AdapterContextContainer ctx) Extracts macro key-value pairs representing location data from this object.formatLocation
(org.bukkit.Location location, AdapterContextContainer ctx) Produces a formatted string representation of the given location, consisting of the world name followed by localized coordinates.org.bukkit.Location
Returns the BukkitLocation
associated with this object.getLocationWorldName
(org.bukkit.Location location, AdapterContextContainer ctx) Resolves the name of the world for the givenLocation
.
-
Method Details
-
getLocation
org.bukkit.Location getLocation()Returns the BukkitLocation
associated with this object.- Returns:
- the location of the object, or
null
if none exists
-
extractLocation
Extracts macro key-value pairs representing location data from this object.The returned
MacroStringMap
may contain:LOCATION
– formatted string of world name and coordinatesLOCATION.WORLD
– resolved world name (Multiverse alias if available)LOCATION.X
,Y
,Z
– localized block coordinates
- Parameters:
baseKey
- the top-level macro key associated with this objectctx
- a container providing access to formatters and world name resolution- Returns:
- a
MacroStringMap
containing extracted location-related macro keys
-
getLocationWorldName
static Optional<String> getLocationWorldName(org.bukkit.Location location, AdapterContextContainer ctx) Resolves the name of the world for the givenLocation
.If Multiverse is installed and enabled, this method may return an alias rather than the raw world name.
- Parameters:
location
- the Bukkit locationctx
- the context container with theWorldNameResolver
- Returns:
- an optional world name, or empty if it could not be resolved
-
formatLocation
Produces a formatted string representation of the given location, consisting of the world name followed by localized coordinates.Example output:
world [123, 64, -512]
- Parameters:
location
- the location to formatctx
- the context container with the number formatter and world name resolver- Returns:
- an
Optional<String>
containing the formatted location, or empty if the location isnull
-