[SOLVED] Get item name

Discussion in 'Spigot Plugin Development' started by PatoTheBest, Jul 5, 2015.

  1. Is there any way of getting the real name of the item if it has no Item meta? The real name of the item (Grass Block, instead of Grass which is the name of the material)
  2. Sadly, no. You have to make your own way to do this. I have my own enum I copy paste between projects that helps with real names.
  3. Mind if you share it?
  4. Its private. :( (one of the few things i keep private to myself)

    Its not hard to make one for yourself, though. There are lots of examples on different way to do it if you google it. Some people simply use a HashMap, others use csv table, others an enum, etc etc. Just have to find something that fits your needs.
  5. Code (Text):
    public BlockNames getRealBlockName(Block b){
    case GRASS:
    return BlockNames.GRASS_BLOCK;
    Wrote this in the code insert page, took me ~15 seconds. That's and example just for one block.
  6. Well you coult just use somrthing that changes all the blocks (eg grass, dirt) into grass_block just by adding _block onto the name... but I havent thought of a way to differentiate from blocks and items other than what has been said above
  7. I re-wrote the method, my objective was to make kind of like a drop party but the problem with that was the item stacking, so I basically created a new ItemStack, applied all the data, durability, lore, enchantments and gave that to the player.