Skip to content

Commit 4e8b375

Browse files
committed
Fix ItemStackUtils null cloning
1 parent 02afe45 commit 4e8b375

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/main/java/cat/nyaa/nyaacore/utils/ItemStackUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ public static List<ItemStack> itemsFromBase64(String base64) {
248248
if (base64 == null) throw new IllegalArgumentException();
249249
base64 = sanitizeBase64(base64);
250250
List<ItemStack> stack = itemDeserializerCache.getIfPresent(base64);
251-
if (stack != null) return stack.stream().map(ItemStack::clone).collect(Collectors.toList());
251+
if (stack != null) {
252+
return stack.stream().map(item -> item == null ? null : item.clone()).collect(Collectors.toList());
253+
}
252254
if (base64.length() <= 0) return new ArrayList<>();
253255

254256
byte[] uncompressedBinary = decompress(BaseEncoding.base64().decode(base64));
@@ -267,7 +269,7 @@ public static List<ItemStack> itemsFromBase64(String base64) {
267269
} catch (IOException ex) {
268270
throw new RuntimeException(ex);
269271
}
270-
itemDeserializerCache.put(base64, ret.stream().map(ItemStack::clone).collect(Collectors.toList()));
272+
itemDeserializerCache.put(base64, ret.stream().map(item -> item == null ? null : item.clone()).collect(Collectors.toList()));
271273
return ret;
272274
}
273275

0 commit comments

Comments
 (0)