Developer API
MCHockey provides a comprehensive API for developers to integrate with the plugin programmatically.
Installation Required
The API is not published to Maven Central. You must reference the MCHockey.jar file directly in your project.
🚀 Quick Setup
1. Plugin Dependency
Add MCHockey as a soft dependency in your plugin.yml:
softdepend: [ MCHockey ]
2. Basic Usage
Access MCHockey services through Bukkit's ServiceManager:
public class YourPlugin extends JavaPlugin {
@Override
public void onEnable() {
Player player = Bukkit.getPlayer("YourPlayerName");
// Creating a ball for your custom use case (MiniGame, Lobby Ball, etc.)
HockeyBallService hockeyBallService = Bukkit.getServicesManager().load(HockeyBallService.class);
// Create a file MCHockey/ball/my_custom_ball.yml and design your ball
String ballName = "my_custom_ball";
Location spawnLocation = player.getLocation();
// The hockey ball is already ready and can be played by any player.
HockeyBall hockeyBall = hockeyBallService.spawn(ballName, spawnLocation);
// You can additionally move it by code.
hockeyBall.setVelocity(new Vector(0.3, 0.3, 0.2));
// Teleporting does only work in the same world.
hockeyBall.teleport(player.getLocation().add(1.0, 0.0, 0.0));
// Letting a player join a game.
GameService gameService = Bukkit.getServicesManager().load(GameService.class);
HockeyGame game = gameService.getByName("myGameName");
game.join(player, Team.BLUE);
}
}
🎯 Core Services
| Service | Purpose |
|---|---|
| GameService | Manage games, get game instances, player management |
| HockeyBallFactory | Create and manage hockey balls outside of games |
📡 Event System
MCHockey broadcasts various events that you can listen to:
- Game Events: Start, end, goal scored, player join/leave
- Ball Events: Kick, pass, interaction
- Player Events: Team switch, respawn
View all available events in the GitHub repository.
📚 Documentation
For detailed API documentation and method signatures, refer to the MCHockey source code on GitHub or use your IDE's intellisense when the plugin is loaded.