If Player Has Not Joined Before

Discussion in 'Plugin Development' started by KaiBB, Feb 16, 2012.

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

    KaiBB

    Is there anyway to do this other than writing to a file? I already tried this:
    Code:
    if(!p.hasPlayedBefore()) {
    It didn't work.

    Ohh it's a boolean. Need to re-test it, but this is what I did this time:
    Code:
    if(p.hasPlayedBefore() == false) {
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
  2. i don't see any difference...
     
  3. Offline

    DrBowe

    The two things you posted are the exact same, but with different syntax. :confused:
     
  4. Offline

    KaiBB

    I know. Neither worked, I was just making sure, because plenty of times thing like that, that make no sense, work. Any idea why neither will work?
    kumpelblase2
    DrBowe
     
  5. Offline

    Njol

    Which event did you put this in (if any)? Maybe it only works in the prelogin event.
     
  6. Offline

    KaiBB

    onPlayerJoin

    Njol
    Should I use PlayerLogin?

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

    Njol

    I'd at least try it.
     
  8. Offline

    KaiBB

    Doesn't work. I'll just use a file.
     
  9. Offline

    dark navi

    I believe that by the time onPlayerJoin is called, the user's .dat file is already created.
     
  10. Offline

    KaiBB

    PlayerLogin doesn't work either.
     
  11. Offline

    hatstand

    PlayerPreLogin?
     
  12. Offline

    KaiBB

    Is that a event?
     
  13. Offline

    hatstand

    KaiBB likes this.
  14. Offline

    KaiBB

    hatstand
    I'll tell you whether or not it works; thanks!
     

  15. Code:
    @EventHandler
    public void onPlayerJoinEvent(PlayerJoinEvent ev)
    {
        Player p = ev.getPlayer();
        if(!p.hasPlayedBefore())
        {
            //your code here
        }
        else
        {
            //whatever you want here
        }
    
    That works fine, if you still have errors, its probably an IDE error.
     
  16. Offline

    20liwlill20

    Code:
                  @EventHandler
    public void playerLogin(PlayerLoginEvent event){
    player = event.getPlayer();
    Pname = player.getName();
    if(player.hasPlayedBefore())
    {
                     
    }else{
    for(Player Player: Bukkit.getOnlinePlayers())
    {
    logger.info(Pname +" has joined for the 1st time.");
    Player.sendMessage(Pname + ChatColor.BLUE + "to the server for the 1st time");
    }
    }
    }
    Try that :D my one posts a message to all online players.
     
  17. You can do Bukkit.broadcastMessage
     
  18. Offline

    Njol

    And this is a reason to bump a 2 months old thread?
     
  19. Oops, never realised it was 2 months old, I had it open in my browser and kept meaning to check back on it.

    I finally got the time today to but didn't look at the date, #fail

    Keir
     
  20. Offline

    TripleXPenguin

    Is bumping 2 month old threads frowned upon?
     
  21. Offline

    feildmaster

    That's incorrect. Player.dat files are created 1- When a plugin tells them to save. When you do /save-all, when you /stop, when player logs off.

    It is when you add no context to the problem. You're telling them to broadcast, which does... what in this situation?

    Edit: Now that I see what you're replying to, yes.. That is a proper response. Also he's spamming to console. Lovely.
     
  22. Offline

    KaiBB

    Why is this still being posted on? It's been fixed in Bukkit API, so you can actually do p.hasPlayedBefore now...
     
Thread Status:
Not open for further replies.

Share This Page