Setting item lore

Discussion in 'Plugin Development' started by _ningattes369, Dec 1, 2021.

Thread Status:
Not open for further replies.
  1. Offline

    _ningattes369

    Trying to set the item lore of an item in a pop-up punishment GUI (for banning and muting players, clicking on the "reasons" which are blocks in this inventory). This is my code:

    Code:
    void setSlot(int slot, Material block, String punishment, int punishmentLength, String description) {
        this.slot[slot] = new ItemStack(block);
        this.slot[slot].getItemMeta().displayName(Component.text(punishment));
        this.slot[slot].getItemMeta().lore(Component.text(punishmentLength));
    
    there's prolly some stuff I messed up here but I'm new to java so I'll figure it out sooner or later. just need help with the context though.

    thanks !!:)
     
    Last edited by a moderator: Dec 2, 2021
  2. Online

    timtower Administrator Administrator Moderator

    @_ningattes369 Get the metadata, change it, set it to the item again.
     
  3. Offline

    359Cube

    Code:
    ItemMeta A_ItemMeta = YourItem.getItemMeta();
    A_ItemMeta.setLore("your lore");
    
    // other code about meta
    YourItem.setItemMeta(A_ItemMeta);
     
Thread Status:
Not open for further replies.

Share This Page