Interface Killable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
An interface for objects that provide information about the entity that killed them.
This abstraction is used to populate the {OBJECT.KILLER}
macro field in messages.
It allows server operators to define custom or built-in behaviors for logging or describing
the cause of death in messages.
The most common implementation source is a
LivingEntity
,
whose getKiller()
method returns the killing Entity
.
However, plugin-defined objects may implement this interface to expose similar semantics.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Predicate
<org.bukkit.entity.Entity> Predicate that evaluates whether a killer is considered valid and non-blank. -
Method Summary
Modifier and TypeMethodDescriptiondefault MacroStringMap
extractKiller
(MacroKey baseKey, AdapterContextContainer ctx) Extracts a macro string map with the killer's name, using the given base key and context.formatKiller
(org.bukkit.entity.Entity killer) Formats the killer name for use in placeholder replacement.org.bukkit.entity.Entity
Returns the killer of this object, typically aPlayer
.
-
Field Details
-
VALID_KILLER
Predicate that evaluates whether a killer is considered valid and non-blank.
-
-
Method Details
-
getKiller
org.bukkit.entity.Entity getKiller()Returns the killer of this object, typically aPlayer
.- Returns:
- the killer as an
Entity
, ornull
if not available
-
extractKiller
Extracts a macro string map with the killer's name, using the given base key and context.- Parameters:
baseKey
- the macro key that identifies the root placeholderctx
- the adapter context container with formatting tools- Returns:
- a
MacroStringMap
containing the killer field, or an empty map if not resolvable
-
formatKiller
Formats the killer name for use in placeholder replacement.- Parameters:
killer
- the entity that performed the kill- Returns:
- an
Optional<String>
containing the killer's name, if valid
-