How to Change Minecraft Server Gamerules (keepInventory, mobGriefing)
Change gamerules minecraft server keepInventory, mobGriefing, doDaylightCycle with one /gamerule command that saves to level.dat and survives restarts.
You change a gamerule with /gamerule <name> <value>: /gamerule keepInventory true to keep items on death, /gamerule mobGriefing false to stop creepers and endermen wrecking builds, /gamerule doDaylightCycle false to freeze the sun. It's one command, it takes effect instantly, and the value saves into the world itself, so you set it once from an op account or the console and it survives every restart after that. That last part is the whole difference from server.properties: gamerules live in the world's level.dat, not a text config, so there's nothing to edit in a file and no reboot to wait on.
The command, and who's allowed to run it
The syntax is always /gamerule <name> <value>, and there are only two kinds of value. Most rules are booleans that take true or false, like keepInventory or mobGriefing. A handful are integers, like randomTickSpeed (default 3, how fast crops and fire tick) or playersSleepingPercentage, and those take a number instead.
Run the name on its own and the game reports the current value back instead of changing it: /gamerule keepInventory returns Gamerule keepInventory is currently set to: false. Add a value and it confirms the change with Gamerule keepInventory is now set to: true. That query form is handy for checking what a world is actually set to before you go flipping things.
/gamerule is a cheat command, so it's gated. In game you need operator status at permission level 2 or higher, which any normal op clears since the default op-permission-level is 4. If you're not op yet, grant yourself operator status first. The other way in is the server console, which always runs at level 4 and doesn't need to be op at all, so you can set every rule from your host panel without touching an account in game.
One Java gotcha worth burning into memory: rule names are case-sensitive. keepInventory works, keepinventory throws an "Unknown or incomplete command" error and does nothing. Tab-complete the name instead of typing it out and you'll never hit this. (Bedrock is more forgiving here; more on that in the FAQ.)
keepInventory: keep your stuff on death
/gamerule keepInventory true is the one people ask about first, and on casual survival and SMP worlds it's usually the first rule flipped. The default is false, meaning death scatters your inventory on the ground and drains your experience, and that timer to sprint back before your stuff despawns is the classic survival panic.
Turn it on and death stops costing you anything material. It keeps both your items and your experience. You drop nothing, and you respawn with your XP bar exactly where it was. It applies to everyone on the world at once, the instant you run it, with no relog needed.
My honest read: it's the friendliest setting for a small friends' server where nobody wants to lose an hour of enchanting to one bad lava step. But it also erases the only real stake survival has, so hardcore and challenge servers leave it off on purpose. Most of the busy public survival worlds on /servers/survival keep it off for the same reason.
mobGriefing: stop creepers and endermen from editing your world
/gamerule mobGriefing false stops mobs from changing the terrain, and the default is true. This is the fastest way to protect a build from the usual culprits without walling everything off.
Here's exactly what it switches off. Creeper explosions still go off and still hurt players standing in them — they just no longer break blocks, so no more craters in your floor. Endermen stop picking up and placing blocks. Ghast fireballs and the wither stop tearing up terrain, and zombies stop breaking down doors. The explosion animations and the player damage stay; only the block-editing goes away.
The catch is that it's a blunt instrument. The same rule also stops villagers from farming and harvesting, which quietly breaks some villager-run crop farms and a few iron-farm designs that lean on villager behavior, and it disables other intended mechanics along the way. For a public server you're better off with a targeted land-claim or protection plugin that only guards claimed areas. That's the difference between a real anti-grief setup and a global off-switch, and the rundown on what griefing is and how servers stop it gets into it. For a small trusted group, though, mobGriefing false is the quick fix and it's fine.
doDaylightCycle: freeze the time of day (and weather while you're at it)
/gamerule doDaylightCycle false stops the sun wherever it happens to be sitting right now, which is rarely the time you actually want. So pair it with a /time set command to pin the moment: /time set day for morning, /time set noon for high sun, or /time set midnight if you're going for a night build. Set the rule to false first, then set the time, and it stays there.
The sibling rule handles weather. /gamerule doWeatherCycle false followed by /weather clear locks in permanent clear skies, which is what most people want for a build server or a lobby. If you'd rather keep a mood, /weather rain locks rain on instead and it'll never clear.
Both of these save into level.dat the same way every other rule does, so a creative build world or a minigame lobby stays in eternal noon with clear skies across every restart. You're not resetting the time each time the server boots.
A few more the chat keeps asking for
/gamerule doFireTick falsestops fire from spreading, which is solid grief and wildfire protection on a wooden town. The trade-off: placed fire also never burns out, so a lit netherrack stays lit forever until you break it./gamerule doInsomnia falsestops phantoms from spawning on players who haven't slept in a few in-game days. Handy if your regulars grind through nights and hate the swooping./gamerule playersSleepingPercentage 0is an integer rule, default100, and it sets what fraction of online players must be in bed to skip the night. Set it to50and half the server passes the night; set it to0and a single sleeper does it. It's the fix for a busy SMP where you can never get everyone into bed at once./gamerule commandBlockOutput falseand/gamerule sendCommandFeedback falsequiet the spam. The first stops command blocks from printing to admin chat every time they fire; the second silences the feedback from repeated manual commands. Both are pure noise control.
When a command block makes sense (and when it doesn't)
The honest take: on a server you actually control, you almost never need a command block to set a gamerule. The value is already saved in level.dat the moment you run the command, so you run it once from the console and forget it exists. Wrapping it in a command block just adds a block you have to maintain for no benefit.
Where a command block earns its place is a self-contained map or adventure world that has to enforce a rule no matter whose server loads it, or a setup where you genuinely can't reach a reliable console. There, a single Impulse command block set to Needs Redstone or Always Active running /gamerule ... will apply the rule at permission level 2 regardless of who trips it. That's exactly why those blocks stay behind op plus Creative: anyone who can place one is running commands at op level. If you're going that route, the walkthrough on enabling command blocks covers placement, and you'll want your op list kept short so only trusted accounts can build them.
Either way, come back to the contrast that makes gamerules easy: unlike server.properties, you're not re-editing anything on each boot. The rule is baked into the world next to your Paper config files, and it stays put. If you're about to flip several rules on an established world, take a backup first, not because the commands are risky, but because it's cheap insurance before you change how a live world behaves.
FAQ
Does keepInventory keep my XP too, or just items?
Both. keepInventory true preserves your experience bar on death right alongside your inventory, so you respawn with the same levels you died with. There's no separate gamerule for experience; it's bundled into this one. If you specifically want items-but-not-XP, or XP-but-not-items, the vanilla rule can't split them and you'll need a plugin, because the rule is all-or-nothing.
Do gamerules apply to the Nether and End as well?
In vanilla and Paper, the overworld, Nether, and End all share one level.dat, so a gamerule you set once already covers all three dimensions. The trap is multi-world setups. If you run something like Multiverse or keep separate world folders, each world carries its own level.dat, so the rule only applies to the world you ran it in. You have to run the command again in each world. That's the most common reason a rule "didn't work" after someone walked into a second world.
Can I turn keepInventory on for just one player?
No. Gamerules are world-wide by design; there's no per-player scope anywhere in vanilla. The moment you set keepInventory true, it's true for everyone on the world. If you need one player (or one rank) to keep their items while others drop theirs, that takes a plugin that grants the behavior through a permission node. The vanilla rule can't target individuals.
Do gamerules work the same on a Bedrock server?
Mostly. /gamerule exists on Bedrock and works the same way, but Bedrock is case-insensitive, so keepinventory is accepted there even though it fails on Java. Bedrock also exposes many rules as plain toggles in the world's Game settings screen, so you can flip them without typing a command at all. Watch out for edition differences, though. Bedrock has rules Java doesn't, like showcoordinates, so don't assume every Java rule name exists on the Bedrock side.


