3535import com .loohp .interactivechat .utils .ComponentCompacting ;
3636import com .loohp .interactivechat .utils .ComponentFlattening ;
3737import com .loohp .interactivechat .utils .ComponentReplacing ;
38+ import com .loohp .interactivechat .utils .ComponentStyling ;
3839import com .loohp .interactivechat .utils .ComponentUtils ;
3940import com .loohp .interactivechat .utils .FilledMapUtils ;
4041import com .loohp .interactivechat .utils .HashUtils ;
@@ -222,13 +223,18 @@ public static Component createItemDisplay(OfflineICPlayer player, ItemStack item
222223 for (Component child : flattened ) {
223224 if (child instanceof TextComponent ) {
224225 TextComponent text = (TextComponent ) child ;
225- cleaned .add (text .content (ChatColorUtils .stripColor (text .content ())));
226+ cleaned .add (text .content (ChatColorUtils .escapeMiniMessageTags ( ChatColorUtils . stripColor (text .content () ))));
226227 } else {
227228 cleaned .add (child );
228229 }
229230 }
230231 itemDisplayNameComponent = ComponentCompacting .optimize (Component .empty ().children (cleaned ));
231232
233+ ItemStack hoverItem = (trimmedItem == null ? item : trimmedItem ).clone ();
234+ if (itemMeta != null && itemMeta .hasDisplayName ()) {
235+ NMS .getInstance ().setItemStackDisplayName (hoverItem , ComponentStyling .stripColor (itemDisplayNameComponent ));
236+ }
237+
232238 amountString = String .valueOf (itemAmount );
233239 Key key = ItemNBTUtils .getNMSItemStackNamespacedKey (item );
234240
@@ -237,12 +243,12 @@ public static Component createItemDisplay(OfflineICPlayer player, ItemStack item
237243 if (item .getType ().equals (Material .AIR )) {
238244 showHover = false ;
239245 }
240- Map <Key , DataComponentValue > dataComponents = ItemNBTUtils .getNMSItemStackDataComponents (trimmedItem == null ? item : trimmedItem );
246+ Map <Key , DataComponentValue > dataComponents = ItemNBTUtils .getNMSItemStackDataComponents (hoverItem );
241247 dataComponents .remove (Key .key ("minecraft" , "container" ));
242248 dataComponents .remove (Key .key ("minecraft" , "bundle_contents" ));
243249 showItem = dataComponents .isEmpty () ? ShowItem .showItem (key , itemAmount ) : ShowItem .showItem (key , itemAmount , dataComponents );
244250 } else {
245- String tag = ItemNBTUtils .getNMSItemStackTag (trimmedItem == null ? item : trimmedItem );
251+ String tag = ItemNBTUtils .getNMSItemStackTag (hoverItem );
246252 showItem = tag == null ? ShowItem .showItem (key , itemAmount ) : ShowItem .showItem (key , itemAmount , BinaryTagHolder .binaryTagHolder (tag ));
247253 }
248254
0 commit comments