# ✅ 条件

插件提供了强大的条件系统。您可以同时使用简单条件和复杂条件。以下是一些示例，供您学习条件使用。

复杂条件允许您在一个部分中使用更多相同类型的条件。

> 简单的生物群系条件

```yaml
biome:
  - minecraft:ocean
  - minecraft:deep_ocean
  - minecraft:cold_ocean
  - minecraft:deep_cold_ocean
  - minecraft:frozen_ocean
  - minecraft:deep_frozen_ocean
  - minecraft:lukewarm_ocean
  - minecraft:deep_lukewarm_ocean
  - minecraft:warm_ocean
```

> 复杂条件（允许您使用相同类型的条件） 部分名称（在本例中为“requirement\_biome\_1”）是完全可自定义的，只要它不与条件类型名称冲突即可。

```yaml
requirement_biome_1:
  type: biome
  value:
    - minecraft:ocean
    - minecraft:deep_ocean
    - minecraft:cold_ocean
    - minecraft:deep_cold_ocean
    - minecraft:frozen_ocean
    - minecraft:deep_frozen_ocean
    - minecraft:lukewarm_ocean
    - minecraft:deep_lukewarm_ocean
    - minecraft:warm_ocean
requirement_biome_2:
  type: '!biome'
  value:
    - minecraft:ocean
    - minecraft:deep_ocean
    - minecraft:cold_ocean
```

## 条件库

> 时间（Minecraft游戏时间 0\~23999）

```yaml
time:
  - 0~1000
  - 2000~6000

advanced_requirement:
  type: time
  value:
  - 0~1000
  - 2000~6000
```

> ypos（玩家的Y坐标）

```yaml
ypos:
  - 0~43
  - -45~12
  
advanced_requirement:
  type: ypos
  value:
  - 0~43
  - -45~12
```

> biome（支持自定义生物群系）

```yaml
biome:
  - minecraft:plains  <- 白名单

'!biome':
  - minecraft:plains  <- 黑名单

advanced_requirement:
  type: biome
  value:
  - minecraft:plains

advanced_requirement:
  type: '!biome'
  value:
  - minecraft:plains
```

> world

```yaml
world:
  - world

'!world':
  - blacklist_world

advanced_requirement:
  type: world
  value:
  - world

advanced_requirement:
  type: '!world'
  value:
  - blacklist_world
```

> weather

```yaml
weather:
  - thunder
  - clear
  - rain

advanced_requirement:
  type: 'weather'
  value:
  - thunder
  - clear
  - rain
```

> date（真实世界日期）

```yaml
date:
  - 12/25
  - 6/1

advanced_requirement:
  type: 'date'
  value:
  - 12/25
  - 6/1
```

> permission

```yaml
permission: customfishing.admin

'!permission': blacklist.perm

advanced_requirement:
  type: 'permission'
  value: customfishing.admin
  
advanced_requirement:
  type: '!permission'
  value: blacklist.perm
```

> “>” “>=” “<” “<=” “==” “!=”

```yaml
'==':
  value1: '20'
  value2: '%player_health%'

advanced_requirement:
  type: '='
  value:
    value1: '20'
    value2: '%player_health%'
```

> “startsWith” “endsWith” “equals” “contains” “in-list”

```yaml
'!startsWith':
  value1: '%player_name%'
  value2: 'X'  <- 不以 "X" 开头的玩家名字

advanced_requirement:
  type: 'contains'
  value:
    value1: '%player_name%'
    value2: '_'  <- 包含 "_" 的玩家名字

advanced_requirement:
  type: '!equals'
  value:
    value1: '%player_name%'
    value2: 'XiaoMoMi'  <- 玩家名字不等于 "XiaoMoMi"

advanced_requirement:
  type: 'in-list'
  value:
    papi: '%player_name%'
    values: 
      - 'XiaoMoMi'
      - 'XIAOMOMI'
      - 'XlA0M0Ml'
```

> logic（创建复杂条件）

```yaml
advanced_requirement:
  type: '&&'
  value:
    in-lava: true
    requirement_time:
      type: time
      value:
        - 0~12000
    '||':
      world:
        - world_nether
      '&&':
        ypos:
          - -64~-32
        world:
          - world
```

> level（玩家经验等级）

```yaml
level: 10

advanced_requirement:
  type: 'level'
  value: 10
```

> random（0\~1）

```yaml
random: 0.3   <- 30% 的概率

advanced_requirement:
  type: 'random'
  value: 0.7   <- 70% 的概率
```

> cooldown

```yaml
cooldown:
  key: unique
  time: 1000 #毫秒

advanced_requirement:
  type: 'cooldown'
  value:
    key: A
    time: 100 #毫秒
```

> regex

```yaml
regex:
  papi: %xxx%
  regex: "[A-Z]"

advanced_requirement:
  type: 'regex'
  value:
    papi: %xxx%
    regex: "[A-Z]"
```

> environment

```yaml
environment:
  - normal
  - nether
  - the_end
  
advanced_requirement:
  type: '!environment'
  value:
    - nether
    - the_end
    - custom
```

> potion-effect

```yaml
potion-effect: "LUCK>=0"

advanced_requirement:
  type: 'potion-effect'
  value: "LUCK!=-1"

"-1": 玩家没有这样的药水效果
"value 不低于 0": 药水效果的增幅

示例:
  LUCK==1
  LUCK<5
  LUCK>=0
```

> geyser（如果玩家是geyser玩家）

```yaml
geyser: false
  
advanced_requirement:
  type: 'geyser'
  value: true
```

> gamemode

```yaml
gamemode:
  - survival

advanced_requirement:
  type: "!gamemode"
  value:
  - adventure
```

> self-disguised（需要LibsDisguises）

```yaml
self-disguised: false
```

> disguised-type（需要LibsDisguises）

```yaml
'!disguised-type':
  - ARROW
```

> region （需要WorldGuard）

```yaml
advanced_requirement:
  type: region
  value:
    mode: 1 # 1,2
    values:
      - a
      - b
region:
  mode: 2
  values:
    - a
    - b
```

<figure><img src="https://content.gitbook.com/content/s87C1OsSEHzpv1XHzgIN/blobs/mJjYYNNTW1iU16UizAjG/image1.png" alt=""><figcaption><p>模式 1</p></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/s87C1OsSEHzpv1XHzgIN/blobs/fKUor73ULp8a00wuFqAm/image2.png" alt=""><figcaption><p>模式 2</p></figcaption></figure>

> is-passenger

```yaml
'is-passenger': true
```

> teammate (如果两名玩家在同一队)

```yaml
teammate: true
```
