Is LaunchProjectileEvent working?

i have this piece of code @Listener public void onShoot(LaunchProjectileEvent e) { logger.info("func1 - Pastebin.com
but console doesn’t log anything when i’m shoting snowball

It is. Your using event.getSource(). That is source of the event, not the source of the shooting. A good way to test if a event is working is just to stick a message at the start of the function.

To get the source of the shooting. Use
Projectile.getShooter().

Oh and also using == with a string doesnt work, use .equals()

And also its better to compare the uuids of the player as its … Well unique

at 3rd line of this i have logger.info() and it doesn’t display message on console.

just tested it on my end, it seems like the event is not firing. What exactly are you trying to do with the event? there maybe a alternative?

I want to make this snowball explode when it hit ground but first i need to add type of paraneter that will help me indentify snawball that was fired by plugin item.
now i try to identify this snowball
My idea was to colect players that used item and after that make snawball fired by that players diffrent

Try this event.

@Listener
public void onLand(CollideBlockEvent.Impact event, @First Snowball ball){
    System.out.println("Entity: " + ball.getType().getId() + " | Shooter: " + ball.getShooter() + " | Is Player: " + (ball.getShooter() instanceof Player));
}

This will fire when/if the snowball hits a block (meaning you could have the explode). I know from a previous issue you had you use InteractItemEvent to detect the shooter, just need to match the two events together by the player

1 Like

Just found this. The LaunchProjectileEvent not firing is a known issue.

1 Like