Skip to content

Commit

Permalink
GH-52 Update EternalCore API (#52)
Browse files Browse the repository at this point in the history
* Add more classes to EternalCoreAPI, provide methods and `CatboyService` usage example

* Fix `markAsCatboy()` example

* Too many spaces
  • Loading branch information
CitralFlo authored Feb 7, 2024
1 parent f357944 commit a8b439e
Showing 1 changed file with 40 additions and 7 deletions.
47 changes: 40 additions & 7 deletions docs/eternalcore/using-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,19 @@ EternalCoreAPI eternalCoreAPI = EternalCoreApiProvider.provide();
After creating instance of api, the User gets access to various classes used in our plugin and methods.
Our API includes:

| Class | Provide method |
|------------|-----------------|
| AfkService | getAfkService() |
| Class | Provide method |
|------------------------|----------------------------|
| AfkService | getAfkService() |
| SpawnService | getSpawnService() |
| CatboyService | getCatboyService() |
| TeleportService | getTeleportService() |
| RandomTeleportService | getRandomTeleportService() |


### AfkService usage examples

The User can then use the methods of the given classes to create their own use cases. Here is an example how to obtain instance of `AfkService`:
The User can then use the methods of the given classes to create their own use cases.
Here is an example how to obtain instance of `AfkService`:

```java
public class YourPlugin extends JavaPlugin {
Expand All @@ -101,6 +106,7 @@ public class YourPlugin extends JavaPlugin {
public onEnable() {
this.eternalCoreApi = EternalCoreProvider.provide(); // [!code focus]
this.afkService = eternalCoreApi.getAfkService(); // [!code focus]
}
}
```
Expand All @@ -118,9 +124,36 @@ if (afkService.isAfk(player.getUniqueId())) {
Mark the player as afk if the player is not afk yet.

```java
if (!afkService.isAfk(player.getUniqueId)) {
Afk afkPlayer = afkService.markAfk(player.getUniqueId(), AfkReason.PLUGIN);
//marks player as afk and creates afk instance
if (!afkService.isAfk(player.getUniqueId())) {
Afk afkPlayer = afkService.markAfk(player.getUniqueId(), AfkReason.PLUGIN);
// marks player as afk and creates afk instance
}
```

### CatboyService usage example

The User can get other classes from `EternalCore` and use them in their own use cases.
Here is an example how to obtain instance of `CatboyService`:

```java
public class YourPlugin extends JavaPlugin {
private EternalCoreApi eternalCoreApi; // [!code focus]
private CatboyService catboyService; // [!code focus]
@Override
public onEnable() {
this.eternalCoreApi = EternalCoreProvider.provide(); // [!code focus]
this.catboyService = eternalCoreApi.getCatboyService(); // [!code focus]
}
}
```

Using the instance of `CatboyService` the User is able to mark players as catboys and give them unique feature provided by `EternalCore`.

```java
if (player.getName().equals("Rollczi")) {
catboyService.markAsCatboy(player, Cat.Type.BLACK); // [!code focus]
}
```

0 comments on commit a8b439e

Please sign in to comment.