@@ -152,39 +152,28 @@ public Component formatLoreMultiplePlaceholders(String configName, Map<String, S
152152 return null ;
153153 }
154154
155- Pattern pattern = Pattern .compile ("\\ {([^}]+)\\ }" );
155+ Pattern pattern = Pattern .compile ("\\ {([^}]+)\\ }( \\ S*) \\ s* " );
156156 Matcher matcher = pattern .matcher (lore );
157157
158- StringBuffer result = new StringBuffer ();
159-
158+ StringBuilder result = new StringBuilder ();
159+ int lastEnd = 0 ;
160+
160161 while (matcher .find ()) {
161162 String placeholder = matcher .group (1 );
163+ String unit = matcher .group (2 );
164+
165+ result .append (lore , lastEnd , matcher .start ());
166+
162167 if (placeHoldersValues .containsKey (placeholder )) {
163- matcher .appendReplacement (result , placeHoldersValues .get (placeholder ));
164- } else {
165- // Placeholder not found in our time values, so remove it and any unit suffix
166- // Find the next non-alphanumeric character after this placeholder to remove the unit
167- int end = matcher .end ();
168- while (end < lore .length () &&
169- !Character .isWhitespace (lore .charAt (end )) &&
170- !lore .substring (end , end + 1 ).matches ("[^a-zA-Z]" )) {
171- end ++;
172- }
173-
174- matcher .appendReplacement (result , "" );
175-
176- // Remove trailing space if there is one
177- if (end < lore .length () && Character .isWhitespace (lore .charAt (end ))) {
178- // Skip this space in the next append
179- end ++;
180- }
181-
182- // Adjust region to char after skipped placeholder
183- matcher .region (end , lore .length ());
168+ result .append (placeHoldersValues .get (placeholder )).append (unit ).append (" " );
184169 }
170+
171+ // Update lastEnd to end of the match
172+ lastEnd = matcher .end ();
173+ }
174+ if (lastEnd < lore .length ()) {
175+ result .append (lore .substring (lastEnd ));
185176 }
186-
187- matcher .appendTail (result );
188177
189178 Component component ;
190179 // Clean output text
0 commit comments