Adding itemstack in PlayerLoginEvent

Discussion in 'Spigot Plugin Development' started by L4undry, Aug 13, 2018.

  1. Hey I have a PlayerLoginEvent that is supposed to put a book into the player's inventory. Whenever I join, it doesn't put the item in or send me the message test. It'll print test to the console though, so I know the event is firing. Why?

    public void onLogin(PlayerLoginEvent e) {


    ItemStack writtenBook = new ItemStack(Material.WRITTEN_BOOK, 1);
    List<String> pages = new ArrayList<String>();
    BookMeta bookMeta = (BookMeta) writtenBook.getItemMeta();
    bookMeta.setTitle("How to Play");
    pages.add("This game mode is all about &craiding &fand &cPvPing &fothers.");


    e.getPlayer().getInventory().setItem(0, writtenBook);

  2. You're looking for a PlayerJoinEvent.

    PlayerLoginEvent occurs on player login, when he hasn't fully joined the server yet.
    • Agree Agree x 1
    • Winner Winner x 1
  3. Even at that, i am not 100% sure you can add items to a player inventory in the join event. You might need to add a delay to 1 / 2 ticks
  4. You actually don't.