File tree Expand file tree Collapse file tree 3 files changed +14
-7
lines changed
v1_21_11/src/main/java/net/azisaba/loreeditor/v1_21_11 Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ plugins {
88
99allprojects {
1010 group = " net.azisaba.loreeditor"
11- version = " 1.3.2 "
11+ version = " 1.3.3 "
1212
1313 apply {
1414 plugin(" java" )
@@ -76,7 +76,9 @@ allprojects {
7676 shadowJar {
7777 relocate(" xyz.acrylicstyle.util" , " net.azisaba.loreeditor.libs.xyz.acrylicstyle.util" )
7878 relocate(" net.kyori" , " net.azisaba.loreeditor.libs.net.kyori" )
79- relocate(" com.google.gson" , " net.azisaba.loreeditor.libs.com.google.gson" )
79+ // exclude gson
80+ exclude(" com/google/gson/**" )
81+ // relocate("com.google.gson", "net.azisaba.loreeditor.libs.com.google.gson")
8082 archiveBaseName.set(" LoreEditor-${project.name} " )
8183 }
8284 }
Original file line number Diff line number Diff line change 11package net .azisaba .loreeditor .v1_21_11 .chat ;
22
33import com .google .gson .Gson ;
4+ import com .google .gson .JsonObject ;
45import com .mojang .serialization .JsonOps ;
56import net .azisaba .loreeditor .common .chat .ChatModifier ;
67import net .azisaba .loreeditor .common .chat .Component ;
@@ -36,7 +37,7 @@ public ComponentImpl(@Nullable net.minecraft.network.chat.Component handle) {
3637 }
3738
3839 public static MutableComponent deserializeFromJson (@ NotNull String input ) {
39- return ComponentSerialization .CODEC .decode (JsonOps .INSTANCE , GSON .toJsonTree (input )).getOrThrow ().getFirst ().copy ();
40+ return ComponentSerialization .CODEC .decode (JsonOps .INSTANCE , GSON .fromJson (input , JsonObject . class )).getOrThrow ().getFirst ().copy ();
4041 }
4142
4243 public static String serializeToJson (@ NotNull net .minecraft .network .chat .Component component ) {
Original file line number Diff line number Diff line change 1010import net .minecraft .core .component .DataComponentMap ;
1111import net .minecraft .core .component .DataComponents ;
1212import net .minecraft .nbt .StringTag ;
13+ import net .minecraft .nbt .StringTagVisitor ;
1314import net .minecraft .network .chat .Component ;
1415import net .minecraft .world .item .component .CustomData ;
1516import net .minecraft .world .item .component .ItemLore ;
@@ -96,11 +97,14 @@ public void setTag(@Nullable CompoundTag tag) {
9697 ((ListTagImpl ) listTag ).getHandle ()
9798 .stream ()
9899 .map (t -> {
99- if (t instanceof StringTag ) {
100- return t .asString ().orElse ("" );
101- } else {
102- return t .toString ();
100+ StringTagVisitor visitor = new StringTagVisitor ();
101+ t .accept (visitor );
102+ String json = visitor .build ();
103+ // strip a single quote around JSON, if any
104+ if (json .startsWith ("'" ) && json .endsWith ("'" )) {
105+ json = json .substring (1 , json .length () - 1 );
103106 }
107+ return json ;
104108 })
105109 .map (ComponentImpl ::deserializeFromJson )
106110 .collect (Collectors .toUnmodifiableList ());
You can’t perform that action at this time.
0 commit comments