Configurable item material

Discussion in 'Plugin Development' started by stimoze, Jul 10, 2016.

Thread Status:
Not open for further replies.
  1. So, i'm developing a plugin, and in this plugin there's an ItemStack. I want to add item material to the config file. This is what i've tried
    Code:
                HealItem.setType(getConfig().getString("Material"));
    It says "The method setType(Material) in the type ItemStack is not applicable for the arguments (String)"

    Any other solutions?
     
  2. Offline

    ArsenArsen

    You need to do Material.matchMaterial(getConfig().getString("Material")).
    But first check is it null, and if it is use a default material, and log that the one in config does not exist.
     
    stimoze likes this.
  3. Offline

    ipodtouch0218

    getConfig().getString("Material")

    You're getting a string from the config... You'll need to use Material#getMaterial(string);

    EDIT: Ninja'd by @ArsenArsen
     
  4. Is this ok?
    Code:
    Material.matchMaterial(getConfig().getString("Material")).
     
  5. @stimoze Not sure if matchMaterial cares about case so if that doesn't work do .toUpperCase
     
  6. I tested it out and it worked :) Thank you guys for helping me :)
     
  7. Offline

    ArsenArsen

    It does not :)

    getMaterial (Something like that) does
     
  8. It does :) i have this code
    Code:
    HealItem.setType(Material.matchMaterial(getConfig().getString("Material")));
     
  9. Offline

    ArsenArsen

    I meant it does that care if it's mixed case.
     
Thread Status:
Not open for further replies.

Share This Page