Advertisement
Guest User

Bone008 NBT API

a guest
Aug 14th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.45 KB | None | 0 0
  1. package bone008.<censored>.shared.util.nbt;
  2.  
  3. import java.util.List;
  4.  
  5. public interface Compound {
  6.    
  7.     /**
  8.      * Checks if this compound has the given key set.
  9.      *
  10.      * @param name the name of the key
  11.      * @return true if the key exists, otherwise false
  12.      */
  13.     public boolean hasKey(String name);
  14.    
  15.     /**
  16.      * Removes a key and its value from this compound.
  17.      *
  18.      * @param name the name of the key
  19.      */
  20.     public void remove(String name);
  21.    
  22.     /**
  23.      * Sets a key in this compound to a value. The name of the compound is used as the name of the key.
  24.      *
  25.      * @param value the value to set
  26.      */
  27.     public void setCompound(Compound value);
  28.    
  29.     /**
  30.      * Returns the value of a key in this compound.<br>
  31.      * If the key is not set, a default value is returned (in this case an empty compound).<br>
  32.      * If the key has an incompatible data type, a {@link NBTException} is thrown.
  33.      *
  34.      * @param name the name of the key
  35.      * @return the associated value, or a default value
  36.      * @throws NBTException if the key has an invalid data type
  37.      */
  38.     public Compound getCompound(String name) throws NBTException;
  39.    
  40.     /**
  41.      * Sets a key in this compound to a value.
  42.      *
  43.      * @param name the name of the key
  44.      * @param value the value to set
  45.      */
  46.     public void setByte(String name, byte value);
  47.    
  48.     /**
  49.      * Returns the value of a key in this compound.<br>
  50.      * If the key is not set, a default value is returned.<br>
  51.      * If the key has an incompatible data type, a {@link NBTException} is thrown.
  52.      *
  53.      * @param name the name of the key
  54.      * @return the associated value, or a default value
  55.      * @throws NBTException if the key has an invalid data type
  56.      */
  57.     public byte getByte(String name) throws NBTException;
  58.    
  59.     /**
  60.      * Sets a key in this compound to a value.
  61.      *
  62.      * @param name the name of the key
  63.      * @param value the value to set
  64.      */
  65.     public void setShort(String name, short value);
  66.    
  67.     /**
  68.      * Returns the value of a key in this compound.<br>
  69.      * If the key is not set, a default value is returned.<br>
  70.      * If the key has an incompatible data type, a {@link NBTException} is thrown.
  71.      *
  72.      * @param name the name of the key
  73.      * @return the associated value, or a default value
  74.      * @throws NBTException if the key has an invalid data type
  75.      */
  76.     public short getShort(String name) throws NBTException;
  77.    
  78.     /**
  79.      * Sets a key in this compound to a value.
  80.      *
  81.      * @param name the name of the key
  82.      * @param value the value to set
  83.      */
  84.     public void setInt(String name, int value);
  85.    
  86.     /**
  87.      * Returns the value of a key in this compound.<br>
  88.      * If the key is not set, a default value is returned.<br>
  89.      * If the key has an incompatible data type, a {@link NBTException} is thrown.
  90.      *
  91.      * @param name the name of the key
  92.      * @return the associated value, or a default value
  93.      * @throws NBTException if the key has an invalid data type
  94.      */
  95.     public int getInt(String name) throws NBTException;
  96.    
  97.     /**
  98.      * Sets a key in this compound to a value.
  99.      *
  100.      * @param name the name of the key
  101.      * @param value the value to set
  102.      */
  103.     public void setLong(String name, long value);
  104.    
  105.     /**
  106.      * Returns the value of a key in this compound.<br>
  107.      * If the key is not set, a default value is returned.<br>
  108.      * If the key has an incompatible data type, a {@link NBTException} is thrown.
  109.      *
  110.      * @param name the name of the key
  111.      * @return the associated value, or a default value
  112.      * @throws NBTException if the key has an invalid data type
  113.      */
  114.     public long getLong(String name) throws NBTException;
  115.    
  116.     /**
  117.      * Sets a key in this compound to a value.
  118.      *
  119.      * @param name the name of the key
  120.      * @param value the value to set
  121.      */
  122.     public void setFloat(String name, float value);
  123.    
  124.     /**
  125.      * Returns the value of a key in this compound.<br>
  126.      * If the key is not set, a default value is returned.<br>
  127.      * If the key has an incompatible data type, a {@link NBTException} is thrown.
  128.      *
  129.      * @param name the name of the key
  130.      * @return the associated value, or a default value
  131.      * @throws NBTException if the key has an invalid data type
  132.      */
  133.     public float getFloat(String name) throws NBTException;
  134.    
  135.     /**
  136.      * Sets a key in this compound to a value.
  137.      *
  138.      * @param name the name of the key
  139.      * @param value the value to set
  140.      */
  141.     public void setDouble(String name, double value);
  142.    
  143.     /**
  144.      * Returns the value of a key in this compound.<br>
  145.      * If the key is not set, a default value is returned.<br>
  146.      * If the key has an incompatible data type, a {@link NBTException} is thrown.
  147.      *
  148.      * @param name the name of the key
  149.      * @return the associated value, or a default value
  150.      * @throws NBTException if the key has an invalid data type
  151.      */
  152.     public double getDouble(String name) throws NBTException;
  153.    
  154.     /**
  155.      * Sets a key in this compound to a value.
  156.      *
  157.      * @param name the name of the key
  158.      * @param value the value to set
  159.      */
  160.     public void setString(String name, String value);
  161.    
  162.     /**
  163.      * Returns the value of a key in this compound.<br>
  164.      * If the key is not set, a default value is returned.<br>
  165.      * If the key has an incompatible data type, a {@link NBTException} is thrown.
  166.      *
  167.      * @param name the name of the key
  168.      * @return the associated value, or a default value
  169.      * @throws NBTException if the key has an invalid data type
  170.      */
  171.     public String getString(String name) throws NBTException;
  172.    
  173.     /**
  174.      * Sets a key in this compound to a value.
  175.      *
  176.      * @param name the name of the key
  177.      * @param value the value to set
  178.      */
  179.     public void setByteArray(String name, byte[] value);
  180.    
  181.     /**
  182.      * Returns the value of a key in this compound.<br>
  183.      * If the key is not set, a default value is returned (in this case an array with length 0).<br>
  184.      * If the key has an incompatible data type, a {@link NBTException} is thrown.
  185.      *
  186.      * @param name the name of the key
  187.      * @return the associated value, or a default value
  188.      * @throws NBTException if the key has an invalid data type
  189.      */
  190.     public byte[] getByteArray(String name) throws NBTException;
  191.    
  192.     /**
  193.      * Sets a key in this compound to a value.
  194.      *
  195.      * @param name the name of the key
  196.      * @param value the value to set
  197.      */
  198.     public void setIntArray(String name, int[] value);
  199.    
  200.     /**
  201.      * Returns the value of a key in this compound.<br>
  202.      * If the key is not set, a default value is returned (in this case an array with length 0).<br>
  203.      * If the key has an incompatible data type, a {@link NBTException} is thrown.
  204.      *
  205.      * @param name the name of the key
  206.      * @return the associated value, or a default value
  207.      * @throws NBTException if the key has an invalid data type
  208.      */
  209.     public int[] getIntArray(String name) throws NBTException;
  210.    
  211.     /**
  212.      * Sets a key in this component to a list value.<br>
  213.      * The list can contain any supported data type, including byte and int arrays, compounds and other lists, but all entries must have the same type.
  214.      *
  215.      * @param name the name of the key
  216.      * @param value the value to set
  217.      */
  218.     public <T> void setList(String name, List<T> value);
  219.    
  220.     /**
  221.      * Returns the value of a key in this compound as a list. A parameter indicating the content type of the list must be given.
  222.      *
  223.      * @param name the name of the key
  224.      * @param entryType the type of entries that are expected in this list
  225.      * @return the associated value, or an empty list if not set
  226.      * @throws NBTException if the key is not a list, or the list's type does not match the expected <tt>entryType</tt>
  227.      */
  228.     public <T> List<T> getList(String name, Class<T> entryType) throws NBTException;
  229.    
  230. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement