Solved add hidden text to lore? or something like that

Discussion in 'Plugin Development' started by Boobah, Mar 21, 2018.

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

    Boobah

    hey, im making something that shows stuff from a sql database in a gui, and when you click the thing in the gui it will do stuff. example:
    upload_2018-3-21_19-36-26.png
    you click that then it unmutes the person when you click it.

    my problem is that to unmute the player i need the id of the punishment, how would i do that without adding the id to the lore of the item?
     
  2. Offline

    Smegel

    You can use NBTTagCompounds

    Code:
        public static NBTTagCompound getData(ItemStack itemStack) {
            net.minecraft.server.v1_12_R1.ItemStack craftItemStack = CraftItemStack.asNMSCopy(itemStack);
            NBTTagCompound comp = craftItemStack.getTag();
           
            if(comp == null)
                comp = new NBTTagCompound();
           
            return comp;
        }
       
        public static ItemStack setData(ItemStack itemStack, NBTTagCompound comp) {
            net.minecraft.server.v1_12_R1.ItemStack craftItemStack = CraftItemStack.asNMSCopy(itemStack);
            craftItemStack.setTag(comp);
           
            return CraftItemStack.asBukkitCopy(craftItemStack);
        }
     
  3. Offline

    Boobah

    setting the nbt stuff:
    Code:
                int id = Integer.parseInt(_arr.get(_arr.size() - 1));
    
                ItemStack history = new ItemStack(getMat(name));
               
                setData(history, id);
    
    getting the nbt stuff:
    Code:
            if(event.getCurrentItem().getType() == Material.PAPER){
    
                Bukkit.broadcastMessage(HistoryPage.getData(event.getCurrentItem()) + "");
               
    }

    output:
    upload_2018-3-21_20-39-38.png
     
  4. Offline

    Boobah

    anyone pls
     
  5. Offline

    Boobah

    hello
     
Thread Status:
Not open for further replies.

Share This Page