Solved Set item lore not being associated with said item

Discussion in 'Plugin Development' started by onleeben, May 2, 2016.

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

    onleeben

    Heya, title says all, I've tried as much as I can (I'm pretty new) And google hasn't been much of a help either. So for my project, I'm making it so if, let's say, there are two people who donate to a server, and the server has the /kits plugin. If one person goes "/kit donator", they can't go and share that item with anybody else, other donators of the same tier included. The supposed "Best way" to do this (according to google) is to modify the /kit plugin so it saves item lore, and have the lore save to a person(s) UUID, so that if their UUID doesn't math the item lore, the can't get the item, whether through a chest, or from the ground.

    The only part I'm struggling with currently, is the lore not sticking to an item. I've debugged the hell out of it, and from what I've found, it:

    -Does write the lore to something
    -Lore can be retrieved from that something
    -something doesn't exist in my inventory, so the thing that has the lore is nowhere to be seen.

    Thank you all for helping out, here is my code:
    Code:
    if (cmd.getName().equalsIgnoreCase("setitemlore")) {
                    Player player = (Player) sender;
                   
                                   
                    if (args.length == 1) {
                       
                        for (Player playerToSetDonatorStatus : Bukkit.getServer().getOnlinePlayers()) {
                            if (playerToSetDonatorStatus.getName().equalsIgnoreCase(args[0])) {
                                if (playerToSetDonatorStatus.getUniqueId().toString().equals(getConfig().getString(playerToSetDonatorStatus.getUniqueId().toString()))) {
                                    String UUID = playerToSetDonatorStatus.getUniqueId().toString();
                                    int playerInventorySlot = player.getInventory().getHeldItemSlot();
                                    ItemStack stacker = new ItemStack(player.getInventory().getItem(playerInventorySlot));
                                   ItemMeta im = stacker.getItemMeta();                               
                                   List<String> lore = new ArrayList<String>();
                                   lore.add(UUID);
                                   im.setLore(lore);
                                    player.sendMessage("Lore set successfully!");                       
                                   return true;
                                }else player.sendMessage("Lore not set.");
                        }
                       
                    }
                }
            }
            return false;
    
     
  2. Offline

    I Al Istannen

    Last edited by a moderator: May 2, 2016
  3. Offline

    Gonmarte

    The best way to do this is to cancel the drop event. Check if a player has any item from the kit donator and cancell the event.
     
Thread Status:
Not open for further replies.

Share This Page