9 changes: 5 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/actions/wrapper-validation@v3
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'microsoft'
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: 3.x

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
key: ${{ github.ref }}
path: .cache
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: |
~/.gradle/loom-cache
Expand All @@ -20,11 +20,12 @@ jobs:
key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'microsoft'

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand All @@ -39,7 +40,7 @@ jobs:
CURSEFORGE: ${{ secrets.CURSEFORGE }}
CHANGELOG: ${{ github.event.release.body }}
- name: Upload GitHub release
uses: AButler/upload-release-assets@v2.0
uses: AButler/upload-release-assets@v3.0
with:
files: 'build/libs/*.jar;!build/libs/*-sources.jar;!build/libs/*-dev.jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6.+'
id 'fabric-loom' version '1.7.+'
id 'maven-publish'
id "com.modrinth.minotaur" version "2.+"
id 'com.matthewprenger.cursegradle' version '1.4.0'
Expand Down
3 changes: 3 additions & 0 deletions docs/user/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ and [placeholders from mods here](/user/mod-placeholders).
[Modrinth](https://modrinth.com/mod/discord4fabric),
[Github](https://github.com/Reimnop/Discord4Fabric)

- Fuji -
[Modrinth](https://modrinth.com/mod/fuji),
[Github](https://github.com/sakurawald/fuji-fabric/)
15 changes: 15 additions & 0 deletions docs/user/mod-placeholders.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ These placeholders are provided by other mods. Some are build in directly, while
- `%afkplus:invulnerable%` - Returns a basic tag to display the status if a player is marked as "invulnerable" using the "disableDamage"
features. It is also used internally under the default "[AFK]" tag method, with "[AFK:I]", for example.

### [Fuji](https://modrinth.com/mod/fuji)
- `%fuji:player_mined%` - Sum of mining blocks of a player.
- `%fuji:server_mined%` - Sum of mining blocks of a server.
- `%fuji:player_placed%` - Sum of placed blocks of a player.
- `%fuji:server_placed%` - Sum of placed blocks of a server.
- `%fuji:player_killed%` - Sum of killed entities of a player.
- `%fuji:server_killed%` - Sum of killed entities of a server.
- `%fuji:player_moved%` - Sum of moved distance of a player.
- `%fuji:server_moved%` - Sum of moved distance of a server.
- `%fuji:player_playtime%` - Sum of playtime of a player.
- `%fuji:server_playtime%` - Sum of playtime of a server.
- `%fuji:item%` - Create the display of main-hand item.
- `%fuji:inv%` - Create the display of inventory.
- `%fuji:ender%` - Create the display of ender-chest.

### [Get Off My Lawn ReServed](https://pb4.eu/#get-off-my-lawn)

- `%goml:claim_owners%`/`%goml:claim_owners [no owners text]%` - Returns a list of claim owners.
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11
minecraft_version=1.21.2-rc1
yarn_mappings=1.21.2-rc1+build.1
loader_version=0.16.7

#Fabric api
fabric_version=0.100.1+1.21
fabric_version=0.105.4+1.21.2

# Mod Properties
mod_version = 2.4.1+1.21
mod_version = 2.5.0+1.21.2
maven_group = eu.pb4
archives_base_name = placeholder-api

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ public static PlaceholderContext of(Entity entity, ViewObject view) {
if (entity instanceof ServerPlayerEntity player) {
return of(player, view);
} else {
return new PlaceholderContext(entity.getServer(), entity::getCommandSource, (ServerWorld) entity.getWorld(), null, entity, null, view);
var world = (ServerWorld) entity.getWorld();
return new PlaceholderContext(entity.getServer(), () -> entity.getCommandSource(world), world, null, entity, null, view);
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/main/java/eu/pb4/placeholders/api/node/ScoreNode.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package eu.pb4.placeholders.api.node;

import com.mojang.datafixers.util.Either;
import eu.pb4.placeholders.api.ParserContext;
import net.minecraft.text.ParsedSelector;
import net.minecraft.text.Text;

public record ScoreNode(String name, String objective) implements TextNode {
public record ScoreNode(Either<ParsedSelector, String> name, String objective) implements TextNode {

public ScoreNode(String name, String objective) {
this(ParsedSelector.parse(name).result()
.map(Either::<ParsedSelector, String>left).orElse(Either.right(name)), objective);
}

@Override
public Text toText(ParserContext context, boolean removeBackslashes) {
return Text.score(name, objective);
return name.map(selector -> Text.score(selector, objective), name -> Text.score(name, objective));
}
}
5 changes: 3 additions & 2 deletions src/main/java/eu/pb4/placeholders/api/node/SelectorNode.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package eu.pb4.placeholders.api.node;

import eu.pb4.placeholders.api.ParserContext;
import net.minecraft.text.ParsedSelector;
import net.minecraft.text.Text;

import java.util.Optional;

public record SelectorNode(String pattern, Optional<TextNode> separator) implements TextNode {
public record SelectorNode(ParsedSelector selector, Optional<TextNode> separator) implements TextNode {
@Override
public Text toText(ParserContext context, boolean removeBackslashes) {
return Text.selector(pattern, separator.map(x -> x.toText(context, removeBackslashes)));
return Text.selector(selector, separator.map(x -> x.toText(context, removeBackslashes)));
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/eu/pb4/placeholders/impl/GeneralUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ public static ParentNode convertToNodes(Text input) {

list.add(TranslatedNode.ofFallback(content.getKey(), content.getFallback(), args.toArray()));
} else if (input.getContent() instanceof ScoreTextContent content) {
list.add(new ScoreNode(content.getName(), content.getObjective()));
list.add(new ScoreNode(content.name(), content.objective()));
} else if (input.getContent() instanceof KeybindTextContent content) {
list.add(new KeybindNode(content.getKey()));
} else if (input.getContent() instanceof SelectorTextContent content) {
list.add(new SelectorNode(content.getPattern(), content.getSeparator().map(GeneralUtils::convertToNodes)));
list.add(new SelectorNode(content.selector(), content.separator().map(GeneralUtils::convertToNodes)));
} else if (input.getContent() instanceof NbtTextContent content) {
list.add(new NbtNode(content.getPath(), content.shouldInterpret(), content.getSeparator().map(GeneralUtils::convertToNodes), content.getDataSource()));
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/eu/pb4/placeholders/impl/color/OkLab.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package eu.pb4.placeholders.impl.color;

import eu.pb4.placeholders.impl.GeneralUtils;

import net.minecraft.util.math.ColorHelper;
import net.minecraft.util.math.MathHelper;

// https://bottosson.github.io/posts/oklab/
public record OkLab(float l, float a, float b) {
public static OkLab fromRgb(int rgb) {
return fromLinearSRGB(ColorHelper.Argb.getRed(rgb) / 255f, ColorHelper.Argb.getGreen(rgb) / 255f,
ColorHelper.Argb.getBlue(rgb) / 255f);
return fromLinearSRGB(ColorHelper.getRed(rgb) / 255f, ColorHelper.getGreen(rgb) / 255f,
ColorHelper.getBlue(rgb) / 255f);
}


Expand Down
2 changes: 0 additions & 2 deletions src/main/java/eu/pb4/placeholders/impl/color/OkLch.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package eu.pb4.placeholders.impl.color;

import eu.pb4.placeholders.impl.GeneralUtils;
import net.minecraft.util.math.ColorHelper;
import net.minecraft.util.math.MathHelper;

// https://bottosson.github.io/posts/oklab/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,11 @@ public static void register() {
var sel = data.getNext("pattern", "@p");
var arg = data.getNext("separator");

return new SelectorNode(sel, arg != null ? Optional.of(TextNode.of(arg)) : Optional.empty());
Optional<ParsedSelector> selector = ParsedSelector.parse(sel).result();
if (selector.isEmpty()) {
return TextNode.empty();
}
return new SelectorNode(selector.get(), arg != null ? Optional.of(TextNode.of(arg)) : Optional.empty());
}
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,15 @@ public static void register() {
"special",
false, (tag, data, input, handlers, endAt) -> {
String[] lines = data.split(":");
String pattern = restoreOriginalEscaping(cleanArgument(lines[0]));
Optional<ParsedSelector> optional = ParsedSelector.parse(pattern).result();
if (optional.isEmpty()) {
return TextParserV1.TagNodeValue.EMPTY;
}
if (lines.length == 2) {
return new TextParserV1.TagNodeValue(new SelectorNode(restoreOriginalEscaping(cleanArgument(lines[0])), Optional.of(TextNode.asSingle(recursiveParsing(restoreOriginalEscaping(cleanArgument(lines[1])), handlers, null).nodes()))), 0);
return new TextParserV1.TagNodeValue(new SelectorNode(optional.get(), Optional.of(TextNode.asSingle(recursiveParsing(restoreOriginalEscaping(cleanArgument(lines[1])), handlers, null).nodes()))), 0);
} else if (lines.length == 1) {
return new TextParserV1.TagNodeValue(new SelectorNode(restoreOriginalEscaping(cleanArgument(lines[0])), Optional.empty()), 0);
return new TextParserV1.TagNodeValue(new SelectorNode(optional.get(), Optional.empty()), 0);
}
return TextParserV1.TagNodeValue.EMPTY;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"environment": "*",
"depends": {
"fabricloader": ">=0.15.0",
"minecraft": ">=1.21-"
"minecraft": ">=1.21.2-alpha.24.33.a"
},
"custom": {
"modmenu": {
Expand Down