PotionSplashEvent help

Discussion in 'Spigot Plugin Development' started by CuongVnZ, Jul 17, 2019.

  1. Hi, like the title
    i have this code below
    Code (Text):
       

    public void shootPotion(Player p){
                            ThrownPotion entity = (ThrownPotion) p.launchProjectile(ThrownPotion.class);
                            entity.setVelocity(entity.getVelocity().multiply(1.3));
                            entity.setBounce(false);
                            entity.setShooter(p);
    }
    @EventHandler
    public void onPotionSplash(PotionSplashEvent event) {
            ThrownPotion pot = event.getPotion();
            if (pot.getShooter() instanceof Player) {
                Player p = (Player) pot.getShooter();
                p.sendMessage("You shoot a potion");
            }
            event.setCancelled(true);
    }
    The problem is when i use command to cast shotPotion(p) function and there wasn't no message to me. When i use normal splash potion(CREATIVE) and the message sent to me. Please help me to fix!
     
  2. md_5

    Administrator Developer

    Version?

    Unless using 1.14 you probably want SplashPotion in the launchProjectile

    If using 1.14 you need to call .setItem instead and make sure the item is a splash potion
     
  3. 1.12.2 .
     
  4. BUMP! NEED HELP!
     
  5. bump, still need help