Add effect to splash potions

Discussion in 'Plugin Development' started by Ward1246, May 17, 2015.

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

    Ward1246

    I would like to add effects to splash potion entities, but i could not find a good way to do this. I am running a command that launches the potion. I tried one method but i didn't work. No effects were added. The arguments or command are not the problem, the potion just has no effects.
    Code:
                                          if(label.equalsIgnoreCase("ThrownPotion")) {
                                                    Player player = (Player) sender;
                                                    if (args.length == 1);
                                                    ThrownPotion potion = player.launchProjectile(ThrownPotion.class);
                                                    if (args[0].equals("Absorption"))
                                                        potion.getEffects().add(new PotionEffect(PotionEffectType.ABSORPTION, 1, 400));
    Is there a way to do this in my case? Thanks.
     
  2. When you type the command, do you type /thrownpotion absorption? if you do you only checked if the first argument was equal to Absorption, not equal ignoring case
     
  3. Offline

    Ward1246

    I have tried again, and it still did not work. I even copy and pasted it to make sure i made absolutely no typos. I did the same as that, but i will make it ignore case.
    EDIT: I remember in one post that it said that that method does not work. I would like another method if that is true, but it needs to be able to be run by command, i will post if there are any errors.

    Partly solved:
    Code:
    if (args.length == 1);
                                                    if (args[0].equalsIgnoreCase("Absorption"));
                                                    Potion potion = new Potion(PotionType, int);
                                               
                                                    potion.setSplash(true);
                                               
                                                    ItemStack itemStack = new ItemStack(Material.POTION);
                                                    potion.apply(itemStack);
                                                    Player player = (Player) sender;
                                                    ThrownPotion thrownPotion = player.launchProjectile(ThrownPotion.class);
                                                    thrownPotion.setItem(itemStack);
    
    HOWEVER, I need potions: Resistance, Absorption, Health boost, Saturation, Nausea, Hunger, Wither, Mining Fatigue, Haste, Blindness, and Jump boost. These do not have a ID so i need another method for these.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  4. Offline

    BrickBoy55

    You don't end an if statement with a semi-colon. Learn java before using bukkit.
     
  5. Offline

    Ward1246

    I have learned java. And i would need that semicolon because if i don't i get an error. Yet that code was updated, the semicolon should have been a bracket. And i know that i do not need one. Don't make assumptions before posting, and test things for yourself before posting.




    I mean really? Without that the whole command does nothing. Besides that is not the problem anymore, so if you decide not to help, don't post.
     
Thread Status:
Not open for further replies.

Share This Page