diff --git a/common/src/main/java/com/discordsrv/common/config/main/AvatarProviderConfig.java b/common/src/main/java/com/discordsrv/common/config/main/AvatarProviderConfig.java index 9c7561fd..bf875a74 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/AvatarProviderConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/AvatarProviderConfig.java @@ -15,5 +15,5 @@ public class AvatarProviderConfig { @Comment("The template for URLs of player avatars\n" + "This will be used for offical Java players only if auto-decide-avatar-url is set to true\n" + "This will be used ALWAYS if auto-decide-avatar-url is set to false") - public String avatarUrlTemplate = "https://crafatar.com/avatars/%uuid_nodashes%.png?size=128&overlay#%texture%"; + public String avatarUrlTemplate = "https://crafatar.com/avatars/%player_uuid_nodashes%.png?size=128&overlay#%player_texture%"; } diff --git a/common/src/main/java/com/discordsrv/common/player/IPlayer.java b/common/src/main/java/com/discordsrv/common/player/IPlayer.java index 68443101..ba0c94cf 100644 --- a/common/src/main/java/com/discordsrv/common/player/IPlayer.java +++ b/common/src/main/java/com/discordsrv/common/player/IPlayer.java @@ -19,7 +19,6 @@ package com.discordsrv.common.player; import com.discordsrv.api.placeholder.annotation.Placeholder; -import com.discordsrv.api.placeholder.util.Placeholders; import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.command.game.sender.ICommandSender; @@ -58,6 +57,17 @@ public interface IPlayer extends DiscordSRVPlayer, IOfflinePlayer, ICommandSende return identity().uuid(); } + @ApiStatus.NonExtendable + @Placeholder("player_uuid_nodashes") + default @NotNull String uniqueIdNoDashes() { + return uniqueId().toString().replace("-", ""); + } + + @Placeholder("player_texture") + default @Nullable String textureId() { + return null; // TODO: implement + } + @NotNull @Placeholder("player_display_name") Component displayName(); @@ -71,21 +81,16 @@ public interface IPlayer extends DiscordSRVPlayer, IOfflinePlayer, ICommandSende if (avatarConfig.autoDecideAvatarUrl) { // Offline mode - if (uniqueId().version() == 3) avatarUrlTemplate = "https://cravatar.eu/helmavatar/%username%/128.png#%texture%"; + if (uniqueId().version() == 3) avatarUrlTemplate = "https://cravatar.eu/helmavatar/%player_name%/128.png#%texture%"; // Bedrock - else if (uniqueId().getLeastSignificantBits() == 0) avatarUrlTemplate = "https://api.tydiumcraft.net/skin?uuid=%uuid_nodashes%&type=avatar&size=128"; + else if (uniqueId().getLeastSignificantBits() == 0) avatarUrlTemplate = "https://api.tydiumcraft.net/skin?uuid=%player_uuid_nodashes%&type=avatar&size=128"; } if (avatarUrlTemplate == null) { return null; } - return new Placeholders(avatarUrlTemplate) - .replace("%uuid%", uniqueId().toString()) - .replace("%uuid_nodashes%", uniqueId().toString().replaceAll("-", "")) - .replace("%username%", username()) - .replace("%texture%", "") // TODO - .toString(); + return discordSRV().placeholderService().replacePlaceholders(avatarUrlTemplate, this); } @Nullable