@@ -57,8 +57,8 @@ public class TriggerEditorList extends OptionList {
5757 private boolean restyle ;
5858 private MultiLineTextField textDisplayField ;
5959 private String displayText = "" ;
60- private TextField keyDisplayField ;
61- private String displayKey = "" ;
60+ private MultiLineTextField keyDisplayField ;
61+ private String displayKeys = "" ;
6262
6363 public TriggerEditorList (
6464 Minecraft mc ,
@@ -116,13 +116,17 @@ protected void addEntries() {
116116 ));
117117
118118 // Key display field
119- keyDisplayField = new TextField (dynWideEntryX , 0 , dynWideEntryWidth , entryHeight );
120- keyDisplayField .setMaxLength (256 );
121- keyDisplayField .setValue (displayKey );
122- addEntry (new Entry .DisplayField (
119+ keyDisplayField = new MultiLineTextField (
123120 dynWideEntryX ,
121+ 0 ,
124122 dynWideEntryWidth ,
125- entryHeight ,
123+ entryHeight
124+ );
125+ keyDisplayField .setValue (displayKeys );
126+ addSpacedEntry (new Entry .DisplayField (
127+ dynWideEntryX ,
128+ dynWideEntryWidth ,
129+ entryHeight + itemHeight ,
126130 keyDisplayField ,
127131 localized ("option" , "notif.trigger.editor.display.key" )
128132 ));
@@ -141,9 +145,9 @@ private void setTextDisplayValue(String text) {
141145 textDisplayField .setValue (displayText );
142146 }
143147
144- private void setKeyDisplayValue (String key ) {
145- displayKey = key ;
146- keyDisplayField .setValue (displayKey );
148+ private void setKeyDisplayValue (String keys ) {
149+ displayKeys = keys ;
150+ keyDisplayField .setValue (displayKeys );
147151 }
148152
149153 // Chat message list
@@ -157,6 +161,7 @@ private void addChatMessages(List<Component> recentChat) {
157161 for (Component msg : recentChat ) {
158162 Component restyledMsg = msg .copy ();
159163 Matcher matcher = null ;
164+ Component keyMatch = null ;
160165 String msgStr = FormatUtil .stripCodes (msg .getString ());
161166 boolean hit = switch (trigger .type ) {
162167 case NORMAL -> {
@@ -171,7 +176,10 @@ private void addChatMessages(List<Component> recentChat) {
171176 yield false ;
172177 }
173178 }
174- case KEY -> MessageUtil .keySearch (msg , trigger .string );
179+ case KEY -> {
180+ keyMatch = MessageUtil .keySearch (msg , trigger .string );
181+ yield keyMatch != null ;
182+ }
175183 };
176184 if (filter && !hit )
177185 continue ;
@@ -184,8 +192,15 @@ else if (restyle && hit) {
184192 trigger .styleTarget .tryParseIndexes ();
185193 }
186194 }
187- restyledMsg =
188- StyleUtil .restyle (msg , msgStr , trigger , matcher , textStyle , restyleAll );
195+ restyledMsg = StyleUtil .restyle (
196+ msg ,
197+ msgStr ,
198+ trigger ,
199+ matcher ,
200+ keyMatch ,
201+ textStyle ,
202+ restyleAll
203+ );
189204 }
190205 displayChat .add (new Pair <>(msg , restyledMsg ));
191206 }
@@ -271,10 +286,10 @@ private static class TriggerOptions extends Entry {
271286 triggerField .regexValidator ();
272287 triggerField .setValueListener ((str ) -> {
273288 trigger .string = str .strip ();
274- if (list .children ().size () > 4 ) {
289+ if (list .children ().size () > 5 ) {
275290 list .children ().removeIf ((entry ) -> entry instanceof MessageEntry
276291 || entry instanceof Text
277- || (entry instanceof Space && list .children ().indexOf (entry ) > 4 ));
292+ || (entry instanceof Space && list .children ().indexOf (entry ) > 5 ));
278293 list .addChatMessages (list .recentChat );
279294 }
280295 });
@@ -503,12 +518,26 @@ private static class MessageEntry extends Entry {
503518 @ Override
504519 public boolean mouseClicked (double mouseX , double mouseY , int button ) {
505520 list .setTextDisplayValue (FormatUtil .stripCodes (msg .getString ()));
506- list .setKeyDisplayValue (msg .getContents () instanceof TranslatableContents tc
507- ? tc .getKey ()
508- : localized ("option" , "notif.trigger.editor.display.key.none" ).getString ());
521+
522+ List <String > keys = new ArrayList <>();
523+ getKeys (msg , keys );
524+ list .setKeyDisplayValue (keys .isEmpty ()
525+ ? localized ("option" , "notif.trigger.editor.display.key.none" ).getString ()
526+ : String .join ("\n " , keys ));
527+
509528 list .setScrollAmount (0 );
510529 return true ;
511530 }
531+
532+ private static void getKeys (Component msg , List <String > keys ) {
533+ if (msg .getContents () instanceof TranslatableContents tc ) {
534+ keys .add (tc .getKey ());
535+ }
536+
537+ for (Component sibling : msg .getSiblings ()) {
538+ getKeys (sibling , keys );
539+ }
540+ }
512541 }
513542 }
514543}
0 commit comments