1.8.8 Reducing splash pot time

Discussion in 'Spigot Plugin Development' started by AJ-Plugin-BotDev, Feb 29, 2020.

  1. Hello im tryna reduce the duration of a splash potion if the effected player has a perm.
    Eg perm druid.tier.1 multiplies it by a value in a config, same for tier2 up to tier 5, the highest tier perm is the one they get.
    Here is what i have, but it runs for any splash pot and doesnt seem to care about perms, as when testing the only perm i had was luckperms.*


    Code (Java):
     public void onSplash(final PotionSplashEvent ev){
                for(Entity entity : ev.getAffectedEntities()){
                    if(!(entity instanceof Player)) continue;
                    Player player = (Player) entity;
                    Bukkit.getScheduler().runTaskLater(plugin, () -> {
                        for (int i = 5; i > 0; i--) {
                            if (!player.hasPermission("druid.tier." + i)) {
                                continue;
                            }
                            for(PotionEffect effect : ev.getPotion().getEffects()){
                                if(!effect.getType().equals(PotionEffectType.POISON)) continue;
                                double time = effect.getDuration() * plugin.getConfig().getDouble("poison.tier" + i);
                                player.removePotionEffect(effect.getType());
                                player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, (int) time, effect.getAmplifier(), true));
                            }
                            break;
                        }
                    }, 1L);
                }
            }
     
  2. You can invoke setVelocity on a ThrownPotion, which ev.getPotion will return in this case.
    Keep in mind you will have to work with a vector instead of just an Integer.
     
  3. I think he want to reduce the duration of the potion effect not the flying time of the thrown potion.

    To do that you should use event.setIntensity() have a look at the javadoc
     
    • Agree Agree x 1