Allow to disable the death messages of minecraft

This commit is contained in:
snowleo 2011-10-09 20:59:06 +02:00
parent ac794bb2b7
commit 3496df6468
4 changed files with 22 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityListener; import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -69,24 +70,29 @@ public class EssentialsEntityListener extends EntityListener
} }
@Override @Override
public void onEntityDeath(EntityDeathEvent event) public void onEntityDeath(final EntityDeathEvent event)
{ {
if (event.getEntity() instanceof Player) if (event instanceof PlayerDeathEvent)
{ {
User user = ess.getUser(event.getEntity()); final PlayerDeathEvent pdevent = (PlayerDeathEvent)event;
final User user = ess.getUser(pdevent.getEntity());
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back")) if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
{ {
user.setLastLocation(); user.setLastLocation();
user.sendMessage(Util.i18n("backAfterDeath")); user.sendMessage(Util.i18n("backAfterDeath"));
} }
if (!ess.getSettings().areDeathMessagesEnabled())
{
pdevent.setDeathMessage("");
}
} }
} }
@Override @Override
public void onFoodLevelChange(FoodLevelChangeEvent event) public void onFoodLevelChange(FoodLevelChangeEvent event)
{ {
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled()) if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{ {
//TODO: Remove the following line, when we're happy to remove backwards compatability with 1185. //TODO: Remove the following line, when we're happy to remove backwards compatability with 1185.
event.setFoodLevel(20); event.setFoodLevel(20);
event.setCancelled(true); event.setCancelled(true);

View File

@ -132,4 +132,6 @@ public interface ISettings extends IConf
long getAutoAfkKick(); long getAutoAfkKick();
boolean getFreezeAfkPlayers(); boolean getFreezeAfkPlayers();
boolean areDeathMessagesEnabled();
} }

View File

@ -523,4 +523,10 @@ public class Settings implements ISettings
{ {
return config.getBoolean("freeze-afk-players", false); return config.getBoolean("freeze-afk-players", false);
} }
@Override
public boolean areDeathMessagesEnabled()
{
return config.getBoolean("death-messages", true);
}
} }

View File

@ -238,6 +238,9 @@ auto-afk-kick: -1
# The player has to use the command /afk to leave the afk mode. # The player has to use the command /afk to leave the afk mode.
freeze-afk-players: false freeze-afk-players: false
# You can disable the death messages of minecraft here
death-messages: true
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | EssentialsHome | # # | EssentialsHome | #