diff --git a/data/products.example.lua b/data/products.example.lua index f083013..3e632af 100644 --- a/data/products.example.lua +++ b/data/products.example.lua @@ -5,4 +5,11 @@ id = "minecraft:emerald", metaname = "mald", }, + { + displayName = "Mending", + price = 1, + id = "minecraft:enchanted_book", + metaname = "mend", + nbt = "704a1bcdf9953c791651a77b1fe78891", + } } diff --git a/src/backend.lua b/src/backend.lua index 6c4e3ee..922e164 100644 --- a/src/backend.lua +++ b/src/backend.lua @@ -128,12 +128,12 @@ logger:debug("Amount: " .. amount .. " Change: " .. change) - local itemsInStock = storage.getCount(product.id) + local itemsInStock = storage.getCount(product.id, product.nbt) logger:debug("Managed to get stock: " .. itemsInStock) if amount > itemsInStock then logger:info("Not enough in stock. Refunding") - logger:debug("Stock for " .. product.id .. " was " .. itemsInStock .. ", requested " .. amount) + logger:debug("Stock for " .. product.displayName .. " was " .. itemsInStock .. ", requested " .. amount) refund(config.pkey, transaction, amount * product.price, config.messages.notEnoughStock) return end @@ -143,9 +143,9 @@ refund(config.pkey, transaction, change, config.messages.change, false) end - logger:info("Dispensing " .. amount .. "x " .. product.id .. " (s).") + logger:info("Dispensing " .. amount .. "x " .. product.displayName .. " (s).") - local stackSize = storage.getItem(product.id).item.maxCount + local stackSize = storage.getItem(product.id, product.nbt).item.maxCount local turns = math.ceil(amount / stackSize / 16) local lastTurn = amount - ((turns - 1) * stackSize * 16) @@ -156,10 +156,10 @@ if turns == turn then logger:debug("Last turn.") logger:debug("Arguments passed: " .. config.self, " | ", product.id, " | ", tostring(lastTurn)) - storage.pushItems(config.self, product.id, lastTurn, nil, nil, { optimal = false }) + storage.pushItems(config.self, product.id, lastTurn, nil, product.nbt, { optimal = false }) else logger:debug("Not last turn") - storage.pushItems(config.self, product.id, stackSize * 16, nil, nil, { optimal = false }) + storage.pushItems(config.self, product.id, stackSize * 16, nil, product.nbt, { optimal = false }) end for i = 1, 16 do @@ -169,7 +169,7 @@ end local message = "Kristify: `" .. - transaction.from .. "` bought " .. amount .. "x " .. product.id .. " (" .. transaction.value .. "kst)" + transaction.from .. "` bought " .. amount .. "x " .. product.displayName .. " (" .. transaction.value .. "kst)" logger:debug("Running webhooks") @@ -179,7 +179,7 @@ if webhook.type == "discord" then webhooks.discord(webhook.URL, message) elseif webhook.type == "discord-modern" then - webhooks.discordModern(webhook.URL, transaction.from, product.id, amount * product.price, transaction.id, + webhooks.discordModern(webhook.URL, transaction.from, product.displayName, amount * product.price, transaction.id, transaction.to) elseif webhook.type == "googleChat" then webhooks.googleChat(webhook.URL, message) diff --git a/src/frontend.lua b/src/frontend.lua index b906e18..f1e1cd0 100644 --- a/src/frontend.lua +++ b/src/frontend.lua @@ -260,7 +260,7 @@ -- Sort tItems = {} for _, item in ipairs(ctx.products) do - local amount = storage.getCount(item.id) + local amount = storage.getCount(item.id, item.nbt) if amount ~= 0 then local newItem = { amount = amount