I'm making a 1.12 map that need to do something when a player join. I tried stats.leavegame method, but if the game crashed the last time, the command won't run.

No file permission for it's hard to share, but unintended file type (like using a file to take the place of a folder, in my answer) is fine

  • 5
    Yay, someone who shows what they tried before! Commented May 9, 2018 at 8:59
  • So you want to detect every join, not just the first, right? There are certainly ways to detect when the player is there or not, but I'm trying to find a not very laggy, elegant way. I have some ideas already, I'll try some things in the next hours, for example if scoreboard tag on offline players can be used here. Commented May 9, 2018 at 9:04
  • @Fabian Using tag seems can only detect players except the first one
    – l4m2
    Commented May 9, 2018 at 11:39
  • @Virusbomb Checked the dup source, it assumes on a server, so if it crashes a local fix can be done; Here is a map where you shouldn't require to do something just because of unnormal shutdown
    – l4m2
    Commented Aug 13, 2019 at 16:39

1 Answer 1


Self solved , experiment under discussion with chyx

The world loads before player join even if it's single player, so freely assume at the beginning there's no player:

give @a[score_onLine=0] iron_shovel
scoreboard players set * onLine 0
scoreboard players set @a onLine 1
  • Someone has requested in a suggested edit that you add scoreboard players add @a onLine 0 at the start, because, This won't register players joining for the first time.. I rejected this edit because it changes the post's meaning. Although it can seem like a good addition, so you may want to consider adding it.
    – One 2 Many
    Commented Jul 7, 2020 at 0:37

Not the answer you're looking for? Browse other questions tagged .