Class EntityManager

java.lang.Object
com.ranull.graves.manager.EntityDataManager
com.ranull.graves.manager.EntityManager

public final class EntityManager extends EntityDataManager
Manages the operations and lifecycle of entities within the Graves plugin.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Graves
    The main plugin instance associated with Graves.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes the EntityManager with the specified plugin instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canOpenGrave(org.bukkit.entity.Player player, Grave grave)
    Checks if a player can open a specified grave.
    void
    createArmorStand(org.bukkit.Location location, Grave grave)
    Creates an armor stand at a specified location associated with a grave.
    org.bukkit.inventory.ItemStack
    createGraveCompass(org.bukkit.entity.Player player, org.bukkit.Location location, Grave grave)
    Creates a grave compass for the specified player, location, and grave.
    void
    createItemFrame(org.bukkit.Location location, Grave grave)
    Creates an item frame at a specified location associated with a grave.
    Map<org.bukkit.inventory.ItemStack,UUID>
    getCompassesFromInventory(org.bukkit.entity.HumanEntity player)
    Retrieves a map of compasses and their associated UUIDs from a player's inventory.
    getDataString(org.bukkit.entity.Entity entity, String key)
    Retrieves the persistent data string associated with the given key from the specified entity.
    getEntityName(org.bukkit.entity.Entity entity)
    Returns the name of the specified entity.
    Map<org.bukkit.inventory.EquipmentSlot,org.bukkit.inventory.ItemStack>
    getEquipmentMap(org.bukkit.entity.LivingEntity livingEntity, Grave grave)
    Retrieves a map of equipment slots and their corresponding item stacks for a living entity and grave.
    getGraveFromEntityData(org.bukkit.entity.Entity entity)
    Retrieves a Grave object from the persistent data or metadata of the specified entity.
    getGraveUUIDFromItemStack(org.bukkit.inventory.ItemStack itemStack)
    Retrieves the grave UUID from an item stack.
    double
    getTeleportCost(org.bukkit.Location location1, org.bukkit.Location location2, Grave grave)
    Calculates the cost of teleportation between two locations.
    boolean
    hasDataByte(org.bukkit.entity.Entity entity, String string)
    Checks if the specified entity has a persistent data byte with the given key.
    boolean
    hasDataString(org.bukkit.entity.Entity entity, String string)
    Checks if the specified entity has a persistent data string with the given key.
    void
    playPlayerSound(String string, org.bukkit.entity.Entity entity, Grave grave)
    Plays a player-specific sound at the entity's location.
    void
    playPlayerSound(String string, org.bukkit.entity.Entity entity, List<String> permissionList)
    Plays a player-specific sound at the entity's location with a permission list.
    void
    playPlayerSound(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave)
    Plays a player-specific sound at a specified location for an entity.
    void
    playPlayerSound(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, List<String> permissionList)
    Plays a player-specific sound at a specified location with a permission list.
    void
    playPlayerSound(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, List<String> permissionList, float volume, float pitch)
    Plays a player-specific sound at a specified location with additional parameters.
    void
    playWorldSound(String string, org.bukkit.entity.Player player)
    Plays a world sound at the player's location.
    void
    playWorldSound(String string, org.bukkit.entity.Player player, Grave grave)
    Plays a world sound at the player's location, associated with a grave.
    void
    playWorldSound(String string, org.bukkit.Location location, Grave grave)
    Plays a world sound at a specified location, associated with a grave.
    void
    playWorldSound(String string, org.bukkit.Location location, org.bukkit.entity.EntityType entityType, List<String> permissionList, float volume, float pitch)
    Plays a world sound at a specified location with additional parameters.
    void
    Removes all entities associated with a grave.
    void
    removeEntity(Map<EntityData,org.bukkit.entity.Entity> entityDataMap)
    Removes a map of entity data and their associated entities.
    void
    runCommands(String string, String name, org.bukkit.Location location, Grave grave)
    Runs commands associated with a name, location, and grave.
    private void
    runCommands(String string, org.bukkit.entity.Entity entity, String name, org.bukkit.Location location, Grave grave)
     
    void
    runCommands(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave)
    Runs commands associated with an entity, location, and grave.
    private void
     
    boolean
    runFunction(org.bukkit.entity.Entity entity, String function)
    Runs a function associated with an entity and a specified function name.
    boolean
    runFunction(org.bukkit.entity.Entity entity, String function, Grave grave)
    Runs a function associated with an entity, a specified function name, and a grave.
    void
    sendMessage(String string, org.bukkit.command.CommandSender commandSender)
    Sends a message to a command sender.
    void
    sendMessage(String string, org.bukkit.entity.Entity entity)
    Sends a message to an entity.
    private void
    sendMessage(String string, org.bukkit.entity.Entity entity, String name, org.bukkit.Location location, Grave grave, List<String> permissionList)
     
    void
    sendMessage(String string, org.bukkit.entity.Entity entity, String name, org.bukkit.Location location, List<String> permissionList)
    Sends a message to an entity with a custom name and a permission list.
    void
    sendMessage(String string, org.bukkit.entity.Entity entity, List<String> permissionList)
    Sends a message to an entity with a permission list.
    void
    sendMessage(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave)
    Sends a message to an entity at a specified location associated with a grave.
    private void
    sendMessage(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave, List<String> permissionList)
     
    void
    sendMessage(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, List<String> permissionList)
    Sends a message to an entity at a specified location with a permission list.
    void
    setDataByte(org.bukkit.entity.Entity entity, String key)
    Sets a persistent data byte for the specified entity with the given key.
    void
    setDataString(org.bukkit.entity.Entity entity, String key, String string)
    Sets a persistent data string for the specified entity with the given key.
    void
    spawnZombie(org.bukkit.Location location, Grave grave)
    Spawns a zombie at a specified location, associated with a grave.
    void
    spawnZombie(org.bukkit.Location location, org.bukkit.entity.Entity entity, org.bukkit.entity.LivingEntity targetEntity, Grave grave)
    Spawns a zombie at a specified location, targeting a specified entity, and associated with a grave.
    private void
    spawnZombie(org.bukkit.Location location, org.bukkit.entity.LivingEntity targetEntity, Grave grave)
     
    void
    swingMainHand(org.bukkit.entity.Player player)
    Swings the main hand of the specified player.
    void
    teleportEntity(org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • plugin

      private final Graves plugin
      The main plugin instance associated with Graves.

      This Graves instance represents the core plugin that this Graves is part of. It provides access to the plugin's functionality, configuration, and other services.

  • Constructor Details

    • EntityManager

      public EntityManager(Graves plugin)
      Initializes the EntityManager with the specified plugin instance.
      Parameters:
      plugin - the Graves plugin instance.
  • Method Details

    • swingMainHand

      public void swingMainHand(org.bukkit.entity.Player player)
      Swings the main hand of the specified player.
      Parameters:
      player - the player whose main hand to swing.
    • createGraveCompass

      public org.bukkit.inventory.ItemStack createGraveCompass(org.bukkit.entity.Player player, org.bukkit.Location location, Grave grave)
      Creates a grave compass for the specified player, location, and grave.
      Parameters:
      player - the player for whom the compass is created.
      location - the location to set on the compass.
      grave - the grave associated with the compass.
      Returns:
      the created compass item stack.
    • getCompassesFromInventory

      public Map<org.bukkit.inventory.ItemStack,UUID> getCompassesFromInventory(org.bukkit.entity.HumanEntity player)
      Retrieves a map of compasses and their associated UUIDs from a player's inventory.
      Parameters:
      player - the player whose inventory to check.
      Returns:
      a map of compasses and their associated UUIDs.
    • getGraveUUIDFromItemStack

      public UUID getGraveUUIDFromItemStack(org.bukkit.inventory.ItemStack itemStack)
      Retrieves the grave UUID from an item stack.
      Parameters:
      itemStack - the item stack to check.
      Returns:
      the grave UUID, or null if not found.
    • teleportEntity

      public void teleportEntity(org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave)
    • getTeleportCost

      public double getTeleportCost(org.bukkit.Location location1, org.bukkit.Location location2, Grave grave)
      Calculates the cost of teleportation between two locations.
      Parameters:
      location1 - the starting location.
      location2 - the destination location.
      grave - the grave associated with the teleportation.
      Returns:
      the teleportation cost.
    • playWorldSound

      public void playWorldSound(String string, org.bukkit.entity.Player player)
      Plays a world sound at the player's location.
      Parameters:
      string - the sound identifier.
      player - the player whose location to play the sound at.
    • playWorldSound

      public void playWorldSound(String string, org.bukkit.entity.Player player, Grave grave)
      Plays a world sound at the player's location, associated with a grave.
      Parameters:
      string - the sound identifier.
      player - the player whose location to play the sound at.
      grave - the grave associated with the sound.
    • playWorldSound

      public void playWorldSound(String string, org.bukkit.Location location, Grave grave)
      Plays a world sound at a specified location, associated with a grave.
      Parameters:
      string - the sound identifier.
      location - the location to play the sound at.
      grave - the grave associated with the sound.
    • playWorldSound

      public void playWorldSound(String string, org.bukkit.Location location, org.bukkit.entity.EntityType entityType, List<String> permissionList, float volume, float pitch)
      Plays a world sound at a specified location with additional parameters.
      Parameters:
      string - the sound identifier.
      location - the location to play the sound at.
      entityType - the type of entity associated with the sound.
      permissionList - the list of permissions associated with the sound.
      volume - the volume of the sound.
      pitch - the pitch of the sound.
    • playPlayerSound

      public void playPlayerSound(String string, org.bukkit.entity.Entity entity, Grave grave)
      Plays a player-specific sound at the entity's location.
      Parameters:
      string - the sound identifier.
      entity - the entity to play the sound for.
      grave - the grave associated with the sound.
    • playPlayerSound

      public void playPlayerSound(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave)
      Plays a player-specific sound at a specified location for an entity.
      Parameters:
      string - the sound identifier.
      entity - the entity to play the sound for.
      location - the location to play the sound at.
      grave - the grave associated with the sound.
    • playPlayerSound

      public void playPlayerSound(String string, org.bukkit.entity.Entity entity, List<String> permissionList)
      Plays a player-specific sound at the entity's location with a permission list.
      Parameters:
      string - the sound identifier.
      entity - the entity to play the sound for.
      permissionList - the list of permissions associated with the sound.
    • playPlayerSound

      public void playPlayerSound(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, List<String> permissionList)
      Plays a player-specific sound at a specified location with a permission list.
      Parameters:
      string - the sound identifier.
      entity - the entity to play the sound for.
      location - the location to play the sound at.
      permissionList - the list of permissions associated with the sound.
    • playPlayerSound

      public void playPlayerSound(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, List<String> permissionList, float volume, float pitch)
      Plays a player-specific sound at a specified location with additional parameters.
      Parameters:
      string - the sound identifier.
      entity - the entity to play the sound for.
      location - the location to play the sound at.
      permissionList - the list of permissions associated with the sound.
      volume - the volume of the sound.
      pitch - the pitch of the sound.
    • sendMessage

      public void sendMessage(String string, org.bukkit.command.CommandSender commandSender)
      Sends a message to a command sender.
      Parameters:
      string - the message identifier.
      commandSender - the command sender to send the message to.
    • sendMessage

      public void sendMessage(String string, org.bukkit.entity.Entity entity)
      Sends a message to an entity.
      Parameters:
      string - the message identifier.
      entity - the entity to send the message to.
    • sendMessage

      public void sendMessage(String string, org.bukkit.entity.Entity entity, List<String> permissionList)
      Sends a message to an entity with a permission list.
      Parameters:
      string - the message identifier.
      entity - the entity to send the message to.
      permissionList - the list of permissions associated with the message.
    • sendMessage

      public void sendMessage(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, List<String> permissionList)
      Sends a message to an entity at a specified location with a permission list.
      Parameters:
      string - the message identifier.
      entity - the entity to send the message to.
      location - the location associated with the message.
      permissionList - the list of permissions associated with the message.
    • sendMessage

      public void sendMessage(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave)
      Sends a message to an entity at a specified location associated with a grave.
      Parameters:
      string - the message identifier.
      entity - the entity to send the message to.
      location - the location associated with the message.
      grave - the grave associated with the message.
    • sendMessage

      public void sendMessage(String string, org.bukkit.entity.Entity entity, String name, org.bukkit.Location location, List<String> permissionList)
      Sends a message to an entity with a custom name and a permission list.
      Parameters:
      string - the message identifier.
      entity - the entity to send the message to.
      name - the custom name associated with the message.
      location - the location associated with the message.
      permissionList - the list of permissions associated with the message.
    • sendMessage

      private void sendMessage(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave, List<String> permissionList)
    • sendMessage

      private void sendMessage(String string, org.bukkit.entity.Entity entity, String name, org.bukkit.Location location, Grave grave, List<String> permissionList)
    • runCommands

      public void runCommands(String string, org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave)
      Runs commands associated with an entity, location, and grave.
      Parameters:
      string - the command identifier.
      entity - the entity associated with the command.
      location - the location associated with the command.
      grave - the grave associated with the command.
    • runCommands

      public void runCommands(String string, String name, org.bukkit.Location location, Grave grave)
      Runs commands associated with a name, location, and grave.
      Parameters:
      string - the command identifier.
      name - the name associated with the command.
      location - the location associated with the command.
      grave - the grave associated with the command.
    • runCommands

      private void runCommands(String string, org.bukkit.entity.Entity entity, String name, org.bukkit.Location location, Grave grave)
    • runConsoleCommand

      private void runConsoleCommand(String string)
    • runFunction

      public boolean runFunction(org.bukkit.entity.Entity entity, String function)
      Runs a function associated with an entity and a specified function name.
      Parameters:
      entity - the entity to run the function for.
      function - the name of the function to run.
      Returns:
      true if the function was run successfully, false otherwise.
    • runFunction

      public boolean runFunction(org.bukkit.entity.Entity entity, String function, Grave grave)
      Runs a function associated with an entity, a specified function name, and a grave.
      Parameters:
      entity - the entity to run the function for.
      function - the name of the function to run.
      grave - the grave associated with the function.
      Returns:
      true if the function was run successfully, false otherwise.
    • canOpenGrave

      public boolean canOpenGrave(org.bukkit.entity.Player player, Grave grave)
      Checks if a player can open a specified grave. Supports both Java and Bedrock players (via Geyser/Floodgate).
      Parameters:
      player - the player attempting to open the grave
      grave - the grave to check
      Returns:
      true if the player can open the grave, false otherwise
    • spawnZombie

      public void spawnZombie(org.bukkit.Location location, org.bukkit.entity.Entity entity, org.bukkit.entity.LivingEntity targetEntity, Grave grave)
      Spawns a zombie at a specified location, targeting a specified entity, and associated with a grave.
      Parameters:
      location - the location to spawn the zombie.
      entity - the entity associated with the zombie spawn.
      targetEntity - the entity to be targeted by the zombie.
      grave - the grave associated with the zombie spawn.
    • spawnZombie

      public void spawnZombie(org.bukkit.Location location, Grave grave)
      Spawns a zombie at a specified location, associated with a grave.
      Parameters:
      location - the location to spawn the zombie.
      grave - the grave associated with the zombie spawn.
    • spawnZombie

      private void spawnZombie(org.bukkit.Location location, org.bukkit.entity.LivingEntity targetEntity, Grave grave)
    • createArmorStand

      public void createArmorStand(org.bukkit.Location location, Grave grave)
      Creates an armor stand at a specified location associated with a grave.
      Parameters:
      location - the location to create the armor stand.
      grave - the grave associated with the armor stand.
    • createItemFrame

      public void createItemFrame(org.bukkit.Location location, Grave grave)
      Creates an item frame at a specified location associated with a grave.
      Parameters:
      location - the location to create the item frame.
      grave - the grave associated with the item frame.
    • removeEntity

      public void removeEntity(Grave grave)
      Removes all entities associated with a grave.
      Parameters:
      grave - the grave whose entities to remove.
    • removeEntity

      public void removeEntity(Map<EntityData,org.bukkit.entity.Entity> entityDataMap)
      Removes a map of entity data and their associated entities.
      Parameters:
      entityDataMap - the map of entity data and entities to remove.
    • getEquipmentMap

      public Map<org.bukkit.inventory.EquipmentSlot,org.bukkit.inventory.ItemStack> getEquipmentMap(org.bukkit.entity.LivingEntity livingEntity, Grave grave)
      Retrieves a map of equipment slots and their corresponding item stacks for a living entity and grave.
      Parameters:
      livingEntity - the living entity to retrieve the equipment for.
      grave - the grave associated with the equipment.
      Returns:
      a map of equipment slots and their corresponding item stacks.
    • getEntityName

      public String getEntityName(org.bukkit.entity.Entity entity)
      Returns the name of the specified entity.

      This method handles different types of entities, including players and other entities, with legacy support for older versions of Minecraft.

      Parameters:
      entity - the Entity whose name is to be retrieved
      Returns:
      the name of the entity, or "null" if the entity is null
    • hasDataString

      public boolean hasDataString(org.bukkit.entity.Entity entity, String string)
      Checks if the specified entity has a persistent data string with the given key.

      The method checks for persistent data if supported; otherwise, it checks for metadata.

      Parameters:
      entity - the Entity to check
      string - the key of the persistent data or metadata
      Returns:
      true if the entity has the specified data string; false otherwise
    • hasDataByte

      public boolean hasDataByte(org.bukkit.entity.Entity entity, String string)
      Checks if the specified entity has a persistent data byte with the given key.

      The method checks for persistent data if supported; otherwise, it checks for metadata.

      Parameters:
      entity - the Entity to check
      string - the key of the persistent data or metadata
      Returns:
      true if the entity has the specified data byte; false otherwise
    • getDataString

      public String getDataString(org.bukkit.entity.Entity entity, String key)
      Retrieves the persistent data string associated with the given key from the specified entity.

      If persistent data is supported, it retrieves the string from the persistent data container; otherwise, it retrieves it from metadata.

      Parameters:
      entity - the Entity to retrieve data from
      key - the key of the persistent data or metadata
      Returns:
      the data string associated with the key, or null if not found
    • setDataString

      public void setDataString(org.bukkit.entity.Entity entity, String key, String string)
      Sets a persistent data string for the specified entity with the given key.

      If persistent data is supported, it sets the string in the persistent data container; otherwise, it sets it in metadata.

      Parameters:
      entity - the Entity to set data for
      key - the key of the persistent data or metadata
      string - the data string to set
    • setDataByte

      public void setDataByte(org.bukkit.entity.Entity entity, String key)
      Sets a persistent data byte for the specified entity with the given key.

      If persistent data is supported, it sets the byte in the persistent data container; otherwise, it sets it in metadata.

      Parameters:
      entity - the Entity to set data for
      key - the key of the persistent data or metadata
    • getGraveFromEntityData

      public Grave getGraveFromEntityData(org.bukkit.entity.Entity entity)
      Retrieves a Grave object from the persistent data or metadata of the specified entity.

      The method checks if persistent data is supported and looks for a "graveUUID" key. If not found, it checks for metadata.

      Parameters:
      entity - the Entity from which to retrieve the grave
      Returns:
      the Grave associated with the entity, or null if not found