Setting the difficulty for Spigot/PaperMC servers (Minecraft: Java Edition)

Other than in Vanilla Minecraft, in Spigot and PaperMC, the difficulty is set per world.

The difficulty option

"Difficulty" option

If your server is running PaperMC, the difficulty option on the options page will only affect newly generated worlds/dimensions. Worlds that have been created before the option was changed won't be updated.

When using Spigot, the difficulty option will update the overworld. Other dimensions, however, won't be updated.

The level.dat file

You can directly change the difficulty for a specific world in its level.dat file, which can be accessed by clicking the Options button on the Worlds page.

"Options" button highlighted on world

The /difficulty command

In Spigot and PaperMC, the /difficulty command only affects your current dimension. For example, if you are in the Nether while executing the command, only the difficulty of the Nether dimension will be changed.

To change the difficulty in all dimensions (Overworld, Nether, and End), please run the following three commands in your server console:

/execute in minecraft:overworld run difficulty <difficulty>
/execute in minecraft:the_nether run difficulty <difficulty>
/execute in minecraft:the_end run difficulty <difficulty>

Replace <difficulty> with the difficulty you want to set (peaceful, easy, normal, or hard).