Package org.bukkit

# Class GameRule<T>

java.lang.Object
org.bukkit.GameRule<T>

Type Parameters:
  `T` - type of rule (Boolean or Integer)

All Implemented Interfaces:
  `Translatable`

public final class GameRule<T> extends Object implements Translatable
GameRules dictate certain behavior within Minecraft itself
For more information please visit the Minecraft Wiki

## Field Summary

Fields
Modifier and Type
Field
Description
`static final GameRule<Boolean>`
`ANNOUNCE_ADVANCEMENTS`
Toggles the announcing of advancements.
`static final GameRule<Boolean>`
`BLOCK_EXPLOSION_DROP_DECAY`
Whether block explosions will destroy dropped items.
`static final GameRule<Boolean>`
`COMMAND_BLOCK_OUTPUT`
Whether command blocks should notify admins when they perform commands.
`static final GameRule<Boolean>`
`DISABLE_ELYTRA_MOVEMENT_CHECK`
Whether the server should skip checking player speed when the player is wearing elytra.
`static final GameRule<Boolean>`
`DISABLE_RAIDS`
Whether pillager raids are enabled or not.
`static final GameRule<Boolean>`
`DO_DAYLIGHT_CYCLE`
Whether time progresses from the current moment.
`static final GameRule<Boolean>`
`DO_ENTITY_DROPS`
Whether entities that are not mobs should have drops.
`static final GameRule<Boolean>`
`DO_FIRE_TICK`
Whether fire should spread and naturally extinguish.
`static final GameRule<Boolean>`
`DO_IMMEDIATE_RESPAWN`
Whether clients will respawn immediately after death or not.
`static final GameRule<Boolean>`
`DO_INSOMNIA`
Whether phantoms will appear without sleeping or not.
`static final GameRule<Boolean>`
`DO_LIMITED_CRAFTING`
Whether players should only be able to craft recipes they've unlocked first.
`static final GameRule<Boolean>`
`DO_MOB_LOOT`
Whether mobs should drop items.
`static final GameRule<Boolean>`
`DO_MOB_SPAWNING`
Whether mobs should naturally spawn.
`static final GameRule<Boolean>`
`DO_PATROL_SPAWNING`
Whether patrols should naturally spawn.
`static final GameRule<Boolean>`
`DO_TILE_DROPS`
Whether blocks should have drops.
`static final GameRule<Boolean>`
`DO_TRADER_SPAWNING`
Whether traders should naturally spawn.
`static final GameRule<Boolean>`
`DO_WARDEN_SPAWNING`
Whether wardens should naturally spawn.
`static final GameRule<Boolean>`
`DO_WEATHER_CYCLE`
Whether the weather will change from the current moment.
`static final GameRule<Boolean>`
`DROWNING_DAMAGE`
Whether drowning damage is enabled or not.
`static final GameRule<Boolean>`
`FALL_DAMAGE`
Whether fall damage is enabled or not.
`static final GameRule<Boolean>`
`FIRE_DAMAGE`
Whether fire damage is enabled or not.
`static final GameRule<Boolean>`
`FORGIVE_DEAD_PLAYERS`
Whether mobs should cease being angry at a player once they die.
`static final GameRule<Boolean>`
`FREEZE_DAMAGE`
Whether freeze damage is enabled or not.
`static final GameRule<Boolean>`
`GLOBAL_SOUND_EVENTS`
Whether global level events such as ender dragon, wither, and completed end portal effects will propagate across the entire server.
`static final GameRule<Boolean>`
`KEEP_INVENTORY`
Whether the player should keep items in their inventory after death.
`static final GameRule<Boolean>`
`LAVA_SOURCE_CONVERSION`
Whether lava blocks can convert into lava source blocks.
`static final GameRule<Boolean>`
`LOG_ADMIN_COMMANDS`
Whether to log admin commands to server log.
`static final GameRule<Integer>`
`MAX_COMMAND_CHAIN_LENGTH`
Determines the number at which the chain of command blocks act as a "chain."
This is the maximum amount of command blocks that can be activated in a single tick from a single chain.
`static final GameRule<Integer>`
`MAX_ENTITY_CRAMMING`
The maximum number of other pushable entities a mob or player can push, before taking suffocation damage.
`static final GameRule<Boolean>`
`MOB_EXPLOSION_DROP_DECAY`
* Whether mob explosions will destroy dropped items.
`static final GameRule<Boolean>`
`MOB_GRIEFING`
Whether mobs can pick up items or change blocks.
`static final GameRule<Boolean>`
`NATURAL_REGENERATION`
Whether players can regenerate health naturally through their hunger bar.
`static final GameRule<Integer>`
`PLAYERS_SLEEPING_PERCENTAGE`
The percentage of online players which must be sleeping for the night to advance.
`static final GameRule<Integer>`
`RANDOM_TICK_SPEED`
How often a random block tick occurs (such as plant growth, leaf decay, etc.) per chunk section per game tick.
`static final GameRule<Boolean>`
`REDUCED_DEBUG_INFO`
Whether the debug screen shows all or reduced information.
`static final GameRule<Boolean>`
`SEND_COMMAND_FEEDBACK`
Whether the feedback from commands executed by a player should show up in chat.
`static final GameRule<Boolean>`
`SHOW_DEATH_MESSAGES`
Whether a message appears in chat when a player dies.
`static final GameRule<Integer>`
`SNOW_ACCUMULATION_HEIGHT`
`static final GameRule<Integer>`
`SPAWN_RADIUS`
The number of blocks outward from the world spawn coordinates that a player will spawn in when first joining a server or when dying without a spawnpoint.
`static final GameRule<Boolean>`
`SPECTATORS_GENERATE_CHUNKS`
Whether players in spectator mode can generate chunks.
`static final GameRule<Boolean>`
`TNT_EXPLOSION_DROP_DECAY`
Whether tnt explosions will destroy dropped items.
`static final GameRule<Boolean>`
`UNIVERSAL_ANGER`
Whether mobs will target all player entities once angered.
`static final GameRule<Boolean>`
`WATER_SOURCE_CONVERSION`
Whether water blocks can convert into water source blocks.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`equals(Object obj)`
`static @Nullable GameRule<?>`
`getByName(@NotNull String rule)`
Get a `GameRule` by its name.
`@NotNull String`
`getName()`
Get the name of this GameRule.
`@NotNull Class<T>`
`getType()`
Get the type of this rule.
`String`
`toString()`
`@NotNull String`
`translationKey()`
Gets the translation key.
`static @NotNull GameRule<?>[]`
`values()`
Get an immutable collection of `GameRule`s.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### ANNOUNCE_ADVANCEMENTS

public static final GameRule<Boolean> ANNOUNCE_ADVANCEMENTS
Toggles the announcing of advancements.

### COMMAND_BLOCK_OUTPUT

public static final GameRule<Boolean> COMMAND_BLOCK_OUTPUT
Whether command blocks should notify admins when they perform commands.

### DISABLE_ELYTRA_MOVEMENT_CHECK

public static final GameRule<Boolean> DISABLE_ELYTRA_MOVEMENT_CHECK
Whether the server should skip checking player speed when the player is wearing elytra.

### DO_DAYLIGHT_CYCLE

public static final GameRule<Boolean> DO_DAYLIGHT_CYCLE
Whether time progresses from the current moment.

### DO_ENTITY_DROPS

public static final GameRule<Boolean> DO_ENTITY_DROPS
Whether entities that are not mobs should have drops.

### DO_FIRE_TICK

public static final GameRule<Boolean> DO_FIRE_TICK
Whether fire should spread and naturally extinguish.

### DO_LIMITED_CRAFTING

public static final GameRule<Boolean> DO_LIMITED_CRAFTING
Whether players should only be able to craft recipes they've unlocked first.

### DO_MOB_LOOT

public static final GameRule<Boolean> DO_MOB_LOOT
Whether mobs should drop items.

### DO_MOB_SPAWNING

public static final GameRule<Boolean> DO_MOB_SPAWNING
Whether mobs should naturally spawn.

### DO_TILE_DROPS

public static final GameRule<Boolean> DO_TILE_DROPS
Whether blocks should have drops.

### DO_WEATHER_CYCLE

public static final GameRule<Boolean> DO_WEATHER_CYCLE
Whether the weather will change from the current moment.

### KEEP_INVENTORY

public static final GameRule<Boolean> KEEP_INVENTORY
Whether the player should keep items in their inventory after death.

### LOG_ADMIN_COMMANDS

public static final GameRule<Boolean> LOG_ADMIN_COMMANDS
Whether to log admin commands to server log.

### MOB_GRIEFING

public static final GameRule<Boolean> MOB_GRIEFING
Whether mobs can pick up items or change blocks.

### NATURAL_REGENERATION

public static final GameRule<Boolean> NATURAL_REGENERATION
Whether players can regenerate health naturally through their hunger bar.

### REDUCED_DEBUG_INFO

public static final GameRule<Boolean> REDUCED_DEBUG_INFO
Whether the debug screen shows all or reduced information.

### SEND_COMMAND_FEEDBACK

public static final GameRule<Boolean> SEND_COMMAND_FEEDBACK
Whether the feedback from commands executed by a player should show up in chat. Also affects the default behavior of whether command blocks store their output text.

### SHOW_DEATH_MESSAGES

public static final GameRule<Boolean> SHOW_DEATH_MESSAGES
Whether a message appears in chat when a player dies.

### SPECTATORS_GENERATE_CHUNKS

public static final GameRule<Boolean> SPECTATORS_GENERATE_CHUNKS
Whether players in spectator mode can generate chunks.

### DISABLE_RAIDS

public static final GameRule<Boolean> DISABLE_RAIDS
Whether pillager raids are enabled or not.

### DO_INSOMNIA

public static final GameRule<Boolean> DO_INSOMNIA
Whether phantoms will appear without sleeping or not.

### DO_IMMEDIATE_RESPAWN

public static final GameRule<Boolean> DO_IMMEDIATE_RESPAWN
Whether clients will respawn immediately after death or not.

### DROWNING_DAMAGE

public static final GameRule<Boolean> DROWNING_DAMAGE
Whether drowning damage is enabled or not.

### FALL_DAMAGE

public static final GameRule<Boolean> FALL_DAMAGE
Whether fall damage is enabled or not.

### FIRE_DAMAGE

public static final GameRule<Boolean> FIRE_DAMAGE
Whether fire damage is enabled or not.

### FREEZE_DAMAGE

public static final GameRule<Boolean> FREEZE_DAMAGE
Whether freeze damage is enabled or not.

### DO_PATROL_SPAWNING

public static final GameRule<Boolean> DO_PATROL_SPAWNING
Whether patrols should naturally spawn.

### DO_TRADER_SPAWNING

public static final GameRule<Boolean> DO_TRADER_SPAWNING
Whether traders should naturally spawn.

### DO_WARDEN_SPAWNING

public static final GameRule<Boolean> DO_WARDEN_SPAWNING
Whether wardens should naturally spawn.

### FORGIVE_DEAD_PLAYERS

public static final GameRule<Boolean> FORGIVE_DEAD_PLAYERS
Whether mobs should cease being angry at a player once they die.

### UNIVERSAL_ANGER

public static final GameRule<Boolean> UNIVERSAL_ANGER
Whether mobs will target all player entities once angered.

### BLOCK_EXPLOSION_DROP_DECAY

public static final GameRule<Boolean> BLOCK_EXPLOSION_DROP_DECAY
Whether block explosions will destroy dropped items.

### MOB_EXPLOSION_DROP_DECAY

public static final GameRule<Boolean> MOB_EXPLOSION_DROP_DECAY
* Whether mob explosions will destroy dropped items.

### TNT_EXPLOSION_DROP_DECAY

public static final GameRule<Boolean> TNT_EXPLOSION_DROP_DECAY
Whether tnt explosions will destroy dropped items.

### WATER_SOURCE_CONVERSION

public static final GameRule<Boolean> WATER_SOURCE_CONVERSION
Whether water blocks can convert into water source blocks.

### LAVA_SOURCE_CONVERSION

public static final GameRule<Boolean> LAVA_SOURCE_CONVERSION
Whether lava blocks can convert into lava source blocks.

### GLOBAL_SOUND_EVENTS

public static final GameRule<Boolean> GLOBAL_SOUND_EVENTS
Whether global level events such as ender dragon, wither, and completed end portal effects will propagate across the entire server.

### RANDOM_TICK_SPEED

public static final GameRule<Integer> RANDOM_TICK_SPEED
How often a random block tick occurs (such as plant growth, leaf decay, etc.) per chunk section per game tick. 0 will disable random ticks, higher numbers will increase random ticks.

### SPAWN_RADIUS

public static final GameRule<Integer> SPAWN_RADIUS
The number of blocks outward from the world spawn coordinates that a player will spawn in when first joining a server or when dying without a spawnpoint.

### MAX_ENTITY_CRAMMING

public static final GameRule<Integer> MAX_ENTITY_CRAMMING
The maximum number of other pushable entities a mob or player can push, before taking suffocation damage.
Setting to 0 disables this rule.

### MAX_COMMAND_CHAIN_LENGTH

public static final GameRule<Integer> MAX_COMMAND_CHAIN_LENGTH
Determines the number at which the chain of command blocks act as a "chain."
This is the maximum amount of command blocks that can be activated in a single tick from a single chain.

### PLAYERS_SLEEPING_PERCENTAGE

public static final GameRule<Integer> PLAYERS_SLEEPING_PERCENTAGE
The percentage of online players which must be sleeping for the night to advance.

### SNOW_ACCUMULATION_HEIGHT

public static final GameRule<Integer> SNOW_ACCUMULATION_HEIGHT

## Method Details

### getName

@NotNull public @NotNull String getName()
Get the name of this GameRule.

Returns:
  the name of this GameRule

### getType

@NotNull public @NotNull Class<T> getType()
Get the type of this rule.

Returns:
  the rule type; Integer or Boolean

### equals

public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### getByName

@Nullable public static @Nullable GameRule<?> getByName(@NotNull @NotNull String rule)
Get a `GameRule` by its name.

Parameters:
  `rule` - the name of the GameRule
Returns:
  the `GameRule` or null if no GameRule matches the given name

### values

@NotNull public static @NotNull GameRule<?>[] values()
Get an immutable collection of `GameRule`s.

Returns:
  an immutable collection containing all registered GameRules.

### translationKey

@NotNull public @NotNull String translationKey()
Description copied from interface: `net.kyori.adventure.translation.Translatable`
Gets the translation key.

Specified by:
  `translationKey` in interface `Translatable`
Returns:
  the translation key