Is there any way to run a command automatically when a player joins the server? I need to do this without the use of a Bukkit plugin. I think it's possible with MCP but I want to know how!

  • 1
    Place a pressure plate on the spawn point? – Ben Dec 21 '14 at 14:59
  • @Ben If he doesn't use Bukkit then there is no on-join point. The spawn point is used only if the player dies. – Andrew Dec 21 '14 at 19:04

First, create a scoreboard objective of type "stat.leaveGame":

/scoreboard objectives add quits stat.leaveGame

Next, put this commands into a always active repeating command block:

/execute as @a[scores={quits=1..}] at @s run <COMMAND TO RUN>

And in a chain command block in the direction that the first command block points to:

/scoreboard players set @a[scores={quits=1..}] quits 0

The command you put in the place of <COMMAND TO RUN> will now run every time a player rejoins the game.

  • 1
    I know this is 5 years old, but… the update order of the command blocks is dependent on the rotation in which you build this, so for half of the people who read this answer, it won't work. Edited: I updated the answer from before 1.9 to after 1.13 now, now it works for 100% of players. – Fabian Röling Jan 14 at 8:20

the previous answer is good if you want it to give players the item every time they join... (i see an exploit if its a good item)

If you only wnat it to give the item the first time they join try:

-in chat:

/scoreboard objectives add joined dummy

-in Command blocks on a fill clock:

/scoreboard players add @a joined 0


/execute @a[score_joined=0] ~ ~ ~ [command you want to run]

in a command block powered by a comparator signal from the execute command

/scoreboard players set @a[score_joined=0] joined 1

this will do it the first time they join only

  • Or you can do this as an .mcfunction – Manchineel Oct 5 '17 at 17:17

If you want to make it run a command when YOU join, use liteloader and the mod called macros mod, found at LiteLoader Website
Unfortunately i do not think there is a way to do this without bukkit (if you want the command to be run whenever ANYONE joins

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.