Files
GeyserWebsite/docs/geyser/getting-started-with-the-api.md
T

86 lines
1.7 KiB
Markdown
Raw Normal View History

2021-12-12 14:16:38 +00:00
---
title: Getting Started with the API
2021-12-12 14:16:38 +00:00
---
To start, add the Open Collaboration repository to your project:
**Maven**
2021-12-12 14:16:38 +00:00
```xml
<repository>
<id>opencollab-snapshot</id>
<url>https://repo.opencollab.dev/main/</url>
2021-12-12 14:16:38 +00:00
</repository>
```
The "main" repository contains both release and snapshot versions.
**Gradle**
```groovy
repositories {
maven {
url = uri("https://repo.opencollab.dev/main/")
}
}
```
2021-12-12 14:16:38 +00:00
## Using Geyser
Add Geyser's API codebase as a dependency:
2021-12-12 14:16:38 +00:00
**Maven**
2021-12-12 14:16:38 +00:00
```xml
<dependency>
<groupId>org.geysermc.geyser</groupId>
<artifactId>api</artifactId>
<version>2.2.0-SNAPSHOT</version>
2021-12-12 14:16:38 +00:00
<scope>provided</scope>
</dependency>
```
**Gradle**
```groovy
dependencies {
compileOnly('org.geysermc.geyser:api:2.2.0-SNAPSHOT')
}
```
2021-12-12 14:16:38 +00:00
To get a Geyser player, or check if a player is from Bedrock:
```java
GeyserConnection connection = GeyserApi.api().connectionByUuid(uuid);
2021-12-12 14:16:38 +00:00
```
`connection` can be null if such a player does not exist on Geyser.
2021-12-12 14:16:38 +00:00
`GeyserApi.api()` may be null until after the Geyser plugin enables.
2021-12-12 14:16:38 +00:00
For more information on the Geyser API, see [here](/geyser/api/).
2021-12-12 14:16:38 +00:00
## Using Floodgate
2022-02-20 12:51:51 +00:00
This page has a very simple primer for the Floodgate API. For a full breakdown, see [here](/floodgate/api/).
2021-12-12 14:16:38 +00:00
Add Floodgate's API as a dependency:
**Maven**
2021-12-12 14:16:38 +00:00
```xml
<dependency>
<groupId>org.geysermc.floodgate</groupId>
<artifactId>api</artifactId>
<version>2.2.2-SNAPSHOT</version>
2021-12-12 14:16:38 +00:00
<scope>provided</scope>
</dependency>
```
**Gradle**
```groovy
dependencies {
compileOnly('org.geysermc.floodgate:api:2.2.2-SNAPSHOT')
}
```
2021-12-12 14:16:38 +00:00
Get the Floodgate API using:
```java
FloodgateApi api = FloodgateApi.getInstance();
api.isFloodgatePlayer(uuid);
2021-12-12 14:22:07 +00:00
```
For more information on the Floodgate API, see [here](/floodgate/api/).