I've just made a name to ID. So you can use things like "/give sand" instead of "/give 12". I'm not currently near a computer with an IDE on it. Could you please verify if this'll work? If so, feel free to use it. It's not advanced at all and only supports blocks at the moment. Code: public enum blocks { stone, grass, dirt, cobblestone, wooden_plank, saplin, bedrock, water, stationary_water, lava, stationary_lava, sand, gravel, gold_ore, iron_ore, coal_ore, wood, leaves, sponge, glass, lapis_lazuli_block, dispenser, sandstone, note_block, wool, yellow_flower, red_rose, brown_mushroom, red_mushroom, gold_block, iron_block, double_stone_slab, stone_slab, brick, tnt, bookshelf, moss_stone, obsidian, torch, fire, monster_spawner, wooden_stairs, chest, redstone_wire, diamond_ore, diamond_block, workbench, crops, soil, furnace, burning_furance, sign_post, wooden_door, ladder, minecart_tracks, cobblestone_stairs, wall_sign, level, stone_pressure_plate, iron_door, wooden_pressure_plate, redstone_ore, glowing_redstone_ore, redstone_torch_off, redstone_torch_on, stone_button, snow, ice, snow_block, cactus, clay, sugar_cane, jukebox, fence, pumpkin, netherrack, soul_sand, glowstone, portal, jack_o_latern, cake_block; } public int nameToID(String name){ Integer in = 0; for(blocks b : blocks.values()){ in++; if(name == b.toString()) { return in; } } return -1; } Basically, I've taken advantage of blocks being in order in terms of IDs.
Hi, If by Blocks you org.bukkit.Material then then try public Material nameToID(String name){ Material.getMaterial(name).getId(); } If you want to use your own class then try: public blocks nameToID(String name){ blocks.valueOf(name); } it will not return the ID as a number but the blocks Object with it is.
This is basically it. But I just had the sudden realization that both need to have the _'s in them. So GOLDEN_AXE and stuff. I'll have to use this for now though, thanks!
on addition everithing is written in Capital Letters so maybe a name.toUpperCase() would also work wonders for the lazy (like me)