Skip to content

The Snake API

The Snake exposes Bukkit events for round lifecycle changes, player input, score updates, and mutable statistic changes. Event classes live under dev.despical.snake.api.event and are dispatched synchronously on the primary server thread.



public final class SnakeIntegration extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
}

Add the dependency so your plugin loads after Snake:

softdepend:
- Snake

Use depend instead if your plugin cannot function without The Snake.


  • Events are synchronous Bukkit events.
  • GameStateChangeEvent and PlayerStatisticChangeEvent implement Cancellable; the other concrete events are informational.
  • GameStartEvent fires after the board, first segment, initial direction, and first apple are prepared.
  • GameEndEvent fires after the result is identified and its message is sent, but before the ending timer returns the player.
  • NewScoreEvent sees the already incremented score.

EventType enumerates the six registered event types. EventRegistry.getRegisteredTypes() returns an unmodifiable set, while getEventClass(type) and matches(type, event) support generic integration and diagnostic tooling. Normal Bukkit listeners should still register against concrete event classes.