[Feature] Enum of item/block data

Discussion in 'Bukkit Discussion' started by Smerfa, Jun 21, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Smerfa

    Because all ID's and data like 35:15 (black wool) is deprecated.
    Using Material class is ok... no ID needed, but there is bigger problem with data, each block/item has own class with possible data, so if you want create command that change or give item you must create code for every type of item - and plugin will break after update because it will not support new blocks/items.

    So my idea is add one enum of possible data, and add method to Block class to use/set/get them.
    Code:
    public enum DataType
    {
        OAK,
        SPRUCE,
        ...
        RED,
        GREEN,
        ...;
     
    }
    And "QAK" can be use for normal wood and logs.
    "RED" and other colors can be used to WOOL, grass, clay
    And this same with other types.

    That will be very useful change, because instead of creating super long code for every type like WOOL, LOG, GLASS
    You can just use:
    Code:
    String materialName = ... // player input
    String dataName = ... // player input
    new ItemStack(Material.valueOf(materialName), DataType.valueOf(dataName), 1)
    Code:
    boolean result = block.setData(DataType.OAK) // returns false if that data can't be used here
    
    Methods should throws exceptions or just return boolean - true if that data can be used here.

    That will be much easier to create any commands or configurations.
    block/item data is only reason why I still must use ID (and maybe second - I don't remember any names but near every ID)
     
  2. Offline

    xTigerRebornx

    Smerfa Look at MaterialData and its sub-classes, they work fine.
     
  3. Offline

    Smerfa

    ... setData is also deprecated, and i wrote about subclasses, you must create code for every block... for every possible sub class of MaterialData.
    And stupid /give command from 10 lines is going to 200/300 of super useless code that is even more useless after every update that adding new block - your command can't give that block, you must update it...
    Class like that will solve all problems - you can easy get all data by name without knowing type of block/item.

     
  4. Offline

    mazentheamazin

    Smerfa
    I would recommend waiting until 1.8 comes out, as there will be a new block data system which will be compatible with 1.8.
     
Thread Status:
Not open for further replies.

Share This Page