Solved Add Item to Inventory not showing up?

Discussion in 'Plugin Development' started by habbah, Oct 24, 2013.

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

    habbah

  2. Offline

    Blah1

    Im going to guess lag? What event is thas for?
     
  3. Offline

    habbah

    no lag, its on a local server 127.0.0.1
    i can move and place blocks but the new item only appears after i click the item slot it was placed into
     
  4. Offline

    Deleted user

    habbah

    player.updateInventory()
     
  5. Offline

    habbah


    This causes it to behave weird lol, now when the stack is added instead of only one it appears as if TWO of the item is added UNTIL i click that stack then it reverts back to only 1 of that item
     
  6. Offline

    MrSparkzz

    habbah
    updateInventory(); is not used anymore, or needed. Remove that and it should be fine.

    Also, instead of this
    Code:java
    1. event.getBlock().setType(Material.AIR);
    2. event.getPlayer().sendMessage("You do NOT have enough money to place this block!");
    3. event.getPlayer().sendMessage("Your current balance is: " + CheapCubes.econ.getBalance(event.getPlayer().getName()));
    4. event.getPlayer().getInventory().addItem(PlacedBlock);
    5. event.getPlayer().updateInventory();

    do this
    Code:java
    1. event.setCancelled(true);
    2. event.getPlayer().sendMessage("You do NOT have enough money to place this block!");
    3. event.getPlayer().sendMessage("Your current balance is: " + CheapCubes.econ.getBalance(event.getPlayer().getName()));
     
  7. Offline

    habbah


    i only added that after @zombiekiller753 told me too the issue is still present. I think this is a bug with the new release today.
     
  8. Offline

    MrSparkzz

    I updated my post. Read through it.

    habbah Oh that's normal. That bug was introduced a couple updates ago. It happens when there's a bit of lag on the server. Sometimes even when there's not.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  9. Offline

    habbah


    Oh... :/
    There should be no lag as it is just me on a local 127.0.0.1 server lol
    This is kind of annoying...
     
  10. Offline

    MrSparkzz

    habbah
    I made a plugin where you could manipulate someones inventory. It's very, very annoying. I'll move something around and the player will be like "Hey where's my stuff" unless they're lucky and it updates properly or they click in their inventory somewhere.
     
  11. Offline

    habbah


    I noticed it updates correctly if I use a stack of 2 instead of one.
    Code:
     ItemStack PlacedBlock = new ItemStack(event.getBlock().getType(),2);
    I already tried added 2 then removing 1 to see if it would update correctly... nope
     
Thread Status:
Not open for further replies.

Share This Page