[Solved] Grab Itemtypes from config

Discussion in 'Spigot Plugin Development' started by Karatechimp29, May 28, 2015.

  1. if i had a config with an area to set an itemtype how would i execute that in the code:

    Code (Text):
            ItemStack addon1 = new ItemStack(Material.POTION);
    where i have "Material.POTION" how can i grab the material from config?

    i also need to do the same with potion effect types
  2. Material.valueOf(config.getString("Material"));
  3. Inkzzz

    Resource Staff

  4. and for potion effects?
  5. My plugin will be complete when i resolve this...
  6. You are supposed to wait 24 hours before bumping. You waited 6 minutes.
    Your parenthesis is in the wrong place.
  7. i have re-written the whole line and still it's red. Where are my parenthesis out?
  8. PotionEffectType.getByName(getConfig().getString("Addon1.PotionType"),
  9. I must be blind, i cant see the miss-placed parenthesis
  10. There should be a parenthesis after the 109th character in this line of code.
    Code (Text):
    player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(getConfig().getString("Addon1.PotionType"), getConfig().getInt("Addon1.Duration")*20, 1)));
    This new parenthesis should replace the 157th character. Specific enough? ;)
  11. the 157th character is in the middle of "Addon1.Duration" ???
  12. Pretty sure you counted wrong.
  13. i just counted again and it lands in the same spot:

    The Line:
    Code (Text):
    player.addPotionEffect(PotionEffectType.getByName(getConfig().getString("Addon1.PotionType"), this.getConfig().getInt("Addon1.Duration")*20, 1));
    I'm lost here...
  14. getByName(
  15. ok i have changed it to this but now addPotionEffect is underlined saying "LivingEntity is not applicable for the arguments"

    Code (Text):
    player.addPotionEffect(PotionEffectType.getByName(getConfig().getString("Addon1.PotionType")), this.getConfig().getInt("Addon1.Duration")*20, 1);
    #17 Karatechimp29, May 28, 2015
    Last edited: May 28, 2015
  16. //EDIT: No matter what i change in here, the errors keep rolling in. What shall i do?