Solved BukkitRunnable fail when player quit

Discussion in 'Spigot Plugin Development' started by Menfie, Jun 1, 2016.

  1. So as I mentioned at the title I have this code:

    Code (Text):
    itemforsale = new playeritem(item, price) //ItemStack, int
    sellerp = new seller(player.getUniqueId(), itemforsale);
    BukkitTask kontrol = new BukkitRunnable().runTaskLater(Aa.plugin, 80);
    I run this code after a command and that command put item player holds to an inventory (a market) and after 80 ticks I run the kontrol and it removes the item from the inventory (market) this is working fine when player is online. But if player trigger the kontrol and quit than the item is just vanishing. It gets removed from the inventory (market) but it goes nowhere. Normally it must go to an inventory which is special for the player and that inventory holds removed items.

    BukkitRunnable kontrol is basically doing this:
    Code (Text):
    UUID playerid = Commands.sellerp.playerid;
    playeritem itemforsale = Commands.sellerp.itemforsale;
    ItemStack i = itemforsale.item;
    Aa.inventories.get(playerid).addItem(s); //Add item that's going to removed to players special inventory
    Aa.aainventory.removeItem(i); //Remove item from market inventory
    Aa.itemsmap.keySet().remove(itemforsale); //Remove item from market items hashmap
     
  2. Just check if player is online, if not, just cancel the task and return;
     
  3. Any error messages?
    Code (Text):
    UUID playerid = Commands.sellerp.playerid;
    Can you show us where you're defining playerid?
     
  4. Than the item is not getting removed? I have to remove it whether the player is online or not and add it to player's special inventory
     
  5. It's already in the code "sellerp = new seller(player.getUniqueId(), itemforsale);"
    And no there isn't any error
     
  6. Then show us
    Code (Text):
    Aa.inventories.get(playerid).addItem(s); //Add item that's going to removed to players special inventory
    please.
     
  7. Never mind guys I solve it thanks for helps -.- It's all my fault.
     
    #7 Menfie, Jun 1, 2016
    Last edited: Jun 1, 2016