Solved Converting item id to material enum

Discussion in 'Plugin Development' started by Pawnguy7, Jun 20, 2013.

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

    Pawnguy7

    Greetings. I was making a basic thing that loads item ids from a config, and would "equip" a player with the items. Anyway, loading the ids worked - checked before and after parsing to an int - and the equip part works as well (giving the items.). The only part left is the int to enum conversion. After a quick google, I found a method of using <EnumName>.values()[index]. In my case, it is Material.values()[itemId], where itemId is the parsed integer.

    The problem? Well... the items aren't quite correct. For example, 283 (gold sword) turns to 380, cauldron. Or the respective parts of gold armor turned into four music discs.

    I feel the problem is simple, but I don't know the correct method of doing this. Ideas?
     
  2. Offline

    Tzeentchful

  3. Offline

    skore87

    Material.getMaterial(int id)
     
  4. Offline

    Pawnguy7

    Thanks, works as expected now. Sadly, I actually did look at the javadoc (I saw another thread which engineered a getById method, so I was looking to see if this had one). I have no idea how I missed it. Quite sorry.
     
Thread Status:
Not open for further replies.

Share This Page