2020package me .zetastormy .akropolis .util .text ;
2121
2222import org .bukkit .Color ;
23+ import org .jetbrains .annotations .NotNull ;
2324
2425import io .github .miniplaceholders .api .MiniPlaceholders ;
2526import net .kyori .adventure .pointer .Pointered ;
2627import net .kyori .adventure .text .Component ;
2728import net .kyori .adventure .text .minimessage .MiniMessage ;
2829import net .kyori .adventure .text .minimessage .tag .resolver .Placeholder ;
2930import net .kyori .adventure .text .minimessage .tag .resolver .TagResolver ;
31+ import net .kyori .adventure .text .minimessage .tag .standard .StandardTags ;
3032
3133public class TextUtil {
3234 private static final MiniMessage MINI_MESSAGE = MiniMessage .miniMessage ();
35+ private static final MiniMessage MINI_MESSAGE_USER_INPUT = MiniMessage .builder ().tags (
36+ TagResolver .builder ().resolvers (
37+ StandardTags .color (),
38+ StandardTags .decorations (),
39+ StandardTags .gradient (),
40+ StandardTags .hoverEvent (),
41+ StandardTags .keybind (),
42+ StandardTags .newline (),
43+ StandardTags .pride (),
44+ StandardTags .rainbow (),
45+ StandardTags .reset (),
46+ StandardTags .shadowColor (),
47+ StandardTags .sprite (),
48+ StandardTags .transition (),
49+ StandardTags .translatable (),
50+ StandardTags .translatableFallback ()
51+ ).build ()).build ();
3352
3453 private static boolean miniplaceholders = false ;
3554
@@ -56,10 +75,33 @@ public static Component parse(String message, Pointered target, TagResolver... r
5675 return MINI_MESSAGE .deserialize (message , target , resolver );
5776 }
5877
78+ public static @ NotNull Component parseUserInput (final @ NotNull String message ) {
79+ return MINI_MESSAGE_USER_INPUT .deserialize (message );
80+ }
81+
82+ public static @ NotNull Component parseUserInput (
83+ final @ NotNull String message ,
84+ final @ NotNull TagResolver resolver
85+ ) {
86+ return MINI_MESSAGE_USER_INPUT .deserialize (message , resolver );
87+ }
88+
89+ public static @ NotNull Component parseUserInput (
90+ final @ NotNull String message ,
91+ final @ NotNull Pointered target ,
92+ final @ NotNull TagResolver ... resolver
93+ ) {
94+ return MINI_MESSAGE_USER_INPUT .deserialize (message , target , resolver );
95+ }
96+
5997 public static String raw (Component message ) {
6098 return MINI_MESSAGE .serialize (message ).replaceAll ("\\ \\ <" , "<" );
6199 }
62100
101+ public static String rawUserInput (final @ NotNull Component message ) {
102+ return MINI_MESSAGE_USER_INPUT .serialize (message ).replaceAll ("\\ \\ <" , "<" );
103+ }
104+
63105 public static Component replace (Component message , String pattern , Component replacement ) {
64106 return parse (raw (message ), Placeholder .component (pattern , replacement ));
65107 }
0 commit comments