getPlayer() Undefined for playerJoinEvent

Discussion in 'Plugin Development' started by Nebula111, Aug 15, 2013.

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

    Nebula111

    All of the sudden (since I changed from craftbukkit.jar to bukkit.jar) I am having a problem where it says getPlayer() in undefined for playerJoinEvent. I had to switch over to bukkit.jar due to the issue with getHealth() being ambiguous (which is fine now).

    [​IMG]
     
  2. Offline

    AmShaegar

    What's the error you get there? Usually shown in a tooltip. The Event definitly has this method. Did you import the correct Player class?
     
  3. Offline

    GaaTavares

    Which imports do you have? Just bukkit API?
     
  4. Offline

    Nebula111

    Yes bukkit API

    [​IMG] And yes I imported the correct player class

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

    herpingdo

    Don't use bukkit.jar, use craftbukkit.jar.
     
  6. Offline

    Nebula111

    Thats what I used to use, but then I had a problem with p.getHealth() and p.setHealth() being ambiguous.
     
  7. Offline

    herpingdo

    I believe they fixed that in the latest version.
     
  8. Offline

    GaaTavares


    In the really, bukkit recommends to use bukkit api instead of craftbukkit.


    o_o this only can be a eclipse error omg
    try to do: p. and open the tooltips (methods) o_o

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

    Nebula111

    Ill give it a try

    Yes p. will open up a list of methods. I tried closing out of eclipse and starting it up again (which usually fixes eclipse bugs) that didnt work though.

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

    GaaTavares


    try re-importing the API.
     
  11. Offline

    Nebula111

    Nope... now there is two errors, both saying the same message [​IMG]

    GaaTavares

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

    GaaTavares


    oh srry, so, i really dont know how do i can help you, sorry :/ i tried..
     
  13. Offline

    MrTwiggy

    Try cleaning and rebuilding your project.
     
  14. Offline

    hubeb

    Nebula111 Do u mind posting your whole class file?
     
  15. Offline

    flaaghara

    It looks like an Eclipse error. Try saving the file you are working on, and reopen Eclipse. Perhaps try and add the bukkit.jar as a library again.
     
  16. Offline

    GaaTavares


    He alredy does this :/
     
  17. Offline

    Nebula111

    MrTwiggy What do you mean?
    hubeb Sure:
    Code:
    package com.github.Nebula111.nations;
     
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.OfflinePlayer;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.BookMeta;
     
    import com.github.Nebula111.vulnerability.Slowness;
     
     
     
     
     
    public class PlayerJoinEvent implements Listener {
       
        /*
        * Constructors
        */
       
        NationsPlayer np = new NationsPlayer();
       
        /*
        * Create Config instance
        */
       
        nations plugin;
        public PlayerJoinEvent(nations instance) {
            plugin = instance;
        }
       
        @EventHandler(priority = EventPriority.NORMAL)
        public void onPlayerJoin(PlayerJoinEvent event){
            Player p = event.getPlayer();
            if(!p.hasPlayedBefore()){
     
        /*
        * Instruction Book Creation
        */
               
                p.sendMessage(ChatColor.BLUE + "This book contains instructions on how to use Nations!");
                ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
                BookMeta bm = (BookMeta)book.getItemMeta();
                bm.setAuthor(plugin.getConfig().getString("Book Title"));
                bm.setTitle("Nations Instructions");
                ArrayList<String> pages = new ArrayList<String>();
                pages.add("Put some instructions here");
                pages.add("Put some instructions here");
                bm.setPages(pages);
                book.setItemMeta(bm);
                p.getInventory().addItem(book);
               
                np.addNationsPlayer(p.getName(), "Starter");
           
          /*
          * Refresh Abilities/Vulnerabilities
          */
               
            } else {
                Slowness.slowPlayer = p;
                Slowness.addSlowness();
            }
           
        }
     
    }
    
    flaaghara Tried both of those already :(
     
  18. Offline

    AmShaegar

    You named your own class PlayerJoinEvent? That's overriding the bukkit one. That's you problem. Chose another name like PlayerListener.
     
  19. Offline

    MrTwiggy

    What AmShaegar said, or, just put

    public void onPlayerJoin(org.bukkit.event.player.PlayerJoinEvent event){
     
  20. Offline

    Samthelord1

    Nebula111 also, use craftbukkit, even though p.setHealth is ambiguous, it works.
     
  21. Offline

    Nebula111

    LOL oops, most have been thinking about the event I was going to use when I made the class.

    Anyway thanks to everyone for helping me out!

    Edit: Still didn't fix the problem :/
     
  22. Offline

    sgavster

    Have you tried saving the class? Sometimes that helps :p
     
  23. Offline

    Nebula111

    Yep :/
     
  24. Offline

    AmShaegar

    You have to import the correct PlayerJoinEvent now.
     
  25. Offline

    Nebula111

    Ok thanks
     
  26. Offline

    Aikar

    Please do not suggest for people to use CraftBukkit over Bukkit.

    You should be using bukkit.jar unless you actually know what you're doing and know WHY you would need CraftBukkit.jar.

    If you use craftbukkit.jar and you're not experienced, you will end up accidently using a non Bukkit API method...

    Just stick to bukkit.jar unless you have a legit reason or know what you are doing and have reason to use craftbukkit.jar
     
Thread Status:
Not open for further replies.

Share This Page