2121
2222import lombok .AllArgsConstructor ;
2323import net .md_5 .bungee .api .chat .*;
24+ import net .md_5 .bungee .chat .ComponentSerializer ;
2425import org .apache .commons .lang .StringUtils ;
2526import org .bukkit .ChatColor ;
2627import org .bukkit .command .CommandSender ;
@@ -83,16 +84,22 @@ public void sendItemHologramChat(@NotNull Player player, @NotNull String text, @
8384 ComponentBuilder builder = new ComponentBuilder ();
8485 TextSplitter .SpilledString spilledString = TextSplitter .deBakeItem (text );
8586 if (spilledString == null ) {
87+ Util .debugLog ("Spilled string is null" );
8688 builder .append (text );
8789 } else {
90+ Util .debugLog ("Building component..." );
8891 builder .append (spilledString .getLeft ())
8992 .append (spilledString .getComponents ())
9093 .append (spilledString .getRight ());
94+ Util .debugLog ("Left is " + spilledString .getLeft ());
95+ Util .debugLog ("Right is " + spilledString .getRight ());
96+ Util .debugLog ("Component is " + ComponentSerializer .toString (spilledString .getComponents ()));
97+ Util .debugLog ("Success..." );
9198 }
92- TextComponent centerItem = new TextComponent ( builder .create ());
93- ComponentBuilder cBuilder = new ComponentBuilder ( json );
94- centerItem . setHoverEvent ( new HoverEvent ( HoverEvent . Action . SHOW_ITEM , cBuilder . create ())); //FIXME: Update this when drop 1.15 supports
95- player .spigot ().sendMessage (centerItem );
99+ builder . event ( new HoverEvent ( HoverEvent . Action . SHOW_ITEM , new ComponentBuilder ( json ) .create () ));
100+ BaseComponent [] components = builder . create ( );
101+ Util . debugLog ( "Sending debug: " + ComponentSerializer . toString ( components ));
102+ player .spigot ().sendMessage (components );
96103 } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | InstantiationException e ) {
97104 plugin .getLogger ().log (Level .WARNING , "Failed to process chat component" , e );
98105 player .spigot ().sendMessage (errorComponent );
@@ -103,33 +110,38 @@ public void sendItemHologramChat(@NotNull Player player, @NotNull String text, @
103110 public @ NotNull QuickComponent getItemHologramChat (@ NotNull Shop shop , @ NotNull ItemStack itemStack , @ NotNull Player player , @ NotNull String message ) {
104111 TextComponent errorComponent = new TextComponent (plugin .text ().of (player , "menu.item-holochat-error" ).forLocale ());
105112 try {
106-
107113 String json = ReflectFactory .convertBukkitItemStackToJson (itemStack );
108114 if (json == null ) {
109115 return new QuickComponentImpl (errorComponent );
110116 }
111117 ComponentBuilder builder = new ComponentBuilder ();
112118 TextSplitter .SpilledString spilledString = TextSplitter .deBakeItem (message );
113119 if (spilledString == null ) {
120+ Util .debugLog ("Spilled string is null" );
114121 builder .append (message );
115122 } else {
123+ Util .debugLog ("Building component..." );
116124 builder .append (spilledString .getLeft ())
117125 .append (spilledString .getComponents ())
118126 .append (spilledString .getRight ());
127+ Util .debugLog ("Left is " + spilledString .getLeft ());
128+ Util .debugLog ("Right is " + spilledString .getRight ());
129+ Util .debugLog ("Component is " + ComponentSerializer .toString (spilledString .getComponents ()));
130+ Util .debugLog ("Success..." );
119131 }
132+
120133 builder .append (" " )
121134 .append (plugin .text ().of (player , "menu.preview" ).forLocale ());
122- TextComponent normalmessage = new TextComponent (builder .create ());
123- ComponentBuilder cBuilder = new ComponentBuilder (json );
135+ // builder.event(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ComponentBuilder(json).create()));
124136 if (QuickShop .getPermissionManager ().hasPermission (player , "quickshop.preview" )) {
125- normalmessage . setClickEvent (new ClickEvent (
137+ builder . event (new ClickEvent (
126138 ClickEvent .Action .RUN_COMMAND ,
127139 MsgUtil .fillArgs (
128140 "/qs silentpreview {0}" ,
129141 shop .getRuntimeRandomUniqueId ().toString ())));
130142 }
131- normalmessage . setHoverEvent (new HoverEvent (HoverEvent .Action .SHOW_ITEM , cBuilder .create ())); //FIXME: Update this when drop 1.15 supports
132- return new QuickComponentImpl (normalmessage );
143+ builder . event (new HoverEvent (HoverEvent .Action .SHOW_ITEM , new ComponentBuilder ( json ) .create ()));
144+ return new QuickComponentImpl (builder . create () );
133145 } catch (Throwable t ) {
134146 plugin .getLogger ().log (Level .WARNING , "Failed to process chat component" , t );
135147 return new QuickComponentImpl (errorComponent );
0 commit comments