Something wrong here?

Discussion in 'Plugin Development' started by triarry, Feb 8, 2013.

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


    Hi guys, I'm trying to make a function in which item IDs that are on an external config.yml are NOT dropped from a player's inventory when they die.

    I was able to incorporate a blacklist, which keeps everything in the players inventory except the item IDs on the external list. I thought it'd be easier to make a whitelist, but I'm stumped on how to create the function and find the correct index in the player's drops.

        public void dropWhitelist(PlayerDeathEvent event) {
            Player p = event.getEntity();
            if (p.hasPermission("pvprestore.whitelist.drop") && plugin.getConfig().getBoolean("whitelist.enabled") == true) {
                for (Integer itemList : plugin.getConfig().getIntegerList("whitelist.items")) {
                    for (ItemStack itemStackList : event.getDrops()) {
                        if (itemStackList.getTypeId() == itemList) {
                            Integer i = event.getDrops().indexOf(itemStackList);
    The System.out.print(i) is for debugging purposes. Whitelist is set to true in the config, and I have the permission pvprestore.whitelist.drop. The items on the whitelist.items are 299 and 300 currently. I'm setting the integer i = to the index of the item I want to remove from the player's drop list, and then removing that from the player's drops. What am I doing wrong here?

    Thanks in advance!

    EDIT: By the way, it DOES print out an index number in the console. So its running it, my event.getDrops().remove(i) is just wrong.
  2. Offline


    Dupe the drop List, then modify that in the loops. Then use event.setDrops(newList).
  3. Offline


    Will give this a shot, and report progress.

    EDIT: Unfortunately, there's no setDrops method. Cloning the list would just make this more of a hassle, and it'd make more sense to directly edit the drops themselves, but I'm having trouble doing this.

    Does anyone else have any other ideas? I'm stumped here. I've got all the code nailed down at this point except for preventing items on a whitelist from dropping.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page