程序包 org.bukkit

# 类 GameRule<T>

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

类型参数:
  `T` - 游戏规则数值类型 (布尔值或整数)

public final class GameRule<T> extends Object
游戏规则控制着Minecraft自身的某些行为.
欲了解更多信息请访问 Minecraft Wiki

版权说明:以下常量翻译大部分引自 Minecraft Wiki.

- ## 字段概要

  字段
  修饰符和类型
  字段
  说明
  `static final GameRule<Boolean>`
  `ANNOUNCE_ADVANCEMENTS`
  是否在聊天框中公告玩家进度的达成.
  `static final GameRule<Boolean>`
  `BLOCK_EXPLOSION_DROP_DECAY`
  Whether block explosions will destroy dropped items.
  `static final GameRule<Boolean>`
  `COMMAND_BLOCK_OUTPUT`
  命令方块执行命令时是否在聊天框中向管理员显示.
  `static final GameRule<Integer>`
  `COMMAND_MODIFICATION_BLOCK_LIMIT`
  Determines the maximum number of blocks which a command can modify.
  `static final GameRule<Boolean>`
  `DISABLE_ELYTRA_MOVEMENT_CHECK`
  是否让服务器停止检查使用鞘翅玩家的移动速度.
  `static final GameRule<Boolean>`
  `DISABLE_RAIDS`
  是否禁用袭击.
  `static final GameRule<Boolean>`
  `DO_DAYLIGHT_CYCLE`
  是否进行日夜交替和月相变化.
  `static final GameRule<Boolean>`
  `DO_ENTITY_DROPS`
  非生物实体是否掉落物品.
  `static final GameRule<Boolean>`
  `DO_FIRE_TICK`
  火是否蔓延及自然熄灭.
  `static final GameRule<Boolean>`
  `DO_IMMEDIATE_RESPAWN`
  玩家死亡时是否不显示死亡界面直接重生.
  `static final GameRule<Boolean>`
  `DO_INSOMNIA`
  幻翼是否在夜晚生成.
  `static final GameRule<Boolean>`
  `DO_LIMITED_CRAFTING`
  玩家的合成配方是否需要解锁才能使用.
  `static final GameRule<Boolean>`
  `DO_MOB_LOOT`
  生物在死亡是否掉落物品 (战利品).
  `static final GameRule<Boolean>`
  `DO_MOB_SPAWNING`
  生物是否自然生成.
  `static final GameRule<Boolean>`
  `DO_PATROL_SPAWNING`
  灾厄巡逻队是否自然生成.
  `static final GameRule<Boolean>`
  `DO_TILE_DROPS`
  方块被破坏时是否掉落物品.
  `static final GameRule<Boolean>`
  `DO_TRADER_SPAWNING`
  流浪商人是否自然生成.
  `static final GameRule<Boolean>`
  `DO_VINES_SPREAD`
  Whether vines will spread.
  `static final GameRule<Boolean>`
  `DO_WARDEN_SPAWNING`
  Whether wardens should naturally spawn.
  `static final GameRule<Boolean>`
  `DO_WEATHER_CYCLE`
  天气是否变化.
  `static final GameRule<Boolean>`
  `DROWNING_DAMAGE`
  玩家是否承受窒息伤害.
  `static final GameRule<Boolean>`
  `ENDER_PEARLS_VANISH_ON_DEATH`
  Whether ender pearls will vanish on player death.
  `static final GameRule<Boolean>`
  `FALL_DAMAGE`
  玩家是否承受跌落伤害.
  `static final GameRule<Boolean>`
  `FIRE_DAMAGE`
  玩家是否承受火焰伤害.
  `static final GameRule<Boolean>`
  `FORGIVE_DEAD_PLAYERS`
  当被激怒的中立生物的目标玩家死亡时, 此生物是否恢复中立状态.
  `static final GameRule<Boolean>`
  `FREEZE_DAMAGE`
  玩家是否承受冰冻伤害.
  `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`
  玩家死亡后是否保留物品栏物品 (死亡时物品不掉落).
  `static final GameRule<Boolean>`
  `LAVA_SOURCE_CONVERSION`
  Whether lava blocks can convert into lava source blocks.
  `static final GameRule<Boolean>`
  `LOG_ADMIN_COMMANDS`
  是否在服务器日志中记录管理员使用过的命令.
  `static final GameRule<Integer>`
  `MAX_COMMAND_CHAIN_LENGTH`
  指定工作在连锁模式的命令方块的总数量.
  `static final GameRule<Integer>`
  `MAX_COMMAND_FORK_COUNT`
  Determines the number of different commands/functions which execute commands can fork into.
  `static final GameRule<Integer>`
  `MAX_ENTITY_CRAMMING`
  玩家或生物能同时推动其它可推动实体的数量, 超过此数量时将承受窒息伤害.
  `static final GameRule<Boolean>`
  `MOB_EXPLOSION_DROP_DECAY`
  * Whether mob explosions will destroy dropped items.
  `static final GameRule<Boolean>`
  `MOB_GRIEFING`
  生物能否捡起物品, 修改以及破坏方块.
  `static final GameRule<Boolean>`
  `NATURAL_REGENERATION`
  玩家是否能在饥饿值足够时自然恢复生命值 (不影响外部治疗效果, 如金苹果、生命恢复状态效果等).
  `static final GameRule<Integer>`
  `PLAYERS_NETHER_PORTAL_CREATIVE_DELAY`
  The amount of time a player in creative mode must stand in a nether portal before the portal activates.
  `static final GameRule<Integer>`
  `PLAYERS_NETHER_PORTAL_DEFAULT_DELAY`
  The amount of time a player must stand in a nether portal before the portal activates.
  `static final GameRule<Integer>`
  `PLAYERS_SLEEPING_PERCENTAGE`
  服务器跳过夜晚所需的入睡玩家的占比.
  `static final GameRule<Boolean>`
  `PROJECTILES_CAN_BREAK_BLOCKS`
  Whether projectiles can break blocks.
  `static final GameRule<Integer>`
  `RANDOM_TICK_SPEED`
  每游戏刻每区块中随机的方块刻发生的频率 (例如植物生长，树叶腐烂等).
  `static final GameRule<Boolean>`
  `REDUCED_DEBUG_INFO`
  调式屏幕是否显示简化的信息而非详细信息.
  `static final GameRule<Boolean>`
  `SEND_COMMAND_FEEDBACK`
  玩家执行命令的返回信息是否在聊天框中显示.
  `static final GameRule<Boolean>`
  `SHOW_DEATH_MESSAGES`
  是否在聊天框中显示玩家以及驯养宠物的死亡信息.
  `static final GameRule<Integer>`
  `SNOW_ACCUMULATION_HEIGHT`
  `static final GameRule<Integer>`
  `SPAWN_CHUNK_RADIUS`
  The number of chunks around spawn which will be kept loaded at all times.
  `static final GameRule<Integer>`
  `SPAWN_RADIUS`
  首次进入服务器的玩家和没有重生点的死亡玩家在重生时与世界重生点坐标的距离.
  `static final GameRule<Boolean>`
  `SPECTATORS_GENERATE_CHUNKS`
  是否允许旁观模式的玩家生成区块.
  `static final GameRule<Boolean>`
  `TNT_EXPLOSION_DROP_DECAY`
  Whether tnt explosions will destroy dropped items.
  `static final GameRule<Boolean>`
  `UNIVERSAL_ANGER`
  当中立生物被激怒时, 是否攻击附近所有玩家 (而不仅仅是激怒此生物的玩家).
  `static final GameRule<Boolean>`
  `WATER_SOURCE_CONVERSION`
  Whether water blocks can convert into water source blocks.

- ## 方法概要

  修饰符和类型
  方法
  说明
  `boolean`
  `equals(Object obj)`
  `static @Nullable GameRule<?>`
  `getByName(@NotNull String rule)`
  按名称获取`游戏规则`.
  `@NotNull String`
  `getName()`
  获取此游戏规则的名称.
  `@NotNull Class<T>`
  `getType()`
  获取此游戏规则的数据类型.
  `String`
  `toString()`
  `static @NotNull GameRule<?>[]`
  `values()`
  获取一个不可变的`游戏规则`集合.

  ### 从类继承的方法 java.lang.Object

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

- ## 字段详细资料

  - ### ANNOUNCE_ADVANCEMENTS

    public static final GameRule<Boolean> ANNOUNCE_ADVANCEMENTS
    是否在聊天框中公告玩家进度的达成.

  - ### COMMAND_BLOCK_OUTPUT

    public static final GameRule<Boolean> COMMAND_BLOCK_OUTPUT
    命令方块执行命令时是否在聊天框中向管理员显示.

  - ### DISABLE_ELYTRA_MOVEMENT_CHECK

    public static final GameRule<Boolean> DISABLE_ELYTRA_MOVEMENT_CHECK
    是否让服务器停止检查使用鞘翅玩家的移动速度. 有助于减轻因服务器延迟而导致的飞行卡顿, 但有可能导致生存模式下玩家飞行过快 (作弊).

  - ### DO_DAYLIGHT_CYCLE

    public static final GameRule<Boolean> DO_DAYLIGHT_CYCLE
    是否进行日夜交替和月相变化.

  - ### DO_ENTITY_DROPS

    public static final GameRule<Boolean> DO_ENTITY_DROPS
    非生物实体是否掉落物品.

  - ### DO_FIRE_TICK

    public static final GameRule<Boolean> DO_FIRE_TICK
    火是否蔓延及自然熄灭.

  - ### DO_LIMITED_CRAFTING

    public static final GameRule<Boolean> DO_LIMITED_CRAFTING
    玩家的合成配方是否需要解锁才能使用.

  - ### DO_MOB_LOOT

    public static final GameRule<Boolean> DO_MOB_LOOT
    生物在死亡是否掉落物品 (战利品).

  - ### PROJECTILES_CAN_BREAK_BLOCKS

    public static final GameRule<Boolean> PROJECTILES_CAN_BREAK_BLOCKS
    Whether projectiles can break blocks.

  - ### DO_MOB_SPAWNING

    public static final GameRule<Boolean> DO_MOB_SPAWNING
    生物是否自然生成. 不影响刷怪箱.

  - ### DO_TILE_DROPS

    public static final GameRule<Boolean> DO_TILE_DROPS
    方块被破坏时是否掉落物品.

  - ### DO_WEATHER_CYCLE

    public static final GameRule<Boolean> DO_WEATHER_CYCLE
    天气是否变化.

  - ### KEEP_INVENTORY

    public static final GameRule<Boolean> KEEP_INVENTORY
    玩家死亡后是否保留物品栏物品 (死亡时物品不掉落).

  - ### LOG_ADMIN_COMMANDS

    public static final GameRule<Boolean> LOG_ADMIN_COMMANDS
    是否在服务器日志中记录管理员使用过的命令.

  - ### MOB_GRIEFING

    public static final GameRule<Boolean> MOB_GRIEFING
    生物能否捡起物品, 修改以及破坏方块.

    译注:Mob包括的实体详见`Mob接口文档`.

  - ### NATURAL_REGENERATION

    public static final GameRule<Boolean> NATURAL_REGENERATION
    玩家是否能在饥饿值足够时自然恢复生命值 (不影响外部治疗效果, 如金苹果、生命恢复状态效果等).

  - ### REDUCED_DEBUG_INFO

    public static final GameRule<Boolean> REDUCED_DEBUG_INFO
    调式屏幕是否显示简化的信息而非详细信息.

  - ### SEND_COMMAND_FEEDBACK

    public static final GameRule<Boolean> SEND_COMMAND_FEEDBACK
    玩家执行命令的返回信息是否在聊天框中显示. 同时影响命令方块是否保存命令输出文本.

  - ### SHOW_DEATH_MESSAGES

    public static final GameRule<Boolean> SHOW_DEATH_MESSAGES
    是否在聊天框中显示玩家以及驯养宠物的死亡信息.

  - ### SPECTATORS_GENERATE_CHUNKS

    public static final GameRule<Boolean> SPECTATORS_GENERATE_CHUNKS
    是否允许旁观模式的玩家生成区块.

  - ### DISABLE_RAIDS

    public static final GameRule<Boolean> DISABLE_RAIDS
    是否禁用袭击.

  - ### DO_INSOMNIA

    public static final GameRule<Boolean> DO_INSOMNIA
    幻翼是否在夜晚生成.

  - ### DO_IMMEDIATE_RESPAWN

    public static final GameRule<Boolean> DO_IMMEDIATE_RESPAWN
    玩家死亡时是否不显示死亡界面直接重生.

  - ### DROWNING_DAMAGE

    public static final GameRule<Boolean> DROWNING_DAMAGE
    玩家是否承受窒息伤害.

  - ### FALL_DAMAGE

    public static final GameRule<Boolean> FALL_DAMAGE
    玩家是否承受跌落伤害.

  - ### FIRE_DAMAGE

    public static final GameRule<Boolean> FIRE_DAMAGE
    玩家是否承受火焰伤害.

  - ### FREEZE_DAMAGE

    public static final GameRule<Boolean> FREEZE_DAMAGE
    玩家是否承受冰冻伤害.

  - ### DO_PATROL_SPAWNING

    public static final GameRule<Boolean> DO_PATROL_SPAWNING
    灾厄巡逻队是否自然生成.

  - ### DO_TRADER_SPAWNING

    public static final GameRule<Boolean> DO_TRADER_SPAWNING
    流浪商人是否自然生成.

  - ### 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
    当被激怒的中立生物的目标玩家死亡时, 此生物是否恢复中立状态.

  - ### UNIVERSAL_ANGER

    public static final GameRule<Boolean> UNIVERSAL_ANGER
    当中立生物被激怒时, 是否攻击附近所有玩家 (而不仅仅是激怒此生物的玩家).

  - ### 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.

  - ### DO_VINES_SPREAD

    public static final GameRule<Boolean> DO_VINES_SPREAD
    Whether vines will spread.

  - ### ENDER_PEARLS_VANISH_ON_DEATH

    public static final GameRule<Boolean> ENDER_PEARLS_VANISH_ON_DEATH
    Whether ender pearls will vanish on player death.

  - ### RANDOM_TICK_SPEED

    public static final GameRule<Integer> RANDOM_TICK_SPEED
    每游戏刻每区块中随机的方块刻发生的频率 (例如植物生长，树叶腐烂等). 为0时禁用随机刻, 较高的数字将增大随机刻频率.

  - ### SPAWN_RADIUS

    public static final GameRule<Integer> SPAWN_RADIUS
    首次进入服务器的玩家和没有重生点的死亡玩家在重生时与世界重生点坐标的距离.

  - ### MAX_ENTITY_CRAMMING

    public static final GameRule<Integer> MAX_ENTITY_CRAMMING
    玩家或生物能同时推动其它可推动实体的数量, 超过此数量时将承受窒息伤害.
    设置成0可以停用这个规则.

  - ### MAX_COMMAND_CHAIN_LENGTH

    public static final GameRule<Integer> MAX_COMMAND_CHAIN_LENGTH
    指定工作在连锁模式的命令方块的总数量.
    该值是在同一连锁同一tick时可激活的最大命令方块数量.

  - ### MAX_COMMAND_FORK_COUNT

    public static final GameRule<Integer> MAX_COMMAND_FORK_COUNT
    Determines the number of different commands/functions which execute commands can fork into.

  - ### COMMAND_MODIFICATION_BLOCK_LIMIT

    public static final GameRule<Integer> COMMAND_MODIFICATION_BLOCK_LIMIT
    Determines the maximum number of blocks which a command can modify.

  - ### PLAYERS_SLEEPING_PERCENTAGE

    public static final GameRule<Integer> PLAYERS_SLEEPING_PERCENTAGE
    服务器跳过夜晚所需的入睡玩家的占比.

  - ### SNOW_ACCUMULATION_HEIGHT

    public static final GameRule<Integer> SNOW_ACCUMULATION_HEIGHT

  - ### PLAYERS_NETHER_PORTAL_DEFAULT_DELAY

    public static final GameRule<Integer> PLAYERS_NETHER_PORTAL_DEFAULT_DELAY
    The amount of time a player must stand in a nether portal before the portal activates.

  - ### PLAYERS_NETHER_PORTAL_CREATIVE_DELAY

    public static final GameRule<Integer> PLAYERS_NETHER_PORTAL_CREATIVE_DELAY
    The amount of time a player in creative mode must stand in a nether portal before the portal activates.

  - ### SPAWN_CHUNK_RADIUS

    public static final GameRule<Integer> SPAWN_CHUNK_RADIUS
    The number of chunks around spawn which will be kept loaded at all times.

- ## 方法详细资料

  - ### getName

    @NotNull public @NotNull String getName()
    获取此游戏规则的名称.

    原文:Get the name of this GameRule.

    返回:
      游戏规则名

  - ### getType

    @NotNull public @NotNull Class<T> getType()
    获取此游戏规则的数据类型.

    原文:Get the type of this rule.

    返回:
      游戏规则的数据类型;Integer 或 Boolean

  - ### equals

    public boolean equals(Object obj)
    覆盖:
      `equals` 在类中 `Object`

  - ### toString

    public String toString()
    覆盖:
      `toString` 在类中 `Object`

  - ### getByName

    @Nullable public static @Nullable GameRule<?> getByName(@NotNull @NotNull String rule)
    按名称获取`游戏规则`.

    原文:Get a `GameRule` by its name.

    参数:
      `rule` - 游戏规则名
    返回:
      `游戏规则`, 若没有与给定名称相匹配的GameRule返回null

  - ### values

    @NotNull public static @NotNull GameRule<?>[] values()
    获取一个不可变的`游戏规则`集合.

    原文:Get an immutable collection of `GameRule`s.

    返回:
      包含所有已注册游戏规则的不可变集合