Death Sound

Discussion in 'Plugin Development' started by MCraftGamer35, Aug 24, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    MCraftGamer35

    I'm trying to code a plugin that plays a xp pickup sound to the killer on death, I have been having problems, so I need to know what to do after I implemented the event.

    Here is the code:
    Code:
    package me.Alex.XP;
     
    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class XP extends JavaPlugin implements Listener {
       
        public void onEnable(){
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
        }
       
        @EventHandler
        public void onPlayerKill(PlayerDeathEvent e){
           
        }
     
    }
     
  2. Offline

    Jalau

    MCraftGamer35
    Code:java
    1. @EventHandler
    2. public void onPlayerKill(PlayerDeathEvent e){
    3. if(e.getEntity().getKiller() != null)
    4. e.getEntity().getKiller().playSound(e.getEntity().getKiller().getLocation(), Sound.ORB_PICKUP, 1, 1);
    5. }


    Not tested ;)
     
  3. Offline

    MCraftGamer35

    Thank you so much! It works! @ Jalau

    Jalau Would you know how to add a heart particle effect too?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  4. Offline

    JordyPwner

  5. Offline

    MCraftGamer35

  6. Offline

    JordyPwner

Thread Status:
Not open for further replies.

Share This Page