#Ban Item
33 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
You sure you tried everything you possibly could to fix your issue? Perhaps not.
Make sure you have searched for issues similar to yours in #1047320998199955458 before posting. They might have the answer to your problem!
@faint jacinth , I tried that but I am new to KUBEJS I don't exactly understand what they meant I'm trying to add a code to blacklist stuff from my server does it go into the kubejs directory said script in question?
Learn Kube first. Look at the Wiki to see if it can help you. We can’t help if you don’t know anything
Sorry to mention you, but will this code work? Was digging like footer said and this seems doable
let bannedItems = [
'minecraft:apple',
'minecraft:stick',
'minecraft:stone'
]
bannedItems.forEach(item => {
PlayerEvents.inventoryChanged(item, event => {
event.player.tell([
"Item ",
Text.yellow(item),
" has been ",
Text.red("removed"),
".\nReason: This item is banned."
]);
event.player.inventory.clear(event.item)
})
})
Okay, I will test it rq and if it works out I will close this thread I just want to ban something that could cause my console to be spammed with death messages thats all
actually i just looked closer at that and it doesnt look that good 
it will work for removing items from inventory, but its not using good coding practices at all
Hmm wierd, i found it in the old kubejs archives i think
let me double check lexxie rq
let bannedItems = ['minecraft:apple']
PlayerEvents.inventoryChanged(event => {
if (!bannedItems.includes(event.item.id)) return
event.player.tell([
"Item ",
Text.yellow(event.item.id),
" has been ",
Text.red("removed"),
"."
])
event.player.inventory.removeItem(event.getSlot(), event.item.count)
})
ServerEvents.recipes(event => {
bannedItems.forEach(item => {
event.remove({ output: item })
})
})
Hmm I'm trying this code its simmilar to the old one but should be more legit i hope? "let bannedItems = [['reaper:rune_humano', "Repeated Death Messages/Spam"]];
bannedItems.forEach((pair) => {
PlayerEvents.inventoryChanged(pair[0], event => {
event.player.tell([
"Item ",
Text.yellow(pair[0]),
" has been ",
Text.red("removed"),
".\nReason: ",
Text.red(pair[1]),
]);
event.player.inventory.removeItem(event.getSlot(), event.item.count);
event.player.inventory.clear(pair[0]);
})
})"
just use the one i wrote
🫡 i trust you
But I also want a item ban reason behind it so if people start asking questions about why its removed they know why, is it possible to have that in the code too?
you already have that
event.player.tell
just add the reason, unless you want individual reasons for each item?
It works, and maybe sure if I need to ban additional items in the future
youd have to change from a list to an object and all those, i cant do it im working (if you need to have per item reason)
I think, I'm good for now if I need assistance I could ask ftb discord or make a new thread thanks for your help pointing me to leigitimate code i think mine was shady as heck because i got almost 25 kubejs warnings when reloading it/restarting my server
Ticket closed!
Hey sorry for the ping, but how would you add multiple items to that code?
why are you necroing a post from march... just open a thread
