Skip to content

Commit afe11dd

Browse files
committed
fix(serialization): temporary fix for the problem derived from moving the MerchantRecipeListDataType to another package
1 parent 9d31e23 commit afe11dd

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/main/java/me/voper/slimeframe/core/datatypes/MerchantRecipeListDataType.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public List<MerchantRecipe> fromPrimitive(@Nonnull byte[] bytes, @Nonnull Persis
6464

6565
List<MerchantRecipe> merchantRecipes = new ArrayList<>();
6666

67-
try (ObjectInputStream objectStream = new ObjectInputStream(new ByteArrayInputStream(bytes))) {
67+
try (ObjectInputStream objectStream = new CustomObjectInputStream(new ByteArrayInputStream(bytes))) {
6868
int recipeCount = objectStream.readInt();
6969
for (int i = 0; i < recipeCount; i++) {
7070
SerializableMerchantRecipe serializableRecipe = (SerializableMerchantRecipe) objectStream.readObject();
@@ -203,4 +203,22 @@ public static SerializableSlimefunItemStack deserialize(Map<String, Object> args
203203

204204
}
205205

206+
public static class CustomObjectInputStream extends ObjectInputStream {
207+
208+
public CustomObjectInputStream(InputStream in) throws IOException {
209+
super(in);
210+
}
211+
212+
@Override
213+
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
214+
ObjectStreamClass osc = super.readClassDescriptor();
215+
216+
if (osc.getName().equals("me.voper.slimeframe.slimefun.datatypes.MerchantRecipeListDataType$SerializableMerchantRecipe")) {
217+
osc = ObjectStreamClass.lookup(MerchantRecipeListDataType.SerializableMerchantRecipe.class);
218+
}
219+
220+
return osc;
221+
}
222+
}
223+
206224
}

0 commit comments

Comments
 (0)