Skip to content

Commit 94f2c1c

Browse files
committed
feat: Added support for returning strings instead of
converting placeholder to component
1 parent 22a65cb commit 94f2c1c

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ Its operation would be similar to running the `/papi parse me (placeholders)` co
2222

2323
This placeholder requires two online players to work.
2424
The functioning of this placeholder depends on whether the plugin in which it is used has relational placeholder support
25+
26+
If you want to nest the result of the placeholder inside another placeholder, add the string argument.
27+
For example: `<placeholderapi_player:%player_name%:string>`
28+
29+
## Downloads
30+
31+
[![](https://raw.githubusercontent.com/Prospector/badges/master/modrinth-badge-72h-padded.png)](https://modrinth.com/plugin/miniplaceholders-placeholderapi-expansion)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
group = io.github.miniplaceholders
2-
version = 1.0.0
2+
version = 1.1.0
33
description = PlaceholderAPI-Expansion

paper/src/main/java/io/github/miniplaceholders/expansion/placeholderapi/paper/PaperPlugin.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22

33
import io.github.miniplaceholders.api.utils.LegacyUtils;
44
import me.clip.placeholderapi.PlaceholderAPI;
5+
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
56
import org.bukkit.entity.Player;
67
import org.bukkit.plugin.java.JavaPlugin;
78

89
import io.github.miniplaceholders.api.Expansion;
910
import net.kyori.adventure.text.minimessage.tag.Tag;
1011

12+
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
1113
import static net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.*;
1214

15+
@SuppressWarnings("unused")
1316
public final class PaperPlugin extends JavaPlugin {
1417

1518
@Override
@@ -25,7 +28,11 @@ public void onEnable(){
2528
argument
2629
).replace(SECTION_CHAR, AMPERSAND_CHAR);
2730

28-
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
31+
if (parseString(queue)) {
32+
return Tag.preProcessParsed(miniMessage().serialize(LegacyUtils.parsePossibleLegacy(papiParsed)));
33+
} else {
34+
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
35+
}
2936
})
3037
.audiencePlaceholder("player", (aud, queue, ctx) -> {
3138
final String argument = queue.popOr("You need to provide a placeholder").value();
@@ -34,7 +41,11 @@ public void onEnable(){
3441
argument
3542
).replace(SECTION_CHAR, AMPERSAND_CHAR);
3643

37-
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
44+
if (parseString(queue)) {
45+
return Tag.preProcessParsed(miniMessage().serialize(LegacyUtils.parsePossibleLegacy(papiParsed)));
46+
} else {
47+
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
48+
}
3849
})
3950
.relationalPlaceholder("relational", (player, toShow, queue, ctx) -> {
4051
final String argument = queue.popOr("You need to provide a placeholder").value();
@@ -44,9 +55,17 @@ public void onEnable(){
4455
argument
4556
).replace(SECTION_CHAR, AMPERSAND_CHAR);
4657

47-
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
58+
if (parseString(queue)) {
59+
return Tag.preProcessParsed(miniMessage().serialize(LegacyUtils.parsePossibleLegacy(papiParsed)));
60+
} else {
61+
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
62+
}
4863
})
4964
.build()
5065
.register();
5166
}
67+
68+
private boolean parseString(ArgumentQueue queue) {
69+
return queue.hasNext() && queue.pop().lowerValue().equals("string");
70+
}
5271
}

0 commit comments

Comments
 (0)