From d2a2adcacbd6bc81808e843ddd04be1672fd852e Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Fri, 27 Apr 2018 14:06:53 +0200 Subject: [PATCH] Add option to disable global death messages --- .../dre2n/dungeonsxl/config/MainConfig.java | 28 ++++++++++++++++++- .../dre2n/dungeonsxl/player/DGamePlayer.java | 4 +++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/dre2n/dungeonsxl/config/MainConfig.java b/src/main/java/io/github/dre2n/dungeonsxl/config/MainConfig.java index c5bcd472..d2e83253 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/config/MainConfig.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/config/MainConfig.java @@ -47,7 +47,7 @@ public class MainConfig extends DREConfig { NEVER } - public static final int CONFIG_VERSION = 14; + public static final int CONFIG_VERSION = 15; private String language = "english"; private boolean enableEconomy = false; @@ -86,6 +86,7 @@ public class MainConfig extends DREConfig { /* Misc */ private boolean sendFloorTitle = true; + private boolean globalDeathMessagesDisabled = true; private Map externalMobProviders = new HashMap<>(); private Map resourcePacks = new HashMap<>(); @@ -300,6 +301,23 @@ public class MainConfig extends DREConfig { announcementInterval = interval; } + /** + * @return + * false if death messages shall be sent to players who are not in the dungeon, + * true if not + */ + public boolean areGlobalDeathMessagesDisabled() { + return globalDeathMessagesDisabled; + } + + /** + * @param disabled + * set if death messages shall be sent to players who are not in the dungeon + */ + public void setGlobalDeathMessagesDisabled(boolean disabled) { + globalDeathMessagesDisabled = false; + } + /** * @return if the floor title shall be sent */ @@ -514,6 +532,10 @@ public class MainConfig extends DREConfig { config.set("sendFloorTitle", sendFloorTitle); } + if (!config.contains("globalDeathMessagesDisabled")) { + config.set("globalDeathMessagesDisabled", globalDeathMessagesDisabled); + } + if (!config.contains("externalMobProviders")) { config.createSection("externalMobProviders"); } @@ -643,6 +665,10 @@ public class MainConfig extends DREConfig { sendFloorTitle = config.getBoolean("sendFloorTitle"); } + if (config.contains("globalDeathMessagesDisabled")) { + globalDeathMessagesDisabled = config.getBoolean("globalDeathMessagesDisabled"); + } + if (config.contains("externalMobProviders")) { externalMobProviders = config.getConfigurationSection("externalMobProviders").getValues(false); } diff --git a/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java b/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java index a06ac672..4078d058 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/player/DGamePlayer.java @@ -851,6 +851,10 @@ public class DGamePlayer extends DInstancePlayer { return; } + if (config.areGlobalDeathMessagesDisabled()) { + event.setDeathMessage(null); + } + if (game.getRules().getKeepInventoryOnDeath()) { setRespawnInventory(event.getEntity().getInventory().getContents()); setRespawnArmor(event.getEntity().getInventory().getArmorContents());