problem saving potions with effects to config

Discussion in 'Spigot Plugin Development' started by John_H_Smith, Apr 25, 2017.

Thread Status:
Not open for further replies.
  1. Hi guys, as said in the title I want to save potions to config. I just did with ItemStacks, but not with potions. So can I convert the potion to an ItemStack? The potion tag is deprecated at the moment as it looks.
    I just tried this one:
    Code (Text):
    if(args[3].equals("373")) {
         int id = Integer.parseInt(args[4]);
         int amount= Integer.parseInt(args[5]);
         int effect = Integer.parseInt(args[6]);
         stack = new ItemStack(id, amount, (short) effect);              
    but the (short) effect is also deprecated.
    So is there a way? Saving into config should be no problem for me.
    Thank you!
    #1 John_H_Smith, Apr 25, 2017
    Last edited: Apr 25, 2017
  2. Does anyone have an idea?
  3. Potions don't use durability anymore. If you want to save them to a config, just put the ItemStack in a ConfigurationSection.

    But your code looks like you are not trying to save to a config but to build one from a command? In that case you'd need to use PotionMeta to set the effects, maybe take an effect name in the command rather than a durability id.
  4. Saving in config is no problem for me, I want to save it into a config after sending a command. Like /potion arg arg arg ID amount effectID
  5. And how can I make the ItemStack a potion? I'm so sorry, I am really new to item handling in Bukkit.
  6. Okay thank you, you helped me very much! I've just one little question, in this code
    Code (Text):
    pMeta.addCustomEffect(new PotionEffect(PotionEffectType.getByName(args[5]), 1200, 1200) , true);
    the both "1200" are the duration and the amplifier. Can those be set to the default value of the effect?
  7. I don't think so, just look up what they should be on the mc wiki. I'm guessing default amplifier is normally zero so that one's easy.
Thread Status:
Not open for further replies.