Package net.risingworld.api.objects
Class Clothes
java.lang.Object
net.risingworld.api.objects.Clothes
An object representing the current clothes of players and certain npcs.
This object contains all individual garments the player/npc is currently wearing.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Represents a single piece of clothing. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(short clothingID) Adds a new garment with the provided type ID.void
add
(short clothingID, int color, long infoID) boolean
deserialize
(byte[] bytes) Deserializes a byte array and applies all information stored in it to this Clothes object.get
(Clothing.Type type) Gets a garment the player/npc is wearing (depending on the provided type).getAll()
Gets all garments the player/npc is currently wearing.boolean
has
(short clothingID) Checks if the character is wearing a particular garment.boolean
hasSpecialGear
(Clothing.Function clothingFunction) Checks if the character is wearing any garment with a special function.boolean
hasType
(Clothing.Type type) boolean
isNpc()
Gets whether this clothes object belongs to an npc or to a player.boolean
remove
(short clothingID) boolean
remove
(Clothing.Type type) void
byte[]
Serializes the clothes, i.e turns all information into a byte array.
-
Constructor Details
-
Clothes
protected Clothes(long handle, boolean isNpc)
-
-
Method Details
-
isNpc
public boolean isNpc()Gets whether this clothes object belongs to an npc or to a player.- Returns:
- true if this is represents the clothes of an npc, false if it represents the clothes of a player.
-
add
public void add(short clothingID) Adds a new garment with the provided type ID.- Parameters:
clothingID
- the type ID of the garment.- Example: Give player a helmet
-
add
public void add(short clothingID, int color, long infoID) -
get
Gets a garment the player/npc is wearing (depending on the provided type).- Parameters:
type
- the clothing type (i.e which body areas are covered by this garment).- Returns:
- a new Garment object representing the clothing piece, or null if nothing was found.
-
getAll
Gets all garments the player/npc is currently wearing.- Returns:
- a new array containing all garments, or null if the player/npc is naked.
-
remove
public boolean remove(short clothingID) -
remove
-
removeAll
public void removeAll() -
has
public boolean has(short clothingID) Checks if the character is wearing a particular garment.- Parameters:
clothingID
- the clothing type id of the garment you're looking for.- Returns:
- true if the character is wearing such a garment, false if not.
- Example: Check if npc is wearing a horse saddle
-
hasType
-
hasSpecialGear
Checks if the character is wearing any garment with a special function.- Parameters:
clothingFunction
- the special function of the garment you're looking for.- Returns:
- true if any of the garments has such a function, false if not.
- Example: Check if player is wearing a lamp garment, e.g headlamp
-
serialize
public byte[] serialize()Serializes the clothes, i.e turns all information into a byte array.- Returns:
- a byte array representing the Clothes object.
- Example: Serialize and deserialize a clothes object
- See Also:
-
deserialize
public boolean deserialize(byte[] bytes) Deserializes a byte array and applies all information stored in it to this Clothes object. Can be used in combination withserialize()
.- Parameters:
bytes
- the byte array representing the Clothes object.- Returns:
- true if the byte array was valid, i.e if it was successfully applied to this Clothes object, false if not.
-