[FEAT] Way to get the real player name and avatar in Server embeds

This commit is contained in:
2024-01-02 03:43:48 +02:00
parent a343acd8aa
commit 6f41ae26bc
3 changed files with 17 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
version_major=0
version_minor=0
version_patch=57
version_patch=58
shade_group=com.hypherionmc.sdlink.shaded.

View File

@@ -36,6 +36,10 @@ public class DiscordAuthor {
@Getter
private GameProfile profile = null;
@Getter String realPlayerAvatar = "";
@Getter String realPlayerName = "";
/**
* Internal. Use {@link #of(String, String, String)}
*
@@ -78,6 +82,16 @@ public class DiscordAuthor {
);
}
public DiscordAuthor setPlayerAvatar(String usr, String userid) {
realPlayerAvatar = SDLinkConfig.INSTANCE.chatConfig.playerAvatarType.resolve(SDLinkPlatform.minecraftHelper.isOnlineMode() ? userid : usr);
return this;
}
public DiscordAuthor setPlayerName(String name) {
this.realPlayerName = name;
return this;
}
public DiscordAuthor setGameProfile(GameProfile profile) {
this.profile = profile;
this.username = profile.getName();

View File

@@ -173,6 +173,8 @@ public final class DiscordMessage {
.replace("%author%", this.author.getDisplayName())
.replace("%avatar%", this.author.getAvatar())
.replace("%message_contents%", this.message)
.replace("%player_avatar%", this.author.getRealPlayerAvatar())
.replace("%player_name%", this.author.getRealPlayerName())
.replace("%username%", this.author.getUsername());
DataObject object = DataObject.fromJson(embedJson);