Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.skyblockexp.lifesteal</groupId>
<artifactId>ezseasons-parent</artifactId>
<version>2.0.3</version>
<version>2.1.0</version>
</parent>

<artifactId>ezseasons-api</artifactId>
Expand All @@ -15,14 +15,7 @@
<name>EzSeasons API</name>
<description>Public API for EzSeasons integrations</description>

<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>${paper.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<dependencies/>

<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.skyblockexp.lifesteal.seasons.api;
package com.skyblockexp.lifesteal.seasons.api;

/**
* Interface for plugins to implement to integrate with EzSeasons.
* Register your implementation via {@link SeasonsApi#registerIntegration(SeasonsIntegration)}.
Expand All @@ -22,4 +22,19 @@ public interface SeasonsIntegration {
* @throws RuntimeException propagated to the unregistering caller; EzSeasons does not swallow or log it here
*/
void onUnregister();

/**
* Called after EzSeasons performs a season reset.
* <p>
* The default implementation is a no-op, so existing implementations are not required to override this method.
* <p>
* Threading: invoked on the same thread that triggered the reset (typically the Bukkit main thread).
*
* @param previousResetMillis unix epoch ms of the reset immediately before this one
* @param resetMillis unix epoch ms of this reset
* @param nextResetMillis unix epoch ms of the next scheduled reset, or {@code 0} if unscheduled
* @param reason caller-provided reason; never {@code null} — defaults to {@code "unspecified"}
*/
default void onSeasonReset(long previousResetMillis, long resetMillis, long nextResetMillis, String reason) {
}
}
13 changes: 8 additions & 5 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ You can use either GitHub Packages (official) or JitPack.
<dependency>
<groupId>com.skyblockexp.lifesteal</groupId>
<artifactId>ezseasons-api</artifactId>
<version>2.0.3</version>
<version>2.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand All @@ -61,15 +61,15 @@ You can use either GitHub Packages (official) or JitPack.
<dependency>
<groupId>com.github.ez-plugins.EzSeasons</groupId>
<artifactId>ezseasons-api</artifactId>
<version>v2.0.3</version>
<version>v2.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
```

## Threading

All public API methods are safe to call from concurrent threads — the integration registry is internally synchronized. However, **callbacks** (`onRegister`, `onUnregister`) and **Bukkit events** (`SeasonResetEvent`, etc.) are fired on the calling thread. In typical usage this is the Bukkit main thread.
All public API methods are safe to call from concurrent threads — the integration registry is internally synchronized. However, **callbacks** (`onRegister`, `onUnregister`, `onSeasonReset`) and **Bukkit events** (`SeasonResetEvent`, etc.) are fired on the calling thread. In typical usage this is the Bukkit main thread.

---

Expand All @@ -90,7 +90,7 @@ Public service interface registered as a Bukkit service. Obtain it via `Bukkit.g

- `registerIntegration` — registry is updated **before** `onRegister` is called and before `SeasonsIntegrationRegisteredEvent` fires.
- `unregisterIntegration` — registry is updated **before** `onUnregister` is called and before `SeasonsIntegrationUnregisteredEvent` fires.
- `triggerSeasonReset` — timestamps are persisted **before** `SeasonResetEvent` fires.
- `triggerSeasonReset` — timestamps are persisted **before** `SeasonResetEvent` fires and **before** `onSeasonReset` callbacks are invoked.

### `SeasonsIntegration`

Expand All @@ -100,13 +100,16 @@ Implement this interface in your plugin to receive registration lifecycle callba
|---|---|
| `onRegister(SeasonsApi api)` | Called after this integration is added to the EzSeasons registry. |
| `onUnregister()` | Called after this integration is removed from the EzSeasons registry. |
| `onSeasonReset(long previousResetMillis, long resetMillis, long nextResetMillis, String reason)` | Called after each season reset. Default no-op — override to react to resets without a Bukkit `@EventHandler`. |

Exceptions thrown from either callback propagate to the caller; EzSeasons does not swallow them.
Exceptions thrown from `onRegister` or `onUnregister` propagate to the caller; EzSeasons does not swallow them.

---

## Events

> **Note:** Event classes (`SeasonResetEvent`, `SeasonsIntegrationRegisteredEvent`, `SeasonsIntegrationUnregisteredEvent`) are shipped in the **plugin JAR**, not in the API artifact. If your plugin uses `@EventHandler` listeners directly, declare EzSeasons as a `softdepend` and add the plugin JAR as a `provided` compile dependency. For most integrations the `onSeasonReset` callback on `SeasonsIntegration` is sufficient and requires only the API artifact.

### `SeasonResetEvent`

Fired whenever EzSeasons performs a season reset (scheduled or forced). Fired **after** timestamps are updated and persisted.
Expand Down
2 changes: 1 addition & 1 deletion jitpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ jdk:
- openjdk25

install:
- ./mvnw --batch-mode --no-transfer-progress clean install -Dmaven.test.skip=true
- ./mvnw --batch-mode --no-transfer-progress clean install -pl api -Dmaven.test.skip=true
2 changes: 1 addition & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.skyblockexp.lifesteal</groupId>
<artifactId>ezseasons-parent</artifactId>
<version>2.0.3</version>
<version>2.1.0</version>
</parent>

<artifactId>ezseasons-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ public MessageService getMessageService() {
public SeasonManager getSeasonManager() {
return registry.getSeasonManager();
}

public SeasonsApiImpl getSeasonsApi() {
return registry.getSeasonsApi();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ public synchronized void triggerSeasonReset(String reason) {
if (Bukkit.getServer() != null) {
Bukkit.getPluginManager().callEvent(new SeasonResetEvent(previousReset, resetAt, nextResetMillis, reason));
}
final SeasonsApiImpl api = plugin != null ? plugin.getSeasonsApi() : null;
if (api != null) {
for (com.skyblockexp.lifesteal.seasons.api.SeasonsIntegration integration : api.getIntegrations()) {
integration.onSeasonReset(previousReset, resetAt, nextResetMillis,
reason != null ? reason : "unspecified");
}
}
if (broadcastMessage != null && !broadcastMessage.isBlank() && Bukkit.getServer() != null) {
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', broadcastMessage));
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.skyblockexp.lifesteal</groupId>
<artifactId>ezseasons-parent</artifactId>
<version>2.0.3</version>
<version>2.1.0</version>
<packaging>pom</packaging>

<name>EzSeasons</name>
Expand Down
Loading