How do i make a sword so every time I hit a player , it gives them poison ? I know I can do p.addPotionEffect, But I want the sword to make a splashing effect, like it throws a poison potion at the player, and it effects the player and ONLY the player. So for example if I hit the player instead of p.addPotionEffect, I send a poison potion at them and the poison only affects them, help please!
Get the world / players location / whatever and play the effect POTION? (Reason for question mark; I can't fully understand you)
CoderRevolq In an EntityByDamageEntityEvent, then get the damaged entity and check if it's instance is a player. If so, spawn a splash potion entity on their location and add a poison effect: Code:java @EventHandlerpublic void onBlah(EntityDamageByEntityEvent e) { // Check instance // define players (I'm calling damaged player p) // Poison for 5 seconds. p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 100, 2)); p.getWorld().spawnEntity(p.getLocation(), EntityType.SPLASH_POTION); }