diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2163d66..77f3aa2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,6 +36,7 @@ jobs: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} MODRINTH: ${{ secrets.MODRINTH }} + CURSEFORGE: ${{ secrets.CURSEFORGE }} CHANGELOG: ${{ github.event.release.body }} - name: Upload GitHub release uses: AButler/upload-release-assets@v2.0 diff --git a/build.gradle b/build.gradle index 07af375..8df2ecc 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'fabric-loom' version '1.6.+' id 'maven-publish' id "com.modrinth.minotaur" version "2.+" + id 'com.matthewprenger.cursegradle' version '1.4.0' } sourceCompatibility = JavaVersion.VERSION_21 @@ -150,4 +151,33 @@ if (System.getenv("MODRINTH")) { remapJar { finalizedBy project.tasks.modrinth } +} + + +curseforge { + if (System.getenv("CURSEFORGE")) { + apiKey = System.getenv("CURSEFORGE") + + project { + id = "1037459" + releaseType = "release" + changelog = System.getenv("CHANGELOG") + changelogType = "markdown" + addGameVersion((project.minecraft_version.contains("-") ? ((String) project.minecraft_version.split("-")[0] + "-Snapshot") : project.minecraft_version)) + addGameVersion "Fabric" + addGameVersion "Quilt" + mainArtifact(remapJar) + + afterEvaluate { + uploadTask.dependsOn("remapJar") + } + } + } + + options { + forgeGradleIntegration = false + } + remapJar { + finalizedBy project.tasks.curseforge + } } \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 0649eeb..33b1aee 100644 --- a/docs/index.md +++ b/docs/index.md @@ -15,6 +15,7 @@ generators. - [Using placeholders](user/general) - [Default placeholder list](user/default-placeholders) - [Mod placeholder list](user/mod-placeholders) +- [QuickText Format](user/quicktext) - [Simplified Text Format](user/text-format) ## For developers diff --git a/docs/user/mod-placeholders.md b/docs/user/mod-placeholders.md index d3340bc..eaeddff 100644 --- a/docs/user/mod-placeholders.md +++ b/docs/user/mod-placeholders.md @@ -107,6 +107,18 @@ These placeholders are provided by other mods. Some are build in directly, while - `%styled-nicknames:display_name%` - Either nickname or default player name. (skips other formatting mods) +### [Text Placeholder API Expressions](https://modrinth.com/mod/text-placeholder-api-expr) +- `%expr:math [Math expressions and ${placeholder}s]%` - See mod page for list of available expressions and functions. +- `%expr:ifeq [aIsMath] [a] [bIsMath] [b] [cIsMath] [c] [dIsMath] [d]%` - Compare if `a` and `b` are equal, and return `c` or `d` accordingly. +- `%expr:iflt [a] [b] [cIsMath] [c] [dIsMath] [d]%` - Compare if `a` is less than `b`, and return `c` or `d` accordingly. +- `%expr:math [a] [b] [cIsMath] [c] [dIsMath] [d]%` - Compare if `a` is greater than `b`, and return `c` or `d` accordingly. +- `%expr:pad [length] [str] [c]%` - Pad both sides of `str` with `c` until it is `length` long. +- `%expr:padleft [length] [str] [c]%` - Pad left side of `str` with `c` until it is `length` long. +- `%expr:padright [length] [str] [c]%` - Pad right side of `str` with `c` until it is `length` long. +- `%expr:padmatch [match] [str] [c]%` - Pad both sides of `str` with `c` until it is the same length as `match`. +- `%expr:padmatchleft [match] [str] [c]%` - Pad left side of `str` with `c` until it is the same length as `match`. +- `%expr:padmatchright [match] [str] [c]%` - Pad right side of `str` with `c` until it is the same length as `match`. + ### [Vanish](https://modrinth.com/mod/vanish) - `%vanish:vanished%` - Displays a text (configurable via config) if a player is vanished. diff --git a/docs/user/quicktext.md b/docs/user/quicktext.md index ff44e54..db124c2 100644 --- a/docs/user/quicktext.md +++ b/docs/user/quicktext.md @@ -1,4 +1,4 @@ -# QuickText Format (Beta) +# QuickText Format !!! warn inline end @@ -169,7 +169,7 @@ There 2 types of gradients: - `#!xml `/``/`#!xml ` - It's simple rainbow gradient. All arguments are optional (`#!xml ` is still valid) and they take numbers between 0 and 1 (`0.3` for example) -### Clear (2.1.3+) +### Clear !!! note inline end diff --git a/gradle.properties b/gradle.properties index 5a441a3..299cfaf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.21-pre2 - yarn_mappings=1.21-pre2+build.2 + minecraft_version=1.21 + yarn_mappings=1.21+build.2 loader_version=0.15.11 #Fabric api - fabric_version=0.99.4+1.21 + fabric_version=0.100.1+1.21 # Mod Properties - mod_version = 2.4.0-pre.2+1.21 + mod_version = 2.4.0+1.21 maven_group = eu.pb4 archives_base_name = placeholder-api diff --git a/icon (kopia).png b/icon (kopia).png new file mode 100644 index 0000000..cd4ab94 Binary files /dev/null and b/icon (kopia).png differ diff --git a/mkdocs.yml b/mkdocs.yml index 4c56941..b1a4dad 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -10,6 +10,7 @@ nav: - user/general.md - user/default-placeholders.md - user/mod-placeholders.md + - user/quicktext.md - user/text-format.md - For Developers: - dev/getting-started.md diff --git a/src/main/java/eu/pb4/placeholders/api/arguments/StringArgs.java b/src/main/java/eu/pb4/placeholders/api/arguments/StringArgs.java index a2cbe07..de92829 100644 --- a/src/main/java/eu/pb4/placeholders/api/arguments/StringArgs.java +++ b/src/main/java/eu/pb4/placeholders/api/arguments/StringArgs.java @@ -68,7 +68,7 @@ private static int keyDecomposition(String input, int offset, char separator, ch var chrN = i != input.length() - 1 ? input.charAt(i + 1) : 0; if (chr == stopAt && wrap == 0) { break; - } else if (key != null && b.isEmpty() && hasMaps && (chr == '{' || chr == '[')) { + } else if (key != null && b.isEmpty() && hasMaps && (chr == '{' || chr == '[') && wrap == 0) { var arg = new StringArgs(""); var ti = keyDecomposition(input, i + 1, separator, map, isWrap, true, chr == '{' ? '}' : ']', (keyx, valuex) -> { @@ -87,7 +87,7 @@ private static int keyDecomposition(String input, int offset, char separator, ch key = null; i = ti; } - } else if (chr == map && key == null) { + } else if (chr == map && wrap == 0 && key == null) { key = b.toString(); b = new StringBuilder(); } else if ((chr == '\\' && chrN != 0) || (chrN != 0 && chr == chrN && isWrap.test(chr))) { diff --git a/src/main/java/eu/pb4/placeholders/impl/textparser/BuiltinTags.java b/src/main/java/eu/pb4/placeholders/impl/textparser/BuiltinTags.java index f4f73d2..e90f1de 100644 --- a/src/main/java/eu/pb4/placeholders/impl/textparser/BuiltinTags.java +++ b/src/main/java/eu/pb4/placeholders/impl/textparser/BuiltinTags.java @@ -195,9 +195,11 @@ public static void register() { TagRegistry.registerDefault(TextTag.enclosing("click", "click_action", false, (nodes, data, parser) -> { if (!data.isEmpty()) { + var type = data.getNext("type"); + var value = data.getNext("value", ""); for (ClickEvent.Action action : ClickEvent.Action.values()) { - if (action.asString().equals(data.getNext("type"))) { - return new ClickActionNode(nodes, action, new LiteralNode(data.getNext("value", ""))); + if (action.asString().equals(type)) { + return new ClickActionNode(nodes, action, new LiteralNode(value)); } } } @@ -297,9 +299,13 @@ public static void register() { true, (nodes, data, parser) -> { try { - var type = data.getNext("type", "").toLowerCase(Locale.ROOT); + var type = data.get("type"); - if (data.size() > 1) { + if (type != null || data.size() > 1) { + if (type == null) { + type = data.getNext("type", ""); + } + type = type.toLowerCase(Locale.ROOT); if (type.equals("show_text") || type.equals("text")) { return new HoverNode<>(nodes, HoverNode.Action.TEXT, parser.parseNode( data.getNext("value", "") @@ -336,7 +342,7 @@ public static void register() { return new HoverNode<>(nodes, HoverNode.Action.TEXT, parser.parseNode(data.get("value", type))); } } else { - return new HoverNode<>(nodes, HoverNode.Action.TEXT, parser.parseNode(data.get("value", type))); + return new HoverNode<>(nodes, HoverNode.Action.TEXT, parser.parseNode(data.getNext("value"))); } } catch (Exception e) { // Shut diff --git a/src/main/resources/assets/placeholderapi/lang/en_us.json b/src/main/resources/assets/placeholderapi/lang/en_us.json new file mode 100644 index 0000000..fc98560 --- /dev/null +++ b/src/main/resources/assets/placeholderapi/lang/en_us.json @@ -0,0 +1,3 @@ +{ + "modmenu.descriptionTranslation.placeholder-api": "Simple api for mods allowing for user friendly formatting and universal placeholders!" +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index d6a08ae..20b2056 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -16,8 +16,8 @@ "icon": "assets/icon.png", "environment": "*", "depends": { - "fabricloader": ">=0.13.4", - "minecraft": ">=1.19-beta.1" + "fabricloader": ">=0.15.0", + "minecraft": ">=1.21-" }, "custom": { "modmenu": { diff --git a/src/testmod/java/eu/pb4/placeholderstest/TestMod.java b/src/testmod/java/eu/pb4/placeholderstest/TestMod.java index cc2e6fe..7e1079d 100644 --- a/src/testmod/java/eu/pb4/placeholderstest/TestMod.java +++ b/src/testmod/java/eu/pb4/placeholderstest/TestMod.java @@ -167,7 +167,7 @@ private static int test3(CommandContext context) { TextNode.asSingle( MarkdownLiteParserV1.ALL.parseNodes( TextNode.asSingle( - TextParserV1.DEFAULT.parseNodes(new LiteralNode(context.getArgument("text", String.class))) + TagParser.DEFAULT.parseNodes(new LiteralNode(context.getArgument("text", String.class))) ) ) )