Finding valueof(ItemString)

Discussion in 'Plugin Development' started by Ben S, Jan 12, 2011.

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

    Ben S

    The way my plugin works is it reads in a string from a database file. It then breaks it up and make sense of it and gets resulting values like "StoneSpade" or "StoneAxe". In hMod, to look up the id for this type of item, I would do something like this:
    Code:
    id = Item.Type.valueOf(stringItem).getId();
    I have been playing with it for about 20 minutes and don't see how to do this. I'm pretty sure I am just overlooking this but any help would be greatly appreciated. Thanks!

    Edit:
    Well I finally figured it out. Not enjoying the confusing ways of bukkit. Apparently we have to go to a new type, Material.
    Code:
    tempItem = Material.getMaterial(stringItem);
    I'm finding bukkit to be much more difficult than hMod, just from comparing my learning curves to both...
    For my plugin I now have to use hashmaps and their associated keysets, which I never had to do with hMod. Coming from a fairly experienced programmer, some of this stuff is set up rather strange. I know this project wants to be different from hMod, but don't make it screwy.

    Also found a bug. Where should be report bugs, github?

    IT comes when you try to set the amount of an ItemStack to 0. You can get set it to any other number (1-64), but 0 has no effect.
     
  2. Offline

    toi

    You may report bugs on the bukkit redmine site http://redmine.bukkit.org/projects/bukkit .
    Bukkit gives you a lot more control and only seems harder than hmod because of this control, imo. I would never go back to hmod after using bukkit even if hmod would be continued.
    Also i belive that you can't get a material from a string yet, as there is no file to read the names from yet. However you may use the enumerator.valueOf(str) but then it needs to be the exact string i believe
     
Thread Status:
Not open for further replies.

Share This Page