-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
When attempting to give a player an item by using addItem, it causes a Java error.
[11:18:21 ERROR]: [...] NO METHOD FOUND:
[11:18:21 ERROR]: [...] org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryPlayer
[11:18:21 ERROR]: [...] addItem
[11:18:21 ERROR]: [...] - java.lang.Object[]
[11:18:21 ERROR]: [...]
Example code to replicate it:
import { PlayerChatEvent, ServerCommands, ServerEvents, Players, ItemStack, Material } from '@customrealms/core'
ServerEvents.register(PlayerChatEvent, event => {
const player = event.getPlayer()
const inventory = player.getInventory()
const invSlot = inventory.firstEmpty()
if (invSlot === -1) return
const voteItemMaterial = Material.withName('DIRT')
if (voteItemMaterial == null) return
const voteItem = ItemStack.create(voteItemMaterial, 1)
console.log('give item', voteItemMaterial.getName(), invSlot)
inventory.addItem(voteItem)
})edit:
replacing inventory.addItem(voteItem) with inventory.setItem(invSlot, voteItem) doesn't work either (no error) but replacing it with inventory.setItemInMainHand(voteItem) does work.
AL1L, kmijkoishi and PonasKovas
Metadata
Metadata
Assignees
Labels
No labels