Class StackableItem
java.lang.Object
marauroa.common.game.Attributes
marauroa.common.game.SlotOwner
marauroa.common.game.RPObject
games.stendhal.server.entity.Entity
games.stendhal.server.entity.PassiveEntity
games.stendhal.server.entity.item.Item
games.stendhal.server.entity.item.StackableItem
- All Implemented Interfaces:
EquipListener
,TurnListener
,UseListener
,Stackable<StackableItem>
,Killer
,Cloneable
,Iterable<String>
,Serializable
- Direct Known Subclasses:
ConsumableItem
,Money
,NoStatsStackableItem
,Scroll
,Seed
,TimedStackableItem
-
Nested Class Summary
Nested classes/interfaces inherited from class marauroa.common.game.RPObject
RPObject.ID
-
Field Summary
Fields inherited from class games.stendhal.server.entity.item.Item
DEGRADATION_TIMEOUT
Fields inherited from class marauroa.common.game.RPObject
INVALID_ID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
add(StackableItem other)
Adds the quantity of the other Stackable to this.int
gets the maximum amountint
Get item count.boolean
isStackable(StackableItem onTop)
checks if the other object can be stacked onto this onevoid
Removes the item.void
setCapacity(int capacity)
sets the maximum amountvoid
setQuantity(int amount)
sets the quantity.splitOff(int amountToSplitOff)
int
sub(int amount)
Reduces Item's amount by amount.void
update()
Methods inherited from class games.stendhal.server.entity.item.Item
autobind, canBeEquippedIn, describe, deteriorate, deteriorate, generateRPClass, getAttack, getAttackRate, getAttackRate, getBoundTo, getDamageType, getDefaultAttackRate, getDefense, getDescriptionName, getDeterioration, getInfoString, getItemClass, getItemSubclass, getMinLevel, getName, getPlantGrower, getPossibleSlots, getRangedAttack, getSusceptibility, getTitle, getWeaponType, initializeActiveSlotsList, initializeStatusResistancesList, isBound, isFromCorpse, isOfClass, isPersistent, isUndroppableOnDeath, onEquipped, onPickedUp, onPutOnGround, onPutOnGround, onRemoveFromGround, onTurnReached, onUnequipped, onUsed, removeFromWorld, repair, setBoundTo, setDamageType, setEquipableSlots, setFromCorpse, setInfoString, setPersistent, setPlantGrower, setSusceptibilities, setUndroppableOnDeath, setUseBehavior, toString
Methods inherited from class games.stendhal.server.entity.Entity
getAdjacentNodes, getArea, getArea, getCursor, getDescription, getEntitySlot, getHeight, getOrigin, getResistance, getResistance, getWidth, getX, getY, getZone, hasDescription, isInSight, isObstacle, nextTo, nextTo, notifyWorldAboutChanges, onAdded, onMoved, onRemoved, setCursor, setDescription, setEntityClass, setEntitySubclass, setMenu, setPosition, setResistance, setSize, setVisibility, slotIterator, slots, squaredDistance, squaredDistance, stopped
Methods inherited from class marauroa.common.game.RPObject
addEvent, addLink, addLink, addMap, addSlot, addSlot, applyDifferences, clearEvents, clearVisible, clone, containsKey, equals, events, eventsIterator, fill, get, getBaseContainer, getBoolean, getContainer, getContainerBaseOwner, getContainerOwner, getContainerSlot, getDifferences, getDouble, getFromSlots, getID, getInt, getLink, getLinkedObject, getMap, getSlot, has, hashCode, hasLink, hasMap, hasSlot, hide, isContained, isEmpty, isHidden, isStorable, maps, put, put, put, put, readObject, remove, removeLink, removeMap, removeSlot, resetAddedAndDeleted, resetAddedAndDeletedMaps, resetAddedAndDeletedRPLink, resetAddedAndDeletedRPSlot, setAddedMaps, setAddedRPSlot, setContainer, setDeletedMaps, setDeletedRPSlot, setID, size, slots, slotsIterator, store, unhide, unstore, writeObject, writeObject, writeToJson
Methods inherited from class marauroa.common.game.SlotOwner
deserializeRPSlots, fill, serializeRPSlots
Methods inherited from class marauroa.common.game.Attributes
add, applyDifferences, get, getBool, getDouble, getInt, getList, getLong, getRPClass, has, instanceOf, iterator, put, put, put, put, put, readFromMap, remove, resetAddedAndDeletedAttributes, setAddedAttributes, setDeletedAttributes, setRPClass, setRPClass, toAttributeString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
StackableItem
-
StackableItem
Copy constructor.- Parameters:
item
- item to copy
-
-
Method Details
-
update
public void update() -
getQuantity
public int getQuantity()Description copied from class:Item
Get item count.- Specified by:
getQuantity
in interfaceStackable<StackableItem>
- Overrides:
getQuantity
in classItem
- Returns:
- 1.
-
setQuantity
public void setQuantity(int amount)Description copied from interface:Stackable
sets the quantity.- Specified by:
setQuantity
in interfaceStackable<StackableItem>
- Parameters:
amount
- to be set
-
sub
public int sub(int amount)Reduces Item's amount by amount.- Parameters:
amount
- of reduction, negative numbers will be ignored.- Returns:
- remaining amount
-
add
Description copied from interface:Stackable
Adds the quantity of the other Stackable to this.- Specified by:
add
in interfaceStackable<StackableItem>
- Parameters:
other
- other object to merge in- Returns:
- the previous quantity
-
splitOff
-
removeOne
public void removeOne()Description copied from class:Item
Removes the item. In case of StackableItems only one is removed. -
isStackable
Description copied from interface:Stackable
checks if the other object can be stacked onto this one- Specified by:
isStackable
in interfaceStackable<StackableItem>
- Parameters:
onTop
- other object- Returns:
- true when both stackables are of the same type and can be merged
-
getCapacity
public int getCapacity()Description copied from interface:Stackable
gets the maximum amount- Specified by:
getCapacity
in interfaceStackable<StackableItem>
- Returns:
- the maximum amount
-
setCapacity
public void setCapacity(int capacity)Description copied from interface:Stackable
sets the maximum amount- Specified by:
setCapacity
in interfaceStackable<StackableItem>
-