Package games.stendhal.server.util
Class EntityHelper
java.lang.Object
games.stendhal.server.util.EntityHelper
Utilities to handle entities in the server.
- Author:
- Martin Fuchs
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Entity
entityFromSlot(Player player, RPAction action)
Retrieves a specified item from a slot.static Entity
entityFromTargetName(String target, Entity player)
Translate the "target" parameter of actions like "look" into an entity reference.static Entity
entityFromTargetNameAnyZone(String target, Entity player)
Translate the "target" parameter of actions like "look" into an entity reference.static Entity
entityFromZoneByID(int objectId, StendhalRPZone zone)
Returns an entity reference by an objectId in a zone.static Entity
getEntityByName(Player player, String itemName)
gets an entity by name from the players bagstatic Entity
getEntityFromPath(Player player, List<String> path)
Get an entity from path.static EntitySlot
gets the item slot from an action
-
Constructor Details
-
EntityHelper
public EntityHelper()
-
-
Method Details
-
entityFromZoneByID
Returns an entity reference by an objectId in a zone.- Parameters:
objectId
- objectId of this Entityzone
- zone- Returns:
- Entity or
null
-
entityFromTargetName
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 targetplayer
- 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 wasnull
.
-
entityFromTargetNameAnyZone
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 targetplayer
- 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 wasnull
.
-
entityFromSlot
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 itemaction
- the action specifying for what to search- Returns:
- the found Entity or null
-
getSlot
gets the item slot from an action- Parameters:
player
- Player executing the actionaction
- action- Returns:
- EntitySlot or
null
if the action was invalid
-
getEntityFromPath
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
gets an entity by name from the players bag- Parameters:
player
- PlayeritemName
- entity name- Returns:
- Entity or
null
-