Hey, I'm not putting this as a review but because Shroob didn't provide any constructive criticism in his, I'll be highlighting some stuff that could have been done better with the script.
#1
The script itself
works, but the commands and variables could be better organized. For instance, you could've used list variables like
{spawn::location} and
{spawn::errormsg} so that all spawn properties would be within the same list variable.
Also, this isn't really a critique but rather personal preference, but I would move all the configuration (i.e. setspawn message, spawn message, error message, etc.) to an options section. There really is little need for these properties to be configured in-game and having them in the script itself would eliminate the need for 3 different commands to set each property.
#2
I would also suggest replacing
0.1 seconds with
1 tick. Not only does this look "cleaner," but as tick is the shortest unit of time you could use in Minecraft, it would actually cut down the wait time in half. 1 second is equivalent to 20 ticks. Similarly, 0.1 seconds would be the same as 2 ticks.
However, there really is no need to wait a tick in your code at all. In the respawn event, you can use the
respawn location expression to dictate where the player will respawn. As for the join event, you can teleport the player immediately without the wait.
Overall there really isn't anything
wrong with your script, if we're talking solely about the correctness of the code. However, I would argue that teleporting players to spawn upon every single join, rather than just the first, is rather inconvenient. Perhaps you could add an option for the server admin to decide whether they want to enable that feature or not. Alternatively, you could also add a command to teleport the player to their last location before they were teleported to the spawn. The former would probably be easier, as teleporting players to their last location could bring issues of its own