> For the complete documentation index, see [llms.txt](https://tanishisherewith.gitbook.io/dynamic-hud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tanishisherewith.gitbook.io/dynamic-hud/widget/dynamicvalueregistry.md).

# DynamicValueRegistry

The `DynamicValueRegistry`  is a shared registry used to provide changing values for widgets. Use it to register `Supplier` instances providing data (e.g., FPS, player names) in the `init` method of your `DynamicHudIntegration`.

The main purpose of this registry is to get data at runtime. Since data which depends on the game-state at runtime cannot be saved in a file, `DynamicValueRegistry` bridges this gap and offers an Identifier based data retrieval.

#### Usage

* **Registering**: Use any of the following function headers to register.

{% code title="DynamicValueRegistry.java" %}

```java
public static <T> void register(Identifier id, Supplier<T> supplier);

public static <T> void register(String namespace, String path, Supplier<T> supplier);
```

{% endcode %}

* **Retrieve Supplier**: Use any of the following function headers to retrieve a supplier.

{% code title="DynamicValueRegistry.java" %}

```java
public static <T> Supplier<T> get(Identifier id);

public static <T> Supplier<T> get(String namespace, String path);
```

{% endcode %}

* **Retrieve Value:** Use any of the following function headers to directly retrieve an object value  from supplier (return value may be null):

{% code title="DynamicValueRegistry.java" %}

```java
//Returns null when supplier not found or the supplier returned null.

@Nullable
public static <T> T getValue(Identifier id);

@Nullable
public static <T> T getValue(String namespace, String path);
```

{% endcode %}

* **Contains supplier**: Use the `boolean has(Identifier id)` function
* **Removing a Supplier:** Use the `remove(Identifier id)` / `removeNamespace(String namespace)` function
* **Retrieving all suppliers:** Use `keys()` to get an unmodifiable list of all registered identifiers.

***

{% hint style="info" %}
Extend your widget with `DynamicValueWidget` to let DynamicHUD  automatically manage `DynamicValueRegistry` to retrieve supplier data for you. (Gosh this is a lot of dynamic, someone please suggest a better name for these).
{% endhint %}
