Class Item
Object
Item
- All Implemented Interfaces:
Serializable,AttributeWrangler,DisplayInterface,ItemWrangler,Ownage
- Direct Known Subclasses:
NormalItem,ShopkeeperList
@Entity
public abstract class Item
extends Object
implements Serializable, DisplayInterface, AttributeWrangler, ItemWrangler, Ownage
An item. To be more precise an instance of an item definition. An item can
either reside in a room, on a person or in another item.
- Author:
- maartenl
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds anItemto the bag (container).voidvoidvoidclose()booleanTells you if this item contains other items, for example if it is a bag.booleandestroyItem(Item item) Physically destroys an item instance.voidvoidSpecialty method for the creation of new items in a room.Returns items this entity has, based on description provided.voidgetAttribute(String name) Retrieves an attribute, returns null if not found.Will return the person that owns this item.getBody()The body to be displayed on the screen.abstract ItemCategoryReturns the category of the item.Retrieves the item that contains this item (if possible).Description of the item, for example "a white, cloth pants".Provides the description of what happens when you try to drink it.Provides the description of what happens when you try to eat it.getId()getImage()Returns an url pointing to an image.getItems()Indicates the items that are contained (if possible) inside this item.The title as visible on the screen.getOwner()Retrieves the owner, the administrator, of this object.getRead()getRoom()Will return the room in which this item can be found.getTitle()voidbooleanhasLid()Returns true if the container has a lid, if the container can be opened.booleanhasLock()Returns whether or not the container has a lock.booleanisBound()Whether or not you are able to drop this item or give this item, or in some other way dispose of this item, besides selling it to a vendor or just destroying it.booleanItems are buyable by default, unless attribute "notbuyable" is set.booleanbooleanisDescribedBy(List<String> parsed) booleanReturns true if the item can be drunk.booleanWhether or not you are able to drop this item.booleanReturns true if the item can be eaten.booleanWhether or not you are able to retrieve this item from the floor of the room.booleanVerifies that the key provided can open this container.booleanisLocked()Returns whether or not the container is locked.booleanisOpen()Indicates if the container is open or closed.booleanReturns true if the container has a lid, if the container can be opened.booleanbooleanItems are sellable by default, unless attribute "notsellable" is set.booleanbooleanisWearable(Wearing position) booleanisWieldable(Wielding position) voidlock()voidopen()booleanremoveAttribute(String name) Removes an attribute by name.voidsetAttribute(String name, String value) Set the value of the attribute, creates the attribute if the attribute does not exist.voidsetContainer(Item container) voidsetCreation(LocalDateTime creation) voidvoidsetItemDefinition(ItemDefinition itemDefinition) voidvoidSets the owner, the administrator, of this object.toString()voidunlock()booleanverifyAttribute(String name, String value) Verify if the attribute exists, and has the proper value.
-
Constructor Details
-
Item
public Item()Constructor. Creates a completely empty item. Usually required by ORM. -
Item
Constructor.- Parameters:
id- the item definition used as a template of this (new) item.
-
-
Method Details
-
getDiscriminator
-
getId
-
setId
-
getCreation
-
setCreation
-
getItems
Indicates the items that are contained (if possible) inside this item. Will in most cases return an empty list.- Specified by:
getItemsin interfaceItemWrangler- Returns:
- set of items.
-
setItems
-
getContainer
Retrieves the item that contains this item (if possible). Might be null.- Returns:
- the container
- See Also:
-
isContainer
public boolean isContainer() -
setContainer
-
getItemDefinition
-
setItemDefinition
-
getOwner
-
setOwner
Description copied from interface:OwnageSets the owner, the administrator, of this object. -
getRoom
Will return the room in which this item can be found. Might be null.- Returns:
- the room which contains this item.
- See Also:
-
getBelongsTo
Will return the person that owns this item. Might be null.- Returns:
- the person who owns this item.
- See Also:
-
toString
-
getDescription
Description of the item, for example "a white, cloth pants".- Returns:
- a description of the item.
-
isDescribedBy
-
getTitle
- Throws:
MudException
-
getMainTitle
Description copied from interface:DisplayInterfaceThe title as visible on the screen.- Specified by:
getMainTitlein interfaceDisplayInterface- Returns:
- Throws:
MudException
-
getImage
Description copied from interface:DisplayInterfaceReturns an url pointing to an image.- Specified by:
getImagein interfaceDisplayInterface- Returns:
- Throws:
MudException
-
getLongDescription
-
getBody
Description copied from interface:DisplayInterfaceThe body to be displayed on the screen. In general the first letter of the body is converted to an image on the client side.- Specified by:
getBodyin interfaceDisplayInterface- Returns:
- Throws:
MudException
-
getCopper
-
removeAttribute
Description copied from interface:AttributeWranglerRemoves an attribute by name.- Specified by:
removeAttributein interfaceAttributeWrangler- Parameters:
name- the name of the attribute, for example "guildwish".- Returns:
- false if not found, true if removed.
-
getAttribute
Description copied from interface:AttributeWranglerRetrieves an attribute, returns null if not found.- Specified by:
getAttributein interfaceAttributeWrangler- Parameters:
name- the name of the attribute- Returns:
- an attribute
-
setAttribute
Description copied from interface:AttributeWranglerSet the value of the attribute, creates the attribute if the attribute does not exist.- Specified by:
setAttributein interfaceAttributeWrangler- Parameters:
name- the name of the attributevalue- the value of the attribute
-
verifyAttribute
Description copied from interface:AttributeWranglerVerify if the attribute exists, and has the proper value.- Specified by:
verifyAttributein interfaceAttributeWrangler- Parameters:
name- the name of the attributevalue- the value of the attribute- Returns:
- true if it exists, false otherwise.
-
isOpen
public boolean isOpen()Indicates if the container is open or closed. Only makes sense if this item is in fact a container.- Returns:
- true if there is an attribute named "isopen".
-
hasLid
public boolean hasLid()Returns true if the container has a lid, if the container can be opened.- Returns:
- boolean true if the container has a lid.
-
isOpenable
public boolean isOpenable()Returns true if the container has a lid, if the container can be opened.- Returns:
- boolean true if the container has a lid.
-
isLocked
public boolean isLocked()Returns whether or not the container is locked. If it can be locked, it needs a key.- Returns:
- boolean true if the container is locked.
- See Also:
-
open
public void open() -
close
public void close() -
isEatable
public boolean isEatable()Returns true if the item can be eaten. This is better than just using a compare on the getEatable.- Returns:
- true if eatable, false otherwise
- See Also:
-
getEatable
Provides the description of what happens when you try to eat it. Can be null or empty, for example if the item cannot be eaten. Eating an item will always destroy that item.- Returns:
-
findItems
Description copied from interface:ItemWranglerReturns items this entity has, based on description provided.- Specified by:
findItemsin interfaceItemWrangler- Parameters:
parsed- the parsed description of the item, for example {"light-green", "leather", "pants"}.- Returns:
- list of found items, empty if not found.
-
destroyItem
Description copied from interface:ItemWranglerPhysically destroys an item instance.- Specified by:
destroyItemin interfaceItemWrangler- Parameters:
item- the item to be destroyed- Returns:
- returns true, if the item was found and destroyed. False if the item was not found.
-
isDrinkable
public boolean isDrinkable()Returns true if the item can be drunk. This is better than just using a compare on the getDrinkable.- Returns:
- true if drinkable, false otherwise
- See Also:
-
getDrinkable
Provides the description of what happens when you try to drink it. Can be null or empty, for example if the item cannot be drunk. Drinking an item will always destroy that item.- Returns:
-
isWearable
-
isWieldable
-
isDroppable
public boolean isDroppable()Whether or not you are able to drop this item.- Returns:
- true, in case you can, false otherwise.
-
isBound
public boolean isBound()Whether or not you are able to drop this item or give this item, or in some other way dispose of this item, besides selling it to a vendor or just destroying it.- Returns:
- true, in case you cannot, false otherwise.
-
isGetable
public boolean isGetable()Whether or not you are able to retrieve this item from the floor of the room.- Returns:
- true, in case you can, false otherwise.
-
drop
-
drop
Specialty method for the creation of new items in a room. Only used byinvalid reference
Room#createItem(mmud.database.entities.items.ItemDefinition)- Parameters:
room- the room to drop the new item into.
-
get
-
give
-
isReadable
public boolean isReadable() -
getRead
-
hasLock
public boolean hasLock()Returns whether or not the container has a lock. Meaning whether or not the container can be unlocked/locked.- Returns:
- boolean true if the container can be locked/unlocked.
-
isKey
Verifies that the key provided can open this container.- Parameters:
key- the key to hopefully open this container.- Returns:
- true, if it is possible to open this container with the key provided.
-
lock
public void lock() -
unlock
public void unlock() -
isVisible
public boolean isVisible() -
getCategory
Returns the category of the item.- Returns:
- the category of the item.
-
isSellable
public boolean isSellable()Items are sellable by default, unless attribute "notsellable" is set.- Returns:
- can the item be sold.
- See Also:
-
isBuyable
public boolean isBuyable()Items are buyable by default, unless attribute "notbuyable" is set.- Returns:
- See Also:
-
containsItems
public boolean containsItems()Tells you if this item contains other items, for example if it is a bag.- Returns:
-
addItem
Adds anItemto the bag (container).- Specified by:
addItemin interfaceItemWrangler- Parameters:
item- the new item. May not be null.- Returns:
- the new item, null if unable to add.
-
assignTo
-
assignTo
-