Minecraft Spigot not change a specific item Java?

ca
10

I need help how can I do that a certain item in the inventory can't be changed so it always stays the same on a hotbar you just can't move and can't drop how can you query whether a player has a certain item?

Ap

You can use the InventoryClickEvent and the PlayerDropItemEvent for this.

ca

And how exactly?

ca

I already know which event I just don't know how to check whether it has a specific item with a name e.g. "& 7Profil"

Ve

You can simply use the events you are familiar with

itemstack.getItemMeta (). GetDisplayName (). Equals ("NAME DES ITEMS");

Query whether the item has a name or what its name is.

ca

Okay thanks honor kiss

ca

But for me there's a mistake

try {
if (ItemStack.getItemMeta (). GetDisplayName (). Equals ("NAME DES ITEMS")); {
e.setCancelled (true);
} else {
e.setCancelled (false);
}
} catch (exception e2) {
// TODO: handle exception
}

Ap

ca

Thank you!

ca

Now it works great!

ca

A question how does that work when placing an item? I can't do it: /