# Feature System

The Feature System defines how runtime behavior is implemented in OMS.

A feature is the core unit of logic. It reacts to events and may trigger actions.

***

### Overview

A feature:

* implements behavior
* listens to lifecycle events
* may trigger actions
* may register custom commands
* may subscribe external event listeners\*

{% hint style="info" %}
Note: External Event Listeners

Features may register external event listeners through `OmsFeature.createEventListeners()`.

These listeners are registered on the Forge event bus independently of the feature enabled state.\
If a listener should only execute while the feature is enabled, the feature must enforce that explicitly.
{% endhint %}

Features are registered by addons and executed by the `FeatureManager`.

***

### Core Types

#### OmsFeature

`OmsFeature` is the base class for implementing feature logic.\
Combines lifecycle handling, configuration, commands, and info.

{% @github-files/github-code-block url="<https://github.com/c0nnor263/OperateMyServer/blob/main/oms-api/src/main/kotlin/io/conboi/oms/api/foundation/feature/OmsFeature.kt>" %}

***

#### FeatureLifecycle

`FeatureLifecycle` defines lifecycle callbacks used by features.

{% @github-files/github-code-block url="<https://github.com/c0nnor263/OperateMyServer/blob/main/oms-api/src/main/kotlin/io/conboi/oms/api/foundation/feature/FeatureLifecycle.kt>" %}

***

#### FeatureInfo

`FeatureInfo` describes feature metadata used for registration and diagnostics.

{% @github-files/github-code-block url="<https://github.com/c0nnor263/OperateMyServer/blob/main/oms-api/src/main/kotlin/io/conboi/oms/api/foundation/feature/FeatureInfo.kt>" %}

***

#### ConfigWatcher

`ConfigWatcher` provides utilities for tracking configuration changes.

{% @github-files/github-code-block url="<https://github.com/c0nnor263/OperateMyServer/blob/main/oms-api/src/main/kotlin/io/conboi/oms/api/foundation/feature/ConfigWatcher.kt>" %}

***

#### Priority

`Priority` defines feature execution order.

{% @github-files/github-code-block url="<https://github.com/c0nnor263/OperateMyServer/blob/main/oms-api/src/main/kotlin/io/conboi/oms/api/foundation/feature/Priority.kt>" %}

***

### Lifecycle

1. Feature is registered by an addon
2. Feature is managed by a `FeatureManager`
3. Feature receives lifecycle events
4. Feature executes logic
5. Feature may trigger actions

***

### Notes

* Features contain all runtime logic
* Addons only group features
* Execution is coordinated by the `FeatureManager`
* Configuration is initialized during the lifecycle


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://conboi.gitbook.io/oms-wiki/developer-guide/core-architecture/feature-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
