1.12.2 Particle on hit

Discussion in 'Spigot Plugin Development' started by witer, Jan 31, 2020.

Thread Status:
Not open for further replies.
  1. this is the code of my plugin:

    package witer33.me;

    import org.bukkit.Bukkit;
    import org.bukkit.Effect;
    import org.bukkit.Location;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    public final class ParticleHit extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
    }

    @EventHandler
    public void onDamage(EntityDamageByEntityEvent e) {
    if (e.getEntity() instanceof Player && e.getDamager() instanceof Player) {
    Player whoWasHit = (Player) e.getEntity();
    Player whoHit = (Player) e.getDamager();
    whoHit.sendMessage("HIT");
    }
    }

    }


    why it doesn't work?

    i'm testing only if the event work, i add particle soon.
     
  2. Add this to the onEnable() method
    Code (Java):
    getServer().getPluginManager().registerEvents(this, this);
     
    • Agree Agree x 1
  3. also please use formatting for your code

    [.CODE] without the .
    package witer33.me;

    import org.bukkit.Bukkit; etc
    [./CODE] without the .

    result:
    Code (Text):

    package witer33.me;

    import org.bukkit.Bukkit;
     
    its easier to read than neon green
     
Thread Status:
Not open for further replies.