Custom Kill Messages + Sound

Discussion in 'Plugin Development' started by 4non, Jul 7, 2013.

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

    nitrousspark

    dont use == for strings, use .equals

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

    4non

    "String message = event.getDeathMessage();"
    wasn't used so I removed it. Still doesn't work.
     
  3. Offline

    nitrousspark

    are you registering the event in onEnable()?
     
  4. Offline

    4non

    OH MY GOD I JUST REALIZED THAT I DIDN'T DO THAT THANK YOU.

    It's still not working though.

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

    Techy4198

    nitrousspark
    why use '.equals()' instead of '=='? it always works fine for me...

    also i have just thought of a way to control any entity you ride; move towards where the player is looking if they are sneaking, using sneak as the 'go' key basically. but i am aware that this will not work in 1.6 and above, since the sneak key is used to dismount vehicles. so is there any other key press that gets sent to the server when riding a mob? or is it just sneak?

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

    4non

    I'm pretty sure WASD or whatever you use to move will affect them.
     
  7. Offline

    Techy4198

    no. only for minecarts and horses. for other things, the packets are not sent. also seems you can no longer sneak while riding a mob in 1.5 anyway :(
     
  8. Offline

    4non

    oh. well that sucks... can we stay on topic please? xD

    Hey guys thanks for all the support.. but I'm going to need to get this finished before Friday...

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

    foodyling

    Code:
    //package net.malicepvp.malicepvp;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Sound;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.PlayerDeathEvent;
     
    public class reap implements Listener {
      public static MalicePvP plugin;
     
      public reap(MalicePvP instance) {
        plugin = instance;
      }
     
        @EventHandler
        public void onPlayerDeath(PlayerDeathEvent event) {
            Player killer = event.getEntity().getKiller();
            if (killer != null && killer.getName().equals("Skeleton_o_Dhuum")) {
                event.setDeathMessage(ChatColor.AQUA + "[" + ChatColor.GRAY + "???" + ChatColor.AQUA + "] " + ChatColor.BLACK + "Someone has been taken...");
                for(Player p : Bukkit.getOnlinePlayers()){
                    p.playSound(p.getLocation(), Sound.WITHER_DEATH, 1, 0);
                }
            }
        }
    }
     
  10. Offline

    Techy4198

    sorry, i didn't think a small thing like that was worth its own thread. but maybe it was :p
     
  11. Offline

    4non

    thanks :D
     
Thread Status:
Not open for further replies.

Share This Page