#Ban Item

33 messages · Page 1 of 1 (latest)

novel escarp
#

How do i ban an item/remove it from recipes and insert it into my server(I know nothing of KUBEJS but will try to figure it out)

plush ironBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

bitter bladeBOT
#

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!

novel escarp
#

@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?

faint jacinth
#

Learn Kube first. Look at the Wiki to see if it can help you. We can’t help if you don’t know anything

novel escarp
#

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)
})
})

lost compass
#

Ye it’s almost identical to the one I linked lol

novel escarp
#

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

lost compass
#

it will work for removing items from inventory, but its not using good coding practices at all

novel escarp
#

Hmm wierd, i found it in the old kubejs archives i think

#

let me double check lexxie rq

lost compass
#
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 })
  })
})
novel escarp
# lost compass ```js let bannedItems = ['minecraft:apple'] PlayerEvents.inventoryChanged(event...

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]);
})
})"

lost compass
#

just use the one i wrote

novel escarp
#

🫡 i trust you

lost compass
#

actually one sec

#

need to change it a little

#

that should be better

novel escarp
# lost compass that should be better

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?

lost compass
#

you already have that

#

event.player.tell

#

just add the reason, unless you want individual reasons for each item?

novel escarp
lost compass
#

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)

novel escarp
lost compass
shy geode
lost compass
#

why are you necroing a post from march... just open a thread