Add ability to hide death messages for disguised players in config

This commit is contained in:
libraryaddict 2024-10-29 17:26:07 +13:00
parent 762368cef5
commit 0950910b39
3 changed files with 18 additions and 1 deletions

View File

@ -301,6 +301,9 @@ public class DisguiseConfig {
@Getter
@Setter
private static boolean uniquePlayerDisguiseUUIDs;
@Getter
@Setter
private static boolean hideDeathMessages;
public static boolean isArmorstandsName() {
return getPlayerNameType() == PlayerNameType.ARMORSTANDS;
@ -710,6 +713,7 @@ public class DisguiseConfig {
String apiKey = config.getString("MineSkinAPIKey");
setSoundsEnabled(config.getBoolean("DisguiseSounds"));
setUniquePlayerDisguiseUUIDs(config.getBoolean("UniquePlayerUUID"));
setHideDeathMessages(config.getBoolean("HideDeathMessages"));
if (apiKey != null && apiKey.matches("[a-zA-Z\\d]{8,}")) {
DisguiseUtilities.getMineSkinAPI().setApiKey(apiKey);

View File

@ -40,6 +40,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
@ -842,4 +843,13 @@ public class DisguiseListener implements Listener {
disguiseRunnable.put(playerName, runnable);
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
if (!DisguiseConfig.isHideDeathMessages() || !DisguiseAPI.isDisguised(event.getPlayer())) {
return;
}
event.setDeathMessage(null);
}
}

View File

@ -37,4 +37,7 @@ RetaliationCombat: false
# If pvp or pve is disabled, this takes effect.
# If RetaliationCombat is false, or it's true but they haven't fought back in PvPTimer seconds, then they can't fight back.
# This also controls it so they can't fight back PvPTimer seconds after applying a disguise
PvPTimer: 5
PvPTimer: 5
# If this is enabled, death messages will not show for players if they were disguised
HideDeathMessages: false