Can't get custom books working

Discussion in 'Plugin Development' started by ItsLeoFTW, Jan 25, 2014.

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

    ItsLeoFTW

    Hey there!
    I'm trying to make a plugin for my server that sends a message to any player who joins AND gives them a custom book. I've tried using numerous tutorials, but none of them seem to work. Maybe they're outdated.... So anyway, here's my code:
    Code:java
    1. package com.minerzone52.welcome;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.Material;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.EventPriority;
    9. import org.bukkit.Material;
    10. import org.bukkit.inventory.ItemStack;
    11. import org.bukkit.inventory.meta.BookMeta;
    12. import org.bukkit.event.player.PlayerLoginEvent;
    13. import org.bukkit.inventory.PlayerInventory;
    14.  
    15. public class LoginListener implements Listener{
    16. @EventHandler (priority = EventPriority.LOW)
    17. public void playerLogin(PlayerLoginEvent event){
    18. ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
    19. BookMeta meta = (BookMeta) book.getItemMeta();
    20. meta.setTitle(ChatColor.YELLOW + "test");
    21. meta.setAuthor(ChatColor.YELLOW + "test");
    22. meta.setPage(1, "hi");
    23. meta.setPage(2, "hi again");
    24. meta.setPage(3, "hi AGAIN!");
    25. book.setItemMeta(meta);
    26. Player player = event.getPlayer();
    27. PlayerInventory playerInv = player.getInventory();
    28. player.sendMessage(ChatColor.YELLOW + "hi");
    29.  
    30. }
    31.  
    32.  
    33. }
    34.  

    Please help!
     
  2. Offline

    SeniorCluckers

    What exactly is the problem?

    Switch line 17
    Code:java
    1. public void playerLogin(PlayerLoginEvent event){


    with this
    Code:
     public void playerJoin(PlayerJoinEvent event){
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  3. Offline

    ItsLeoFTW

    Ahh ok thanks trying now
     
  4. Offline

    SeniorCluckers

    Ok tell me if works am not sure!
     
  5. Offline

    ItsLeoFTW

    The problem is that whenever I login, the console says "Could not pass event PlayerJoinEvent to Welcome v1.0". I changed the code, and that's what happens.
     
Thread Status:
Not open for further replies.

Share This Page