Translating item names.

Discussion in 'Plugin Development' started by Cowboys1919, Jan 11, 2013.

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

    Cowboys1919

    I am trying to use some code to get the local item name text for a Material:

    I need to get the material into a format like these to retrieve the value:
    Code:
    item.egg.name=Egg
    item.compass.name=Compass
    item.fishingRod.name=Fishing Rod
    item.clock.name=Clock
    item.yellowDust.name=Glowstone Dust
    item.fishRaw.name=Raw Fish
    item.fishCooked.name=Cooked Fish
    item.record.name=Music Disc
    item.bone.name=Bone
    item.dyePowder.black.name=Ink Sac
    item.dyePowder.red.name=Rose Red
    item.dyePowder.green.name=Cactus Green
    item.dyePowder.brown.name=Cocoa Beans
    item.dyePowder.blue.name=Lapis Lazuli
    item.dyePowder.purple.name=Purple Dye
    item.dyePowder.cyan.name=Cyan Dye
    
    I have code that works to change something like "IRON_BLOCK" to "ironBlock", but the real problem here is how items like "inkSack" need to be "dyePowder.black" and "glowstoneDust" needs to be "yellowDust"

    Can anyone think of a way to get this name from an org.bukkit.Material?

    (in other words, is there a function somewhere to get these values?)
     
  2. Offline

    chasechocolate

    Afaik no. You will have to make some if-statements to check the item durability.
     
  3. With the bukkit API (surprisingly ...) no. And because it's part of minecraft's internal workings, they probably won't ever put that in ...

    With access to native code, there is (untested):
    Code:
    String nameIdentifier = CraftItemStack.asNMSCopy(bukkitItemStack).a();
    (method name as of 1.4.6)

    That should give you the right value (if I'm not mistaken without the ".name" suffix).
     
    Cowboys1919 likes this.
  4. Offline

    Cowboys1919

    Thanks man! That works great. Wish I could like it more than once.
     
Thread Status:
Not open for further replies.

Share This Page