Class EntityHelper

java.lang.Object
games.stendhal.server.util.EntityHelper

public class EntityHelper extends Object
Utilities to handle entities in the server.
Author:
Martin Fuchs
  • Constructor Details

    • EntityHelper

      public EntityHelper()
  • Method Details

    • entityFromZoneByID

      public static Entity entityFromZoneByID(int objectId, StendhalRPZone zone)
      Returns an entity reference by an objectId in a zone.
      Parameters:
      objectId - objectId of this Entity
      zone - zone
      Returns:
      Entity or null
    • entityFromTargetName

      public static Entity entityFromTargetName(String target, Entity player)
      Translate the "target" parameter of actions like "look" into an entity reference. Numeric parameters are treated as object IDs, alphanumeric names are searched in the list of players and NPCs.
      Parameters:
      target - representation of the target
      player - to constraint for current zone and screen area
      Returns:
      the entity associated either with name or id or null if none was found or any of the input parameters was null .
    • entityFromTargetNameAnyZone

      public static Entity entityFromTargetNameAnyZone(String target, Entity player)
      Translate the "target" parameter of actions like "look" into an entity reference. Numeric parameters are treated as object IDs, alphanumeric names are searched in the list of players and NPCs.
      Parameters:
      target - representation of the target
      player - to constraint for current zone and screen area
      Returns:
      the entity associated either with name or id or null if none was found or any of the input parameters was null .
    • entityFromSlot

      public static Entity entityFromSlot(Player player, RPAction action)
      Retrieves a specified item from a slot. Necessary attributes in the RPAction: - baseslot name of the slot to search in - baseobject the id of the object where to search for the specified slot - baseitem the id of the object to search for
      Parameters:
      player - the player where to search for the item
      action - the action specifying for what to search
      Returns:
      the found Entity or null
    • getSlot

      public static EntitySlot getSlot(Player player, RPAction action)
      gets the item slot from an action
      Parameters:
      player - Player executing the action
      action - action
      Returns:
      EntitySlot or null if the action was invalid
    • getEntityFromPath

      public static Entity getEntityFromPath(Player player, List<String> path)
      Get an entity from path. Does not do any access checks.
      Parameters:
      player -
      path - entity path
      Returns:
      entity corresponding to the path, or null if none was found
    • getEntityByName

      public static Entity getEntityByName(Player player, String itemName)
      gets an entity by name from the players bag
      Parameters:
      player - Player
      itemName - entity name
      Returns:
      Entity or null