Class Clothes

java.lang.Object
net.risingworld.api.objects.Clothes

public final class Clothes extends Object
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

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Represents a single piece of clothing.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Clothes(long handle, boolean isNpc)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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.
    Gets a garment the player/npc is wearing (depending on the provided type).
    Gets all garments the player/npc is currently wearing.
    boolean
    has(short clothingID)
    Checks if the character is wearing a particular garment.
    boolean
    Checks if the character is wearing any garment with a special function.
    boolean
     
    boolean
    Gets whether this clothes object belongs to an npc or to a player.
    boolean
    remove(short clothingID)
     
    boolean
     
    void
     
    byte[]
    Serializes the clothes, i.e turns all information into a byte array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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
      1//Get definition of mining helmet
      2Clothing.ClothingDefinition def = Definitions.getClothingDefinition("mininghelmet");
      3
      4//Add helmet to player
      5player.getClothes().add(def.id);
    • add

      public void add(short clothingID, int color, long infoID)
    • get

      public Clothes.Garment get(Clothing.Type type)
      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

      public Clothes.Garment[] 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

      public boolean remove(Clothing.Type type)
    • 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
      1//Get saddle definition
      2Clothing.ClothingDefinition def = Definitions.getClothingDefinition("saddlehorse");
      3
      4//Get npc clothes
      5Clothes clothes = npc.getClothes();
      6
      7//Check if clothes contain saddle
      8if (clothes.has(def.id)) {
      9 System.out.println("Npc is wearing a saddle!");
      10}
    • hasType

      public boolean hasType(Clothing.Type type)
    • hasSpecialGear

      public boolean hasSpecialGear(Clothing.Function clothingFunction)
      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
      1//Get player clothes
      2Clothes clothes = player.getClothes();
      3
      4//Check if "Lamp" function is available
      5if (clothes.hasSpecialGear(Clothing.Function.Lamp)) {
      6 player.sendTextMessage("You're currently wearing a lamp item!");
      7}
    • 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
      1//Get clothes of player 1
      2Clothes clothes1 = player1.getClothes();
      3
      4//Serialize it
      5byte[] data = clothes1.serialize();
      6
      7//Get clothes of player 2
      8Clothes clothes2 = player2.getClothes();
      9
      10//Deserialize data (so clothes 2 will contain the same data as clothes 1)
      11clothes2.deserialize(data);
      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 with serialize().
      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.