2424import com .viaversion .viaversion .protocols .protocol1_12to1_11_1 .data .AchievementTranslationMapping ;
2525import com .viaversion .viaversion .protocols .protocol1_9_3to1_9_1_2 .ClientboundPackets1_9_3 ;
2626import com .viaversion .viaversion .rewriter .ComponentRewriter ;
27+ import com .viaversion .viaversion .util .SerializerVersion ;
2728import java .util .logging .Level ;
2829
2930public class TranslateRewriter {
@@ -45,13 +46,7 @@ protected void handleHoverEvent(JsonObject hoverEvent) {
4546 return ;
4647 }
4748
48- String textValue ;
49- JsonElement value = hoverEvent .get ("value" );
50- if (value .isJsonObject ()) {
51- textValue = value .getAsJsonObject ().get ("text" ).getAsString ();
52- } else {
53- textValue = value .getAsJsonPrimitive ().getAsString ();
54- }
49+ String textValue = SerializerVersion .V1_9 .toComponent (hoverEvent .get ("value" )).asUnformattedString ();
5550
5651 if (AchievementTranslationMapping .get (textValue ) == null ) {
5752 JsonObject invalidText = new JsonObject ();
@@ -79,7 +74,7 @@ protected void handleHoverEvent(JsonObject hoverEvent) {
7974 typePart .addProperty ("translate" , "stats.tooltip.type.achievement" );
8075 JsonObject description = new JsonObject ();
8176 typePart .addProperty ("italic" , true );
82- description .addProperty ("translate" , value + ".desc" );
77+ description .addProperty ("translate" , textValue + ".desc" );
8378 baseArray .add (newLine );
8479 baseArray .add (description );
8580 } else if (textValue .startsWith ("stat" )) {
@@ -91,7 +86,9 @@ protected void handleHoverEvent(JsonObject hoverEvent) {
9186 hoverEvent .addProperty ("action" , "show_text" );
9287 hoverEvent .add ("value" , baseArray );
9388 } catch (Exception e ) {
94- Via .getPlatform ().getLogger ().log (Level .WARNING , "Error rewriting show_achievement: " + hoverEvent , e );
89+ if (!Via .getConfig ().isSuppressConversionWarnings () || Via .getManager ().isDebug ()) {
90+ Via .getPlatform ().getLogger ().log (Level .WARNING , "Error rewriting show_achievement: " + hoverEvent , e );
91+ }
9592 JsonObject invalidText = new JsonObject ();
9693 invalidText .addProperty ("text" , "Invalid statistic/achievement!" );
9794 invalidText .addProperty ("color" , "red" );
@@ -114,4 +111,4 @@ public static void toClient(JsonElement element) {
114111 }
115112 }
116113
117- }
114+ }
0 commit comments