Solved Need some help...

Discussion in 'Plugin Development' started by Wantsome909, Jan 22, 2017.

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

    Wantsome909

    So i been making a mini game lately and i came upon an error.
    Here is my code:

    Code:
            if(event.getItem().getItemStack().getType().equals(Item.health)){
                player.sendMessage("§c[Debug]");
                new BukkitRunnable(){
                    int count = 2;
                    public void run(){
                        count--;
                        if(count == 1){
                            player.sendMessage("§2[Debug]2");
                            itemstack.setAmount(amount - 0);
                            player.getInventory().removeItem(itemstack);
                            this.cancel();
                        }
                        this.cancel();
                    }
                }.runTask(BlockDefence.getPlugin());
            }
    when i pick up the health it wont remove it self or anything like i'm trying to do?
    debug message wont even work.
    i have another item and it works.
     
  2. Offline

    JanTuck

    You are running the task once, which means it wont iterate over the code again. So the counter will never be 1 when the if statement is checking
     
  3. Offline

    Wantsome909

    I don't think that is the problem. I believe its the item i'm using. I can use every other items then dyes or other items that have different meta's like StainGlass, or wool or like 251:12, 251:13, etc. if that helps @JanTuck

    i got it thanks for the help @JanTuck!

    if you need help get switch getType() to getItemMeta!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited: Jan 22, 2017
Thread Status:
Not open for further replies.

Share This Page