> For the complete documentation index, see [llms.txt](https://impoo.gitbook.io/authenticationsystem/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://impoo.gitbook.io/authenticationsystem/developers/getting-started.md).

# Getting Started

This page shows you how to start using the AuthSystem API in your own plugin.

## Prerequisites

* Java 21
* Paper 1.21.8 (or compatible)
* Gradle 9.4.1 (or Maven)
* AuthSystem installed on the server

## Step 1: Add the dependency

Add AuthSystem as a dependency to your project. See [Installation](/authenticationsystem/developers/installation.md) for Maven and Gradle setup.

## Step 2: Obtain the API

AuthSystem provides a static entry point: `AuthSystemApi.get()`.

```java
import me.authsystem.api.AuthSystemApi;

AuthSystemApi api = AuthSystemApi.get();
```

{% hint style="warning" %}
`AuthSystemApi.get()` returns `null` if AuthSystem is not loaded. Always check for null before using the API.
{% endhint %}

```java
AuthSystemApi api = AuthSystemApi.get();
if (api == null) {
    getLogger().warning("AuthSystem is not loaded!");
    return;
}
```

## Step 3: Access the managers

Once you have the API, you can access the two main managers:

```java
AuthManager authManager = api.getAuthManager();
AuthTable authTable = api.getAuthTable();
```

* `AuthManager` — handles the authentication lifecycle (register, login, check state)
* `AuthTable` — handles database operations (returns `CompletableFuture`)

## Step 4: Check authentication state

```java
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    
    if (!authManager.isAuthenticated(player)) {
        player.sendMessage("§cPlease register or log in to play!");
    }
}
```

## Step 5: Wait for AuthSystem to load

If your plugin loads before AuthSystem, use the plugin manager to wait:

```java
@Override
public void onEnable() {
    Plugin authSystem = getServer().getPluginManager().getPlugin("AuthSystem");
    if (authSystem != null && authSystem.isEnabled()) {
        initApi();
    } else {
        getServer().getPluginManager().registerEvents(new Listener() {
            @EventHandler
            public void onPluginEnable(PluginEnableEvent event) {
                if (event.getPlugin().getName().equals("AuthSystem")) {
                    initApi();
                }
            }
        }, this);
    }
}

private void initApi() {
    AuthSystemApi api = AuthSystemApi.get();
    // use the API
}
```

## Next steps

* Read the [API Reference](/authenticationsystem/developers/api-reference.md) for an overview
* Check [AuthManager](/authenticationsystem/developers/authmanager.md) for authentication methods
* Check [AuthTable](/authenticationsystem/developers/authtable.md) for database methods
* See [Examples](/authenticationsystem/developers/examples.md) for practical code

***

> :bulb: **Tip**: Always verify that `AuthSystemApi.get()` is not null before calling any API methods.
