mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-10-31 08:32:18 +01:00
Make placeholders of avatar url consistent
This commit is contained in:
parent
bfd4edb6ed
commit
2f57b0d2bf
@ -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%";
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user