onPlayerDeath Help!

Discussion in 'Plugin Development' started by stantheman68, Mar 23, 2013.

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

    stantheman68

    Hey,

    I've been trying to change the death messages back to the previous color, Yellow, instead of white. Though when I finished coding I had an error. I'm not quite sure how to fix it so I thought someone on the bukkit forums would know.

    Here's my player listener class,

    Code:
    package me.stantheman68.deathmessages;
     
    import org.bukkit.ChatColor;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.PlayerDeathEvent;
     
    public class PlayerListener implements Listener{
        public static DeathMessages plugin;
     
        public PlayerListener(DeathMessages instance) {
            plugin = instance;
       
            @EventHandler( priority = EventPriority.HIGHEST)
            public void onPlayerDeath(final PlayerDeathEvent event) {
           
                event.setDeathMessage(ChatColor.YELLOW + event.getDeathMessage());
            }
        }
    }
     
  2. Offline

    chasechocolate

    What error do you get?
     
  3. Offline

    NerdsWBNerds

    Code:
    package me.stantheman68.deathmessages;
     
    import org.bukkit.ChatColor;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.PlayerDeathEvent;
     
    public class PlayerListener implements Listener{
        public static DeathMessages plugin;
     
        public PlayerListener(DeathMessages instance) {
            plugin = instance;
        }
       
        @EventHandler
        public void onPlayerDeath(PlayerDeathEvent event) {
            event.setDeathMessage(ChatColor.YELLOW + ChatColor.stripColor(event.getDeathMessage()));
        }
    }
    
     
  4. Offline

    PolarCraft

    Why are you using final when you arent using a scheduler?
     
  5. Offline

    RainoBoy97

    You have the listener inside the constructor :p
    NerdsWBNerds gave you the fixed code ;)
     
  6. Offline

    kreashenz

    Uhmm.. I don't think anyone noticed, but I think my post got removed? I swear I posted a code for this guy last night..
     
  7. Offline

    stantheman68

    Thanks!
    It fixed the code but when I tried the plugin in game, the messages were still white.
     
Thread Status:
Not open for further replies.

Share This Page