DeathMessage not working

Discussion in 'Plugin Development' started by CheesyFreezy, May 31, 2015.

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

    CheesyFreezy

    Heey developers,

    I'm here to try to get some help with my plugin. I'm trying to change the death message, but it's not changing. I've tried everything but still no luck.

    Code:
    Code:
    event.setDeathMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "> " + ChatColor.AQUA + player.getName() + ChatColor.GRAY + "'s death was caused by " + ChatColor.YELLOW + player.getLastDamageCause().toString().toLowerCase().replace("_", " ") + ChatColor.GRAY + "!");
    
    Player killer = null;
    if(player.getKiller() != null) {
       killer = player.getKiller();
                       
       event.setDeathMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "> " + ChatColor.AQUA + player.getName() + ChatColor.GRAY + " was killed by " + ChatColor.AQUA + killer.getName() + ChatColor.GRAY + "!");
       killer.sendMessage(Plugin.prefix + ChatColor.YELLOW + "" + ChatColor.BOLD + "> " + ChatColor.GRAY + "You've killed " + ChatColor.YELLOW + player.getName() + ChatColor.GRAY + " and earned " + ChatColor.GOLD + "10 coins" + ChatColor.GRAY + "!");
                       
       Core.sgManager.totalKills.put(killer.getName(), Core.sgManager.totalKills.get(killer.getName()) + 1);
       Core.sgManager.totalCoins.put(killer.getName(), Core.sgManager.totalCoins.get(killer.getName()) + 10);
                       
       File ecoFile = new File(Plugin.core.getDataFolder(), "economy.yml");
       YamlConfiguration ecoConfig = null;
       if(ecoFile.exists()) {
         ecoConfig = YamlConfiguration.loadConfiguration(ecoFile);
       }
                       
       if(ecoConfig.isConfigurationSection("sgcoins") && ecoConfig.isInt("sgcoins." + killer.getName())) {
         ecoConfig.set("sgcoins." + killer.getName(), ecoConfig.getInt("sgcoins." + killer.getName()) + 10);
         try {
           ecoConfig.save(ecoFile);
         } catch (IOException e) {
           e.printStackTrace();
         }
       } else {
         ecoConfig.set("sgcoins." + killer.getName(), 10);
         try {
           ecoConfig.save(ecoFile);
         } catch (IOException e) {
           e.printStackTrace();
         }
       }
    } else {
       event.setDeathMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "> " + ChatColor.AQUA + player.getName() + ChatColor.GRAY + "'s death was caused by " + ChatColor.YELLOW + player.getLastDamageCause().toString().toLowerCase().replace("_", " ") + ChatColor.GRAY + "!");
    }
    
     
  2. Offline

    FisheyLP

    Did you
    • Let this class implement Listener
    • Register the events
    • @EventHandler
    ?
     
  3. Offline

    CheesyFreezy

    Yup...
     
  4. Offline

    Dudemister1999

    @CheesyFreezy
    You might want to check if another plugin is setting the death message. I know, it's a long shot, but there's a good chance there is. I know Essentials does this.
     
Thread Status:
Not open for further replies.

Share This Page