diff --git a/EssentialsDiscord/src/main/java/net/essentialsx/discord/DiscordSettings.java b/EssentialsDiscord/src/main/java/net/essentialsx/discord/DiscordSettings.java index e443ae44d..3e18ea828 100644 --- a/EssentialsDiscord/src/main/java/net/essentialsx/discord/DiscordSettings.java +++ b/EssentialsDiscord/src/main/java/net/essentialsx/discord/DiscordSettings.java @@ -153,6 +153,10 @@ public class DiscordSettings implements IConf { return config.getBoolean("show-name", false); } + public boolean isShowDisplayName() { + return config.getBoolean("show-displayname", false); + } + public String getAvatarURL() { return config.getString("avatar-url", "https://crafthead.net/helm/{uuid}"); } diff --git a/EssentialsDiscord/src/main/java/net/essentialsx/discord/JDADiscordService.java b/EssentialsDiscord/src/main/java/net/essentialsx/discord/JDADiscordService.java index 126999681..5a0ea867b 100644 --- a/EssentialsDiscord/src/main/java/net/essentialsx/discord/JDADiscordService.java +++ b/EssentialsDiscord/src/main/java/net/essentialsx/discord/JDADiscordService.java @@ -252,7 +252,7 @@ public class JDADiscordService implements DiscordService { } public void updateTypesRelay() { - if (!getSettings().isShowAvatar() && !getSettings().isShowName()) { + if (!getSettings().isShowAvatar() && !getSettings().isShowName() && !getSettings().isShowDisplayName()) { for (WebhookClient webhook : channelIdToWebhook.values()) { webhook.close(); } diff --git a/EssentialsDiscord/src/main/java/net/essentialsx/discord/listeners/BukkitListener.java b/EssentialsDiscord/src/main/java/net/essentialsx/discord/listeners/BukkitListener.java index bcde3c6a7..03669bdac 100644 --- a/EssentialsDiscord/src/main/java/net/essentialsx/discord/listeners/BukkitListener.java +++ b/EssentialsDiscord/src/main/java/net/essentialsx/discord/listeners/BukkitListener.java @@ -101,7 +101,7 @@ public class BukkitListener implements Listener { MessageUtil.sanitizeDiscordMarkdown(FormatUtil.stripEssentialsFormat(jda.getPlugin().getEss().getPermissionsHandler().getSuffix(player)))), player.hasPermission("essentials.discord.ping"), jda.getSettings().isShowAvatar() ? jda.getSettings().getAvatarURL().replace("{uuid}", player.getUniqueId().toString()) : null, - jda.getSettings().isShowName() ? player.getName() : null, + jda.getSettings().isShowName() ? player.getName() : (jda.getSettings().isShowDisplayName() ? player.getDisplayName() : null), player.getUniqueId()); }); } @@ -149,7 +149,7 @@ public class BukkitListener implements Listener { MessageUtil.sanitizeDiscordMarkdown(message), false, jda.getSettings().isShowAvatar() ? jda.getSettings().getAvatarURL().replace("{uuid}", player.getUniqueId().toString()) : null, - jda.getSettings().isShowName() ? player.getName() : null, + jda.getSettings().isShowName() ? player.getName() : (jda.getSettings().isShowDisplayName() ? player.getDisplayName() : null), player.getUniqueId())); } @@ -180,7 +180,7 @@ public class BukkitListener implements Listener { MessageUtil.sanitizeDiscordMarkdown(event.getDeathMessage())), false, jda.getSettings().isShowAvatar() ? jda.getSettings().getAvatarURL().replace("{uuid}", event.getEntity().getUniqueId().toString()) : null, - jda.getSettings().isShowName() ? event.getEntity().getName() : null, + jda.getSettings().isShowName() ? event.getEntity().getName() : (jda.getSettings().isShowDisplayName() ? event.getEntity().getDisplayName() : null), event.getEntity().getUniqueId()); } @@ -203,7 +203,7 @@ public class BukkitListener implements Listener { MessageUtil.sanitizeDiscordMarkdown(event.getAffected().getDisplayName())), false, jda.getSettings().isShowAvatar() ? jda.getSettings().getAvatarURL().replace("{uuid}", event.getAffected().getBase().getUniqueId().toString()) : null, - jda.getSettings().isShowName() ? event.getAffected().getName() : null, + jda.getSettings().isShowName() ? event.getAffected().getName() : (jda.getSettings().isShowDisplayName() ? event.getAffected().getDisplayName() : null), event.getAffected().getBase().getUniqueId()); } @@ -219,8 +219,8 @@ public class BukkitListener implements Listener { MessageUtil.sanitizeDiscordMarkdown(event.getPlayer().getDisplayName()), event.getName()), false, - jda.getSettings().isShowAvatar() ? AVATAR_URL.replace("{uuid}", event.getPlayer().getUniqueId().toString()) : null, - jda.getSettings().isShowName() ? event.getPlayer().getName() : null, + jda.getSettings().isShowAvatar() ? jda.getSettings().getAvatarURL().replace("{uuid}", event.getPlayer().getUniqueId().toString()) : null, + jda.getSettings().isShowName() ? event.getPlayer().getName() : (jda.getSettings().isShowDisplayName() ? event.getPlayer().getDisplayName() : null), event.getPlayer().getUniqueId()); } diff --git a/EssentialsDiscord/src/main/resources/config.yml b/EssentialsDiscord/src/main/resources/config.yml index 601cc2d59..aecf5b035 100644 --- a/EssentialsDiscord/src/main/resources/config.yml +++ b/EssentialsDiscord/src/main/resources/config.yml @@ -134,6 +134,9 @@ show-avatar: false avatar-url: "https://crafthead.net/helm/{uuid}" # Whether or not player messages should show their name as the bot name in Discord. show-name: false +# Whether or not player messages should show their display-name/nickname as the bot name in Discord. +# You must disable show-name for this option to work. +show-displayname: false # Whether or not fake join and leave messages should be sent to Discord when a player toggles vanish in Minecraft. # Fake join/leave messages will be sent the same as real join and leave messages (and to the same channel).