EzCountdownApi (interface)
Public service interface exposed by the plugin: com.skyblockexp.ezcountdown.api.EzCountdownApi
Methods
Countdown lifecycle
boolean startCountdown(String name)- Start a configured countdown by name. Returns
trueif started successfully,falseif the countdown was already running or does not exist.
- Start a configured countdown by name. Returns
boolean stopCountdown(String name)- Stop a running countdown by name. Returns
trueif stopped,falseif it was already stopped or does not exist.
- Stop a running countdown by name. Returns
Optional<Countdown> getCountdown(String name)- Retrieve a countdown configuration and runtime state by name.
Collection<Countdown> listCountdowns()- List all countdowns currently known to the plugin.
Countdown management
boolean createCountdown(Countdown countdown)- Create and persist a new countdown configuration. Returns
trueon success,falseif a countdown with the same name already exists.
- Create and persist a new countdown configuration. Returns
boolean createCountdown(CountdownType type, long durationSeconds, Collection<Player> targetPlayers)- Convenience overload: create an ephemeral countdown of the given type and duration, visible only to the specified players. Returns
trueon success.
- Convenience overload: create an ephemeral countdown of the given type and duration, visible only to the specified players. Returns
boolean deleteCountdown(String name)- Delete a configured countdown by name. Returns
truewhen deleted.
- Delete a configured countdown by name. Returns
Notifications
Optional<String> sendNotification(Notification notification)- Fire a one-shot ephemeral timed display notification. The notification runs for its configured duration then is removed automatically - it is never written to
countdowns.ymland does not appear in/countdown list. Returns anOptionalcontaining the generated internal name on success, or an emptyOptionalon name collision.
- Fire a one-shot ephemeral timed display notification. The notification runs for its configured duration then is removed automatically - it is never written to
Optional<String> sendNotification(Notification notification, Collection<Player> players)- Same as above, but restrict the notification to the specified players. Equivalent to building a
NotificationwithNotificationBuilder.players(players).
- Same as above, but restrict the notification to the specified players. Equivalent to building a
Exceptions
Methods return boolean flags or Optional on expected failures (e.g. countdown not found). The API also defines a typed exception hierarchy for use in builders and validation:
| Exception | Package | Description |
|---|---|---|
EzCountdownException | api.exception | Base class for all EzCountdown API exceptions |
CountdownNotFoundException | api.exception | A countdown name does not exist; carries getCountdownName() |
DuplicateCountdownException | api.exception | A countdown with this name already exists; carries getCountdownName() |
InvalidConfigurationException | api.exception | Thrown by NotificationBuilder.build() when duration is missing or invalid |
Usage example
RegisteredServiceProvider<EzCountdownApi> rsp =
Bukkit.getServicesManager().getRegistration(EzCountdownApi.class);
if (rsp != null) {
EzCountdownApi api = rsp.getProvider();
api.createCountdown(myCountdown);
api.startCountdown("myCountdownName");
}
Per-player notification:
List<Player> targets = List.of(player1, player2);
api.sendNotification(Notification.ofSeconds(30), targets);
Notes
- Changes made via the API are persisted using the plugin’s
countdowns.ymlstorage. - Ephemeral countdowns created by
sendNotificationare held in memory only; they are deleted automatically when they end and are never stored incountdowns.yml. createCountdown(CountdownType, long, Collection<Player>)creates an ephemeral (in-memory) countdown visible only to the provided players.