set Game Rule
Enable or disable a game rule. Game rules control what happens to players and mobs in some game situations.
gameplay.setGameRule(PV_P, false);
You can cause or prevent some things happening to players and mobs with ||gameplay:set rule||. The
rule is turned on by setting true and turned off by setting false.
Parameters
- rule: the game rule to change, such as: _PV_P_
PvP: players can attack each otherdrowning damage: staying for too long under water will damage the playerfall damage: falling from really high will damage the playerfire damage: fire will damage the playerdaylight cycle: time will advance in the gamemob loot: mobs will drop loot upon dyingmob spawning: mobs are able to spawnweather cycle: weather will change naturallymob griefing: mobs can affect the game world (for example, endermen picking up blocks, or creepers exploding the environment)block drops: blocks that are successfully mined will drop as an item and be collectible by playerskeep inventory: players will not lose their inventory upon dying
- enabled: set enabled:
true, or not enabled:false, for the rule
Example
Make it always sunny in the game world by disabling daylight and weather cycles.
gameplay.setGameRule(DAYLIGHT_CYCLE, false);
gameplay.setGameRule(WEATHER_CYCLE, false);
gameplay.setWeather(Weather.Clear);
gameplay.timeSet(gameplay.time(DAY));