Skip to content

Commit c376f38

Browse files
authored
Merge pull request #147 from litetex-oss/dev
Release
2 parents 6b87f9b + 02c44dd commit c376f38

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
* [Modrinth](https://modrinth.com/mod/${{ steps.metadata.outputs.archivesBaseName }})
118118
* the GitHub release assets below
119119
* [Maven Central](https://repo.maven.apache.org/maven2/net/litetex/mcm/)
120-
${{ (steps.check-for-curseforge.outputs.has) && format('[CurseForge](https://www.curseforge.com/minecraft/mc-mods/{0})', steps.metadata.outputs.archivesBaseName) || '' }}
120+
${{ (steps.check-for-curseforge.outputs.has) && format('* [CurseForge](https://www.curseforge.com/minecraft/mc-mods/{0})', steps.metadata.outputs.archivesBaseName) || '' }}
121121
122122
publish:
123123
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 4.0.2
2+
* Fixed: `$` inside `fabric.mod.json` is usually replaced by the build process #145
3+
* Added a note that this may require escaping using a `\`
4+
* Made it possible to use `§` instead of `$`
5+
* Updated the demo accordingly
6+
17
# 4.0.1
28
* Made animated GIF decoding more reliable
39
* This should fix broken textures #135

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ Here's a simple implementation:
9696
"cape": {
9797
// Gives everyone a christmas cape
9898
// You can also use variables here, like $uuid. See above for more details
99+
// You may have to escape the $ with \ or you can alternatively use § instead of $
99100
// Alternative: "uriTemplate"
100-
"url": "https://raw.githubusercontent.com/litetex-oss/mcm-cape-provider/refs/heads/dev/custom-cape-demo/uuid.png",
101+
"url": "https://example.org/textures/§uuid.png",
101102
"changeCapeUrl": "https://...",
102103
"rateLimitedReqPerSec": 20 // Default is 20
103104
}

src/main/java/net/litetex/capes/provider/CustomProvider.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,30 @@ public String name()
3939
@Override
4040
public String getBaseUrl(final GameProfile profile)
4141
{
42-
return this.config.uriTemplate()
43-
.replace("$name", profile.getName())
44-
.replace("$id", profile.getId().toString())
45-
.replace("$idNoHyphen", profile.getId().toString().replace("-", ""));
42+
final String idString = profile.getId().toString();
43+
String uriTemplate = this.config.uriTemplate();
44+
if(uriTemplate.indexOf('$') != -1)
45+
{
46+
uriTemplate = this.fillInTemplate(uriTemplate, '$', idString, profile);
47+
}
48+
else if(uriTemplate.indexOf('§') != -1)
49+
{
50+
uriTemplate = this.fillInTemplate(uriTemplate, '§', idString, profile);
51+
}
52+
53+
return uriTemplate;
54+
}
55+
56+
protected String fillInTemplate(
57+
final String uriTemplate,
58+
final char prefix,
59+
final String idString,
60+
final GameProfile profile)
61+
{
62+
return uriTemplate
63+
.replace(prefix + "name", profile.getName())
64+
.replace(prefix + "id", idString)
65+
.replace(prefix + "idNoHyphen", idString.replace("-", ""));
4666
}
4767

4868
@Override

0 commit comments

Comments
 (0)