From short item name to ItemStack?

Discussion in 'Plugin Development' started by Acrobot, Feb 11, 2011.

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

    Acrobot

    Hello,

    how can I convert short item name (Like MOSSY_COBBLESTO) to MOSSY_COBBLESTONE?
    Is there any way to autocomplete the name?

    I've searched the forum, yet I didn't find anything like this...
     
  2. Offline

    eisental

    Code:
    for (Material m : Material.values()) {
       if (m.name().startsWith(partialName)) {
              // found your material
              ........
       }
    }
    
    //do something if we got until here without finding anything
    
     
  3. Offline

    NathanWolf

    Also, if you're interested (and don't mind me doing a bit of plugging here), I've going to have material, material variant, and material list data functions in the PluginUtilities class of my Persistence plugin. You'll be able to look up a material (or variant, such as "red wool") by name or id/data combination.

    All of the names are stored in sqllite, so you can even edit them- though they will be populated using the default Material.name() values, so by default it would work just as eisental describes above.

    I don't have this in yet, but I need it for Spells- which I'll be integrating with Persistence as soon as I can pull myself away from NetherGate for a little bit.
     
  4. Offline

    Acrobot

    Thank you :)
     
Thread Status:
Not open for further replies.

Share This Page