From Minecraft Wiki
Sets the maximum number of players allowed to join a multiplayer game.
setmaxplayers <maxPlayers: int>
- Specifies the desired new maximum number of players. If less than the current number of players or greater than the maximum number of connections the server can accept, the argument is forced into this range. The integer must be between 1 to 30.
- Fails if maxPlayers is omitted or isn't an integer that is between 1 to 30.
- On success, displays the new maximum number of players in the chat. An additional notification message is displayed if the number specified in the command was forced into the allowed range.
- Note: This command can be entered in single-player mode, but has no effect until you reopen the world in multiplayer mode.