Util [Reflection] Friendly item names

Discussion in 'Resources' started by KingFaris11, Feb 1, 2015.

Thread Status:
Not open for further replies.
  1. @API_Tutorials
    No need to over complicate things :D.
    public static String getFriendlyName(Material mat) {
    StringBuilder sb = new StringBuilder();
    for (String str : mat.name().split("_"))
    sb.append(" ").append(Character.toUpperCase(str.charAt(0))).append(str.substring(1).toLowerCase());
    return sb.toString().trim().replace("Diode", "Redstone Repeater").replace("Thin Glass", "Glass Pane").replace("Wood ", "Wooden ");
    Results from Material.BAKED_POTATO:
    Baked Potato
    Results from Material.STONE:
    Last edited: May 26, 2015
    KingFaris11 likes this.
  2. @FisheyLP Why would you replace the underscore and then split by space? Just split by underscore... That would also end up with, for example, "Diode" rather than "Repeater".
  3. @AdamQpzm Fixed
    @KingFaris11 At line 47 and 51: There is only the method capitalize not capitalizeFully
  4. Woops, thanks, forgot to change that xD
  5. Offline


    well.. looking the code of that method (be creative) it seems to return the name when the item has a tag name .. when not, it returns the global string name (like "tile.stone.name") calling same a() method

    and yes, i also feel is unlike this method name will change, and if does updating is easy (but broke backwards compatibility)
Thread Status:
Not open for further replies.

Share This Page