Is there a way to detect if a map is being played in multiplayer? (1.15)

I'm attempting to make a fully customized map that I want to only be single player. I'm going to be using custom sounds with my voice, and wanted to determine whether or not a group of people are playing multiplayer so I can present them with a custom clip of me saying "this map will only work in Single Player" or something similar.

I've thought about making a simple command block that triggers after x amount of time using chain command blocks, with the following command;

execute unless @a[limit=1] run playsound ..

The problem with this, however, is I'm not entirely certain that the limit selector will work this way. In theory, of course, it should, but being unable to test multiplayer myself makes this a little difficult.

Another, more sure-fire, way would be to do three scoreboards and match them all up together to create a tally system, but not only would that be countless hours of tedious brain-knocking before eventually making a flawless system, but it wouldn't be necessarily flawless and could mess up at any given moment.

Would there be any way to find how many players there are in a world--and if so, to run a command if there are x people?


Solution 1:

Create a scoreboard objective:

/scoreboard objectives add players dummy

and run this in a repeating command block:

/execute store result score map players run execute if entity @e[type=player] 

to run your command:

execute if score map players matches 2.. run <command>

^ this only runs if there are 2 or more players in the world.