Class XGameRule<T>

java.lang.Object
com.cryptomorin.xseries.base.XModule<XGameRule<T>, String>
com.cryptomorin.xseries.XGameRule<T>
Type Parameters:
T - The type of the value that this game rule requires. Usually only Integer or Boolean (rarely String)
All Implemented Interfaces:
XBase<XGameRule<T>, String>

public final class XGameRule<T> extends XModule<XGameRule<T>, String>
The Bukkit GameRule class itself was added around Minecraft v1.13 so it's recommended to use the getValue(World) and setValue(World, Object) of this class instead of interacting with GameRule object directly or the methods provided in World as they've been changed.
Author:
Almighty-Satan
See Also:
  • GameRule
  • Field Details

    • COMMAND_BLOCK_OUTPUT

      public static final XGameRule<Boolean> COMMAND_BLOCK_OUTPUT
      Whether command blocks should notify admins when they perform commands. Controls if command block executions are broadcast to ops in chat.
    • ADVANCE_TIME

      public static final XGameRule<Boolean> ADVANCE_TIME
      Whether the daylight cycle and moon phases progress. Controls if time advances with day/night cycle.
    • ENTITY_DROPS

      public static final XGameRule<Boolean> ENTITY_DROPS
      Whether non-mob entities (like boats, minecarts, items from item frames) drop items when broken.
    • MOB_DROPS

      public static final XGameRule<Boolean> MOB_DROPS
      Whether mobs drop their loot (items and experience) when killed.
    • SPAWN_MOBS

      public static final XGameRule<Boolean> SPAWN_MOBS
      Whether mobs spawn naturally. Does not affect spawners or structure spawns.
    • BLOCK_DROPS

      public static final XGameRule<Boolean> BLOCK_DROPS
      Whether blocks drop items when broken (not by explosions or creative mode).
    • KEEP_INVENTORY

      public static final XGameRule<Boolean> KEEP_INVENTORY
      Whether players keep their inventory and experience after death.
    • LOG_ADMIN_COMMANDS

      public static final XGameRule<Boolean> LOG_ADMIN_COMMANDS
      Whether admin commands (like /give, /tp) are logged to the server log.
    • MOB_GRIEFING

      public static final XGameRule<Boolean> MOB_GRIEFING
      Whether mobs can grief the world (e.g., creepers explode blocks, endermen pick up blocks).
    • NATURAL_HEALTH_REGENERATION

      public static final XGameRule<Boolean> NATURAL_HEALTH_REGENERATION
      Whether players naturally regenerate health when hunger is full.
    • REDUCED_DEBUG_INFO

      public static final XGameRule<Boolean> REDUCED_DEBUG_INFO
      Whether reduced debug screen info is shown (hides coordinates, etc.).
    • SEND_COMMAND_FEEDBACK

      public static final XGameRule<Boolean> SEND_COMMAND_FEEDBACK
      Whether command feedback (success/failure messages) is sent to the player.
    • SHOW_DEATH_MESSAGES

      public static final XGameRule<Boolean> SHOW_DEATH_MESSAGES
      Whether death messages are shown in chat.
    • RANDOM_TICK_SPEED

      public static final XGameRule<Integer> RANDOM_TICK_SPEED
      Controls the rate of random block ticks (crop growth, leaf decay, etc.). Default is 3; higher values make processes faster.
    • SPECTATORS_GENERATE_CHUNKS

      @XInfo(since="1.9") public static final XGameRule<Boolean> SPECTATORS_GENERATE_CHUNKS
      Whether spectators generate new chunks when moving around.
    • ELYTRA_MOVEMENT_CHECK

      @XInfo(since="1.9") public static final XGameRule<Boolean> ELYTRA_MOVEMENT_CHECK
      Whether the server checks for elytra flight cheating (speed/movement validation). Set to false to disable the check.
    • RESPAWN_RADIUS

      @XInfo(since="1.9") public static final XGameRule<Integer> RESPAWN_RADIUS
      The radius around world spawn where players respawn if no bed.
    • ADVANCE_WEATHER

      @XInfo(since="1.11") public static final XGameRule<Boolean> ADVANCE_WEATHER
      Whether weather cycles (rain, thunder) progress naturally.
    • MAX_ENTITY_CRAMMING

      @XInfo(since="1.11") public static final XGameRule<Integer> MAX_ENTITY_CRAMMING
      Maximum number of entities that can be crammed in one block before taking suffocation damage.
    • LIMITED_CRAFTING

      @XInfo(since="1.12") public static final XGameRule<Boolean> LIMITED_CRAFTING
      Whether crafting recipes require the exact arrangement as discovered in the recipe book.
    • SHOW_ADVANCEMENT_MESSAGES

      @XInfo(since="1.12") public static final XGameRule<Boolean> SHOW_ADVANCEMENT_MESSAGES
      Whether advancement completion messages are announced in chat.
    • MAX_COMMAND_SEQUENCE_LENGTH

      @XInfo(since="1.12") public static final XGameRule<Integer> MAX_COMMAND_SEQUENCE_LENGTH
      Maximum length of a command chain (function or command block chain).
    • GAME_LOOP_FUNCTION

      @XInfo(since="1.12", removedSince="1.13") @Deprecated public static final XGameRule<String> GAME_LOOP_FUNCTION
      Deprecated.
      The function that runs every game tick.
    • RAIDS

      @XInfo(since="1.14.3") public static final XGameRule<Boolean> RAIDS
      Whether raids can occur (inverted: true disables raids).
    • SPAWN_PHANTOMS

      @XInfo(since="1.15") public static final XGameRule<Boolean> SPAWN_PHANTOMS
      Whether phantoms spawn from insomnia.
    • IMMEDIATE_RESPAWN

      @XInfo(since="1.15") public static final XGameRule<Boolean> IMMEDIATE_RESPAWN
      Whether players respawn immediately without the death screen.
    • DROWNING_DAMAGE

      @XInfo(since="1.15") public static final XGameRule<Boolean> DROWNING_DAMAGE
      Whether players take drowning damage.
    • FALL_DAMAGE

      @XInfo(since="1.15") public static final XGameRule<Boolean> FALL_DAMAGE
      Whether players take fall damage.
    • FIRE_DAMAGE

      @XInfo(since="1.15") public static final XGameRule<Boolean> FIRE_DAMAGE
      Whether players take fire/lava damage.
    • SPAWN_PATROLS

      @XInfo(since="1.15.2") public static final XGameRule<Boolean> SPAWN_PATROLS
      Whether pillager patrols spawn naturally.
    • SPAWN_WANDERING_TRADERS

      @XInfo(since="1.15.2") public static final XGameRule<Boolean> SPAWN_WANDERING_TRADERS
      Whether wandering traders spawn naturally.
    • FORGIVE_DEAD_PLAYERS

      @XInfo(since="1.16.1") public static final XGameRule<Boolean> FORGIVE_DEAD_PLAYERS
      Whether angered neutral mobs forgive players who die and respawn.
    • UNIVERSAL_ANGER

      @XInfo(since="1.16.1") public static final XGameRule<Boolean> UNIVERSAL_ANGER
      Whether angered neutral mobs attack any nearby player (universal anger).
    • FREEZE_DAMAGE

      @XInfo(since="1.17") public static final XGameRule<Boolean> FREEZE_DAMAGE
      Whether players take freeze damage in powder snow.
    • PLAYERS_SLEEPING_PERCENTAGE

      @XInfo(since="1.17") public static final XGameRule<Integer> PLAYERS_SLEEPING_PERCENTAGE
      Percentage of players that must sleep to skip the night.
    • SPAWN_WARDENS

      @XInfo(since="1.19") public static final XGameRule<Boolean> SPAWN_WARDENS
      Whether wardens spawn naturally in ancient cities.
    • BLOCK_EXPLOSION_DROP_DECAY

      @XInfo(since="1.19.3") public static final XGameRule<Boolean> BLOCK_EXPLOSION_DROP_DECAY
      Whether block explosion drops have decay (chance to not drop based on distance).
    • MOB_EXPLOSION_DROP_DECAY

      @XInfo(since="1.19.3") public static final XGameRule<Boolean> MOB_EXPLOSION_DROP_DECAY
      Whether mob (creeper/ghast) explosion drops have decay.
    • TNT_EXPLOSION_DROP_DECAY

      @XInfo(since="1.19.3") public static final XGameRule<Boolean> TNT_EXPLOSION_DROP_DECAY
      Whether TNT explosion drops have decay.
    • WATER_SOURCE_CONVERSION

      @XInfo(since="1.19.3") public static final XGameRule<Boolean> WATER_SOURCE_CONVERSION
      Whether water source blocks convert to flowing water under certain conditions.
    • LAVA_SOURCE_CONVERSION

      @XInfo(since="1.19.3") public static final XGameRule<Boolean> LAVA_SOURCE_CONVERSION
      Whether lava source blocks convert to flowing lava under certain conditions.
    • GLOBAL_SOUND_EVENTS

      @XInfo(since="1.19.3") public static final XGameRule<Boolean> GLOBAL_SOUND_EVENTS
      Whether certain sound events are heard globally by all players.
    • MAX_SNOW_ACCUMULATION_HEIGHT

      @XInfo(since="1.19.3") public static final XGameRule<Integer> MAX_SNOW_ACCUMULATION_HEIGHT
      Maximum height snow can accumulate in a single block.
    • SPREAD_VINES

      @XInfo(since="1.19.4") public static final XGameRule<Boolean> SPREAD_VINES
      Whether vines spread to adjacent blocks.
    • MAX_BLOCK_MODIFICATIONS

      @XInfo(since="1.19.4") public static final XGameRule<Integer> MAX_BLOCK_MODIFICATIONS
      Maximum number of block modifications allowed in a single command (anti-grief).
    • ENDER_PEARLS_VANISH_ON_DEATH

      @XInfo(since="1.20.2") public static final XGameRule<Boolean> ENDER_PEARLS_VANISH_ON_DEATH
      Whether ender pearls disappear when the player dies.
    • PROJECTILES_CAN_BREAK_BLOCKS

      @XInfo(since="1.20.3") public static final XGameRule<Boolean> PROJECTILES_CAN_BREAK_BLOCKS
      Whether projectiles (arrows, tridents, etc.) can break certain blocks.
    • MAX_COMMAND_FORKS

      @XInfo(since="1.20.3") public static final XGameRule<Integer> MAX_COMMAND_FORKS
      Maximum number of command forks allowed.
    • PLAYERS_NETHER_PORTAL_DEFAULT_DELAY

      @XInfo(since="1.20.3") public static final XGameRule<Integer> PLAYERS_NETHER_PORTAL_DEFAULT_DELAY
      Default delay (in ticks) for players entering Nether portals in survival/adventure.
    • PLAYERS_NETHER_PORTAL_CREATIVE_DELAY

      @XInfo(since="1.20.3") public static final XGameRule<Integer> PLAYERS_NETHER_PORTAL_CREATIVE_DELAY
      Delay (in ticks) for players in creative mode entering Nether portals.
    • SPAWN_CHUNK_RADIUS

      @XInfo(since="1.20.5", removedSince="1.21.9") @Deprecated public static final XGameRule<Integer> SPAWN_CHUNK_RADIUS
      Deprecated.
      Radius of spawn chunks that are always loaded.
    • PLAYER_MOVEMENT_CHECK

      @XInfo(since="1.21.2") public static final XGameRule<Boolean> PLAYER_MOVEMENT_CHECK
      Whether the server performs player movement validation checks.
    • MAX_MINECART_SPEED

      @XInfo(since="1.21.2") public static final XGameRule<Integer> MAX_MINECART_SPEED
      Maximum speed of minecarts.
    • TNT_EXPLODES

      @XInfo(since="1.21.5") public static final XGameRule<Boolean> TNT_EXPLODES
      Whether primed TNT explodes.
    • ALLOW_FIRE_TICKS_AWAY_FROM_PLAYER

      @XInfo(since="1.21.5", removedSince="1.21.11") @Deprecated public static final XGameRule<Boolean> ALLOW_FIRE_TICKS_AWAY_FROM_PLAYER
      Deprecated.
      Whether fire continues to tick/update when far from players.
    • LOCATOR_BAR

      @XInfo(since="1.21.6") public static final XGameRule<Boolean> LOCATOR_BAR
      Whether the locator bar (on maps?) is shown.
    • PVP

      @XInfo(since="1.21.9") public static final XGameRule<Boolean> PVP
      Whether PvP (player vs player damage) is enabled.
    • ALLOW_ENTERING_NETHER_USING_PORTALS

      @XInfo(since="1.21.9") public static final XGameRule<Boolean> ALLOW_ENTERING_NETHER_USING_PORTALS
      Whether players can enter the Nether using portals.
    • SPAWN_MONSTERS

      @XInfo(since="1.21.9") public static final XGameRule<Boolean> SPAWN_MONSTERS
      Whether hostile monsters spawn naturally.
    • COMMAND_BLOCKS_WORK

      @XInfo(since="1.21.9") public static final XGameRule<Boolean> COMMAND_BLOCKS_WORK
      Whether command blocks are enabled and can execute commands.
    • SPAWNER_BLOCKS_WORK

      @XInfo(since="1.21.9") public static final XGameRule<Boolean> SPAWNER_BLOCKS_WORK
      Whether monster spawners work and spawn mobs.
    • FIRE_SPREAD_RADIUS_AROUND_PLAYER

      @XInfo(since="1.21.11") public static final XGameRule<Integer> FIRE_SPREAD_RADIUS_AROUND_PLAYER
      Radius around players where fire spreads faster or is allowed.
    • DO_FIRE_TICK

      @XInfo(since="", removedSince="1.21.11") @Deprecated public static final XGameRule<Boolean> DO_FIRE_TICK
      Deprecated.
      Legacy rule: Whether fire spreads and burns blocks. Removed and replaced in 1.21.11 by newer fire rules.
      See Also:
  • Method Details

    • isSupported

      public boolean isSupported()
      Description copied from interface: XBase
      Checks if this sound is supported in the current Minecraft version.

      An invocation of this method yields exactly the same result as the expression:

      XBase.get() != null
      Returns:
      true if the current version has this sound, otherwise false.
    • getType

      @NotNull public @NotNull Class<?> getType()
      Returns the type of this game rule (either Boolean, Integer or String).
      Returns:
      The type of this game rule
    • getValue

      @Contract(pure=true) @Nullable public T getValue(@NotNull @NotNull org.bukkit.World world)
      Returns the value of this game rule.
      Parameters:
      world - The world from which the value should be fetched
      Returns:
      The value of this game rule
      Throws:
      UnsupportedOperationException - if isSupported() is false
    • setValue

      @Contract(mutates="param1") public void setValue(@NotNull @NotNull org.bukkit.World world, @NotNull T value)
      Set a game rule's value
      Parameters:
      world - The world in which this game rule should be updated
      value - The new value
      Throws:
      UnsupportedOperationException - If isSupported() is false
      IllegalArgumentException - If value parameter is not an instance of getType()
    • of

      @NotNull @Contract(pure=true) public static <T> @NotNull XGameRule<T> of(@NotNull @NotNull org.bukkit.GameRule<T> bukkit)
    • of

      @NotNull @Contract(pure=true) public static @NotNull Optional<XGameRule<?>> of(@NotNull @NotNull String bukkit)
    • getValues

      @NotNull @Contract(pure=true) public static @NotNull @Unmodifiable Collection<XGameRule<?>> getValues()