Klasse PetService
When a round starts, configured kit items turn into companions: the item stack is consumed and
one pet spawns per item (pets.items, for example 5 bones = 5 wolves), capped by
pets.max-per-player. Any living entity type works - a blaze fights alongside its owner
just like a wolf. Pets carry the owner's UUID in their persistent data, are named per class
(pet-name with the <player-name> placeholder), only attack arena mobs, cannot be
damaged, and their kills count for the owner. Mount items (pets.mount-items) spawn a
saddled mount instead: only the owner can ride it and it stays put when dismounted.
All companions are removed when their owner leaves, is eliminated, or the round ends. They are never persisted; orphans from a crash are swept like orphaned arena mobs.
-
Feldübersicht
Felder -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungPetService(@NotNull MobArenaPlugin plugin, @NotNull ConfigManager config, @NotNull MobScaler scaler) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungbooleanisCompanion(@NotNull Entity entity) boolean@NotNull NamespacedKeymountKey()@Nullable PlayerResolves the online owner of a pet or mount.@NotNull NamespacedKeypetKey()voidremoveCompanions(@NotNull UUID owner) Removes all companions of a player.@Nullable PlayerresolveKillCredit(@NotNull LivingEntity victim) Resolves the owner credited for a mob death caused by a pet (directly or via projectile).voidspawnCompanions(@NotNull Player player, @Nullable ArenaClass arenaClass) Converts the player's configured kit items into pets and mounts.voidstart()Starts the companion brain (every half second).
-
Felddetails
-
PET_KEY
Persistent-data key storing the owner UUID of a pet.- Siehe auch:
-
MOUNT_KEY
Persistent-data key storing the owner UUID of a mount.- Siehe auch:
-
-
Konstruktordetails
-
PetService
public PetService(@NotNull @NotNull MobArenaPlugin plugin, @NotNull @NotNull ConfigManager config, @NotNull @NotNull MobScaler scaler) - Parameter:
plugin- the owning plugin, used for the persistent-data keys and loggingconfig- the configuration manager holding the item mappingsscaler- the mob scaler, providing the arena-mob marker pets hunt for
-
-
Methodendetails
-
start
public void start()Starts the companion brain (every half second). Ground pets actively walk (and jump) after their owner via the pathfinder and chase their target on foot; flying pets - a blaze, a bee - are steered through the air and hover near the owner when idle. Idle pets pick the nearest arena mob as their target. Teleporting is only the last resort when a pet falls more than 30 blocks behind. -
petKey
- Gibt zurück:
- the persistent-data key marking pets
-
mountKey
- Gibt zurück:
- the persistent-data key marking mounts
-
spawnCompanions
public void spawnCompanions(@NotNull @NotNull Player player, @Nullable @Nullable ArenaClass arenaClass) Converts the player's configured kit items into pets and mounts. Call after the loadout was applied, at round start.- Parameter:
player- the fighterarenaClass- the class played, for the pet name template (null= no template)
-
removeCompanions
Removes all companions of a player. Call on leave, elimination and round end.- Parameter:
owner- the owner's unique id
-
isCompanion
- Parameter:
entity- the entity to test- Gibt zurück:
- whether the entity is a pet or mount
-
isMount
- Parameter:
entity- the entity to test- Gibt zurück:
- whether the entity is a mount
-
ownerOf
Resolves the online owner of a pet or mount.- Parameter:
entity- the companion- Gibt zurück:
- the owner, or
nullwhen the entity is no companion or the owner is offline
-
petsOf
- Parameter:
owner- the owner's unique id- Gibt zurück:
- the live pets of the owner (mounts excluded)
-
resolveKillCredit
Resolves the owner credited for a mob death caused by a pet (directly or via projectile).- Parameter:
victim- the dead mob- Gibt zurück:
- the owner to credit, or
null
-