Solved Getting Material-Name like IG-Name?

Discussion in 'Plugin Development' started by PreFiXAUT, May 29, 2014.

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

    PreFiXAUT

    Hi Guys, I got a question to the Materials.
    I KNOW that there is a function to get the "Name" of a Material with Material.MATERIAL_NAME.name, but the name is always in Uppercase.
    Is there maybe a Way/Function to get the Name like IG? For example: Material.STONE.name = "STONE", InGame: "Stone".
     
  2. Offline

    metalhedd

  3. Offline

    PreFiXAUT

    Looks nice, but as I tried it out it will only give me the node-name :/
    Im using CB 1.7.9, maybe caused by it? Cuz you're using 1.7.3 References.
     
  4. Offline

    mythbusterma

    Instead of bothering with NMS which will constantly break your plugin why don't you just to Material.toString() and then manipulate it using javas String functions.
     
  5. Offline

    PreFiXAUT

    Because I don't know every Minecraft-Item name. They aren't always like: "First Character Of Each Word Is Uppercase", example: "Eye of Ender" would make it to "Eye Of Ender" :/
     
  6. Offline

    Azubuso

    PreFiXAUT Just do as mythbusterma said, get the name of the Material then just play around with Java's built in String manipulation. Can easily just do .toLowerCase() then replace the first character of the String with an uppercase version of itself.
     
  7. Offline

    mythbusterma

    Use String#replace ("_"," ") then use StringUtils.capitalize (String), then replace "The", "Of", etc with "the," "of."
     
  8. Offline

    PreFiXAUT

    True, forgot about that. Thanks xD
     
  9. Offline

    metalhedd

    The problem with this solution is that all your dyes will be called "Ink Sack" along with a few other inconsistencies sulphur vs gunpowder, "log2" etc. It doesn't make for good UI.

    The nms code I posted works perfectly with 1.7.9, it gave you the node name because you called the method which returns that instead of the one that actually translates it. Read the comments

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 1, 2016
  10. Offline

    PreFiXAUT

    No, i used the fromStack() Method, but it didn't work. And thanks, I'm able to read Comments.
     
  11. Offline

    metalhedd

    You'll have to forgive my skepticism, because it does, in fact, work perfectly. its written for 1.7.9, not 1.7.3 (which doesn't exist) I've tested it myself, as have others. You're doing something wrong if it doesn't work for you.
     
Thread Status:
Not open for further replies.

Share This Page