Skip to content

Commit 8bcf03d

Browse files
authored
Discord: Add PAPI support to avatar-url (#6189)
Closes #6160
1 parent 689c35f commit 8bcf03d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

EssentialsDiscord/src/main/java/net/essentialsx/discord/util/DiscordUtil.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,14 @@ public static boolean matchesRole(Role role, String roleDefinition) {
219219
}
220220

221221
public static String getAvatarUrl(final JDADiscordService jda, final Player player) {
222-
return jda.getSettings().getAvatarURL().replace("{uuid}", player.getUniqueId().toString()).replace("{name}", player.getName());
222+
final String format = jda.getSettings().getAvatarURL();
223+
final String filled;
224+
if (jda.getPlugin().isPAPI() && format != null) {
225+
filled = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, format);
226+
} else {
227+
filled = format;
228+
}
229+
return filled.replace("{uuid}", player.getUniqueId().toString()).replace("{name}", player.getName());
223230
}
224231

225232
public static void dispatchDiscordMessage(final JDADiscordService jda, final MessageType messageType, final String message, final boolean allowPing, final String avatarUrl, final String name, final UUID uuid) {

EssentialsDiscord/src/main/resources/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ discord-url: "https://discord.gg/invite-code"
2222

2323
# Defined text channels
2424
# =====================
25-
#
25+
#
2626
# Channels defined here can be used for two different purposes:
2727
#
2828
# Firstly, channels defined here can be used to give players permission to see messages from said channel.
@@ -163,6 +163,7 @@ show-avatar: false
163163
# Any URL in here should only return a proper JPEG/PNG image and nothing else.
164164
# To include the UUID of the player in this URL, use "{uuid}".
165165
# To include the name of the player in this URL, use "{name}".
166+
# ... PlaceholderAPI placeholders are also supported here too!
166167
avatar-url: "https://crafthead.net/helm/{uuid}"
167168

168169
# Whether or not fake join and leave messages should be sent to Discord when a player toggles vanish in Minecraft.

0 commit comments

Comments
 (0)