mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-03-11 22:29:46 +01:00
Add config option to change discord show-avatar url (#4330)
Co-authored-by: T41US <adityakomp@gmail.com> Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
parent
3787b80286
commit
cba5063b33
@ -147,6 +147,10 @@ public class DiscordSettings implements IConf {
|
||||
return config.getBoolean("show-name", false);
|
||||
}
|
||||
|
||||
public String getAvatarURL() {
|
||||
return config.getString("avatar-url", "https://crafthead.net/helm/{uuid}");
|
||||
}
|
||||
|
||||
// General command settings
|
||||
|
||||
public boolean isCommandEnabled(String command) {
|
||||
|
@ -26,7 +26,6 @@ import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitListener implements Listener {
|
||||
private final static String AVATAR_URL = "https://crafthead.net/helm/{uuid}";
|
||||
private final JDADiscordService jda;
|
||||
|
||||
public BukkitListener(JDADiscordService jda) {
|
||||
@ -95,7 +94,7 @@ public class BukkitListener implements Listener {
|
||||
MessageUtil.sanitizeDiscordMarkdown(FormatUtil.stripEssentialsFormat(jda.getPlugin().getEss().getPermissionsHandler().getPrefix(player))),
|
||||
MessageUtil.sanitizeDiscordMarkdown(FormatUtil.stripEssentialsFormat(jda.getPlugin().getEss().getPermissionsHandler().getSuffix(player)))),
|
||||
player.hasPermission("essentials.discord.ping"),
|
||||
jda.getSettings().isShowAvatar() ? AVATAR_URL.replace("{uuid}", player.getUniqueId().toString()) : null,
|
||||
jda.getSettings().isShowAvatar() ? jda.getSettings().getAvatarURL().replace("{uuid}", player.getUniqueId().toString()) : null,
|
||||
jda.getSettings().isShowName() ? player.getName() : null,
|
||||
player.getUniqueId());
|
||||
});
|
||||
@ -111,7 +110,7 @@ public class BukkitListener implements Listener {
|
||||
MessageUtil.sanitizeDiscordMarkdown(event.getUser().getDisplayName()),
|
||||
MessageUtil.sanitizeDiscordMarkdown(event.getJoinMessage())),
|
||||
false,
|
||||
jda.getSettings().isShowAvatar() ? AVATAR_URL.replace("{uuid}", event.getUser().getBase().getUniqueId().toString()) : null,
|
||||
jda.getSettings().isShowAvatar() ? jda.getSettings().getAvatarURL().replace("{uuid}", event.getUser().getBase().getUniqueId().toString()) : null,
|
||||
jda.getSettings().isShowName() ? event.getUser().getName() : null,
|
||||
event.getUser().getBase().getUniqueId());
|
||||
}
|
||||
@ -126,7 +125,7 @@ public class BukkitListener implements Listener {
|
||||
MessageUtil.sanitizeDiscordMarkdown(event.getPlayer().getDisplayName()),
|
||||
MessageUtil.sanitizeDiscordMarkdown(event.getQuitMessage())),
|
||||
false,
|
||||
jda.getSettings().isShowAvatar() ? AVATAR_URL.replace("{uuid}", event.getPlayer().getUniqueId().toString()) : null,
|
||||
jda.getSettings().isShowAvatar() ? jda.getSettings().getAvatarURL().replace("{uuid}", event.getPlayer().getUniqueId().toString()) : null,
|
||||
jda.getSettings().isShowName() ? event.getPlayer().getName() : null,
|
||||
event.getPlayer().getUniqueId());
|
||||
}
|
||||
@ -140,7 +139,7 @@ public class BukkitListener implements Listener {
|
||||
MessageUtil.sanitizeDiscordMarkdown(event.getEntity().getDisplayName()),
|
||||
MessageUtil.sanitizeDiscordMarkdown(event.getDeathMessage())),
|
||||
false,
|
||||
jda.getSettings().isShowAvatar() ? AVATAR_URL.replace("{uuid}", event.getEntity().getUniqueId().toString()) : null,
|
||||
jda.getSettings().isShowAvatar() ? jda.getSettings().getAvatarURL().replace("{uuid}", event.getEntity().getUniqueId().toString()) : null,
|
||||
jda.getSettings().isShowName() ? event.getEntity().getName() : null,
|
||||
event.getEntity().getUniqueId());
|
||||
}
|
||||
@ -159,7 +158,7 @@ public class BukkitListener implements Listener {
|
||||
MessageUtil.sanitizeDiscordMarkdown(event.getAffected().getName()),
|
||||
MessageUtil.sanitizeDiscordMarkdown(event.getAffected().getDisplayName())),
|
||||
false,
|
||||
jda.getSettings().isShowAvatar() ? AVATAR_URL.replace("{uuid}", event.getAffected().getBase().getUniqueId().toString()) : null,
|
||||
jda.getSettings().isShowAvatar() ? jda.getSettings().getAvatarURL().replace("{uuid}", event.getAffected().getBase().getUniqueId().toString()) : null,
|
||||
jda.getSettings().isShowName() ? event.getAffected().getName() : null,
|
||||
event.getAffected().getBase().getUniqueId());
|
||||
}
|
||||
|
@ -121,6 +121,10 @@ message-types:
|
||||
|
||||
# Whether or not player messages should show their avatar as the profile picture in Discord.
|
||||
show-avatar: false
|
||||
# The URL which should be used to get the avatars of users when "show-avatar" is set to true.
|
||||
# Any URL in here should only return a proper JPEG/PNG image and nothing else.
|
||||
# To include the UUID of the player in this URL, use "{uuid}".
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user