Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public static class DataRawDatabaseInfo {
if(dataRecord.getEncoded() != null && !dataRecord.getEncoded().isEmpty()) {
Log.debug("Shop has correct encoded item type, loaded as usual.");

this.item = QuickShop.getInstance().platform().decodeStack(dataRecord.getEncoded());
this.item = sanitizeLoadedItemStack(QuickShop.getInstance().platform().decodeStack(dataRecord.getEncoded()));
this.newItem = item;

encodedLoaded = true;
Expand All @@ -364,7 +364,7 @@ public static class DataRawDatabaseInfo {
if(!encodedLoaded || this.item == null) {
Log.debug("Attempting to migrate shop to new encoded type....");

this.item = deserializeItem(dataRecord.getItem());
this.item = sanitizeLoadedItemStack(deserializeItem(dataRecord.getItem()));
this.newItem = item;
needUpdate = true;
}
Expand All @@ -383,6 +383,22 @@ public static class DataRawDatabaseInfo {
}
}

private @Nullable ItemStack sanitizeLoadedItemStack(@Nullable final ItemStack stack) {

if(stack == null) {
return null;
}
final int amount = stack.getAmount();
final int normalizedAmount = Math.max(1, Math.min(99, amount));
if(amount == normalizedAmount) {
return stack;
}
final ItemStack sanitized = stack.clone();
sanitized.setAmount(normalizedAmount);
needUpdate = true;
Copy link
Copy Markdown
Contributor

@creatorfromhell creatorfromhell Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needUpdate assignment is unnecessary.

return sanitized;
}

private @Nullable YamlConfiguration deserializeExtra(@NotNull final String extraString) {

if(CommonUtil.isEmptyString(extraString)) {
Expand Down