22
33import io .github .miniplaceholders .api .utils .LegacyUtils ;
44import me .clip .placeholderapi .PlaceholderAPI ;
5+ import net .kyori .adventure .text .minimessage .tag .resolver .ArgumentQueue ;
56import org .bukkit .entity .Player ;
67import org .bukkit .plugin .java .JavaPlugin ;
78
89import io .github .miniplaceholders .api .Expansion ;
910import net .kyori .adventure .text .minimessage .tag .Tag ;
1011
12+ import static net .kyori .adventure .text .minimessage .MiniMessage .miniMessage ;
1113import static net .kyori .adventure .text .serializer .legacy .LegacyComponentSerializer .*;
1214
15+ @ SuppressWarnings ("unused" )
1316public 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