# AdvancementProgressHelper

`com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper`

**Since:** 1.8.4

Progress of a player's advancement, including completed criteria and requirement groups.  
 
 Each group requires at least one completed criterion; all groups must be satisfied. Percentages
 count satisfied groups, and obtained-criterion timestamps are milliseconds since the epoch.  
 ```js
const player = Player.getPlayer();  
if (player !== null) {
  const manager = player.getAdvancementManager();  
  const progress = manager.getAdvancementProgress("minecraft:story/mine_stone");  
  if (progress.getRaw() === null) { throw new Error("no progress entry"); }

  if (progress.isDone()) {
    Chat.log("already earned");  
  } else {
    // the game's own "1/2" style text, straight from the tab, and null
    // when the advancement has a single group so guard it
    const fraction = progress.getFraction();  
    Chat.log(`progress: ${fraction === null ? "part way" : fraction.getString()}`);  

    // and what is actually left
    for (const criterion of progress.getUnobtainedCriteria()) {
      Chat.log(`still to do: ${criterion}`);  
    }
  }
}
 ```

## Constructors

### new AdvancementProgressHelper {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_constructor-AdvancementProgress-}

```js
new AdvancementProgressHelper(AdvancementProgress base)
```

Wraps the supplied advancement progress by storing it as this helper's base value.

**Parameters:**
- `base`: raw advancement progress to wrap

## Methods

### countObtainedRequirements {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_countObtainedRequirements-}

```js
countObtainedRequirements(): int
```

Number of requirement groups for which at least one criterion is completed.

**Returns:** the number of satisfied requirement groups.

**Since:** 1.8.4

### getCriteria {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_getCriteria-}

```js
getCriteria(): Map<String, Long>
```

Completed criteria and their completion times in milliseconds since the epoch.  
 The returned map is newly collected on each call; unmet criteria are omitted.

**Returns:** a map of every criterion that has been met, and when it was met.

**Since:** 1.8.4

### getCriterionProgress {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_getCriterionProgress-String-}

```js
getCriterionProgress(String criteria): long
```

Completion time for a named criterion, in milliseconds since the epoch. An unknown name
 returns `-1`; a known but incomplete criterion throws [NullPointerException](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/NullPointerException.html).

**Parameters:**
- `criteria`: criterion name

**Returns:** completion time in milliseconds since the epoch, or `-1` if the name is unknown

**Since:** 1.8.4

### getEarliestProgressObtainDate {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_getEarliestProgressObtainDate-}

```js
getEarliestProgressObtainDate(): long
```

Earliest completion time among this advancement's criteria, in milliseconds since the
 epoch. Throws [NullPointerException](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/NullPointerException.html) if no criterion has been completed.  
 ```js
const player = Player.getPlayer();  
if (player === null) { throw new Error("not in a world"); }
const manager = player.getAdvancementManager();  
const progress = manager.getAdvancementProgress("minecraft:story/mine_stone");  
if (progress.getRaw() === null) { throw new Error("no progress entry"); }
if (progress.isAnyObtained()) {
  const started = new Date(progress.getEarliestProgressObtainDate());  
  Chat.log(`first touched at ${started.toISOString()}`);  
}
 ```

**Returns:** the earliest completion date of all criteria.

**Since:** 1.8.4

### getFraction {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_getFraction-}

```js
getFraction(): TextHelper
```

Localized progress text for the requirement groups, or `null` when there are no
 criteria or at most one requirement group. See [getPercentage()](#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_getPercentage-) for a numeric value.

**Returns:** localized progress text, or `null` when unavailable.

**Since:** 1.8.4

### getObtainedCriteria {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_getObtainedCriteria-}

```js
getObtainedCriteria(): String[]
```

Names of completed criteria.

**Returns:** the names of completed criteria.

**Since:** 1.8.4

### getPercentage {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_getPercentage-}

```js
getPercentage(): float
```

Fraction of requirement groups satisfied, from `0` to `1`; an empty
 requirement set yields `0`.

**Returns:** the fraction of requirement groups satisfied.

**Since:** 1.8.4

### getRequirements {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_getRequirements-}

```js
getRequirements(): List<List<String>>
```

Requirement groups: each inner list contains alternative criteria, and every group must
 have at least one completed criterion.

**Returns:** all requirements of this advancement.

**Since:** 1.8.4

### getUnobtainedCriteria {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_getUnobtainedCriteria-}

```js
getUnobtainedCriteria(): String[]
```

Names of criteria that have not been completed.

**Returns:** the names of incomplete criteria.

**Since:** 1.8.4

### isAnyObtained {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_isAnyObtained-}

```js
isAnyObtained(): boolean
```

Whether at least one criterion has been completed, including for a finished advancement.

**Returns:** `true` if any criteria has already been met, `false` otherwise.

**Since:** 1.8.4

### isCriteriaObtained {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_isCriteriaObtained-String-}

```js
isCriteriaObtained(String criteria): boolean
```

Whether a named criterion is completed. An unknown criterion name throws
 [NullPointerException](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/NullPointerException.html).

**Parameters:**
- `criteria`: criterion name

**Returns:** `true` if completed; `false` if the criterion is known but incomplete

**Since:** 1.8.4

### isDone {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_isDone-}

```js
isDone(): boolean
```

Whether all requirement groups are satisfied. An empty requirement list is not done.

**Returns:** `true` if the advancement is finished, `false` otherwise.

**Since:** 1.8.4

### toString {#com.jsmacrosce.jsmacros.client.api.helper.AdvancementProgressHelper_toString-}

```js
toString(): String
```

Returns a diagnostic representation containing the advancement progress percentage.

**Returns:** diagnostic representation of advancement progress
