Klasse PetService

java.lang.Object
de.delinkedde.mobarenareborn.pet.PetService

public final class PetService extends Object
Companion pets and mounts spawned from kit items.

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.

  • Felddetails

    • PET_KEY

      public static final String PET_KEY
      Persistent-data key storing the owner UUID of a pet.
      Siehe auch:
    • MOUNT_KEY

      public static final String 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 logging
      config - the configuration manager holding the item mappings
      scaler - 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

      @NotNull public @NotNull NamespacedKey petKey()
      Gibt zurück:
      the persistent-data key marking pets
    • mountKey

      @NotNull public @NotNull NamespacedKey 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 fighter
      arenaClass - the class played, for the pet name template (null = no template)
    • removeCompanions

      public void removeCompanions(@NotNull @NotNull UUID owner)
      Removes all companions of a player. Call on leave, elimination and round end.
      Parameter:
      owner - the owner's unique id
    • isCompanion

      public boolean isCompanion(@NotNull @NotNull Entity entity)
      Parameter:
      entity - the entity to test
      Gibt zurück:
      whether the entity is a pet or mount
    • isMount

      public boolean isMount(@NotNull @NotNull Entity entity)
      Parameter:
      entity - the entity to test
      Gibt zurück:
      whether the entity is a mount
    • ownerOf

      @Nullable public @Nullable Player ownerOf(@NotNull @NotNull Entity entity)
      Resolves the online owner of a pet or mount.
      Parameter:
      entity - the companion
      Gibt zurück:
      the owner, or null when the entity is no companion or the owner is offline
    • petsOf

      @NotNull public @NotNull List<Entity> petsOf(@NotNull @NotNull UUID owner)
      Parameter:
      owner - the owner's unique id
      Gibt zurück:
      the live pets of the owner (mounts excluded)
    • resolveKillCredit

      @Nullable public @Nullable Player resolveKillCredit(@NotNull @NotNull LivingEntity victim)
      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