Bug with PlayerFishEvent?

Discussion in 'Plugin Development' started by EvilPeanut, Mar 16, 2013.

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

    EvilPeanut

    For some reason we can't seem to add items to the player inventory on the PlayerFishEvent event.

    Heres the code, see anything wrong?
    Code:
    Player player = event.getPlayer();
    String fishName = plugin.fishList.get(new Random().nextInt(plugin.fishList.size()));
    ItemStack fish = new ItemStack(Material.RAW_FISH);
    ItemMeta meta = fish.getItemMeta();
    meta.setDisplayName(fishName);
    fish.setItemMeta(meta); 
    player.getInventory().addItem(fish);
    player.sendMessage("§7You have caught a " + fishName);
    player.giveExp(event.getExpToDrop());
    NOTE: player.setItemInHand(fish); works, so why doesnt player.getInventory().addItem(fish);?

    anyone :( ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  2. Offline

    ZeusAllMighty11

    Code:
    ItemStack fish = new ItemStack(Material.RAW_FISH, 1);
    
     
  3. Offline

    EvilPeanut

    Nope, i think its actually a bug...
    How can i report it?
     
  4. EvilPeanut
    Does the message trigger ?
    Also you shouldn't manually give exp to them unless you're canceling the event, otherwise you can just set the amount of exp they'll get to the event directly, better that way.

    ZeusAllMighty11
    ItemStacks start with 1 amount if not defined.
     
  5. Offline

    EvilPeanut

    Im trying to spawn items....
     
  6. Offline

    Codex Arcanum

    What Digi wants to know is whether the player.sendMessage("§7You have caught a " + fishName) message actually triggers, because that way we can be sure the event is actually running.
     
  7. Offline

    EvilPeanut

    Yes, it does trigger :p
     
  8. Offline

    blablubbabc

    maybe try with "player.updateInventory();" after you added the item to the players inventory to update it for the player
     
  9. Offline

    EvilPeanut

    Works! There must be a bug though because it really should do that automatically :p
     
  10. Offline

    EvilKanoa

    Nope, that's not a bug :p
     
  11. Offline

    EvilPeanut

    Surely? Shouldn't it update the player inventory?
     
  12. Offline

    EvilKanoa

    It would make a few things easier, but it also makes it so you can invisible items and what-not (Don't quote me on it though, haven't tested).
     
Thread Status:
Not open for further replies.

Share This Page