Minesweeper Events
info
The developer API currently only have events available, and the structure are subject to change.
List of eventsβ
- MinesweeperPlayerJoinEvent
- MinesweeperPlayerLeaveEvent
- MinesweeperPlayerPreJoinEvent
- MinesweeperPlayerSpectateEvent
- MinesweeperPlayerStopSpectateEvent
Examplesβ
MinesweeperPlayerPreJoinEventβ
Cancel joining if the player is not in the world spawn:
public class CancelJoinListener implements Listener {
@EventHandler
public void onPlayerJoin(MinesweeperPlayerPreJoinEvent event) {
Player player = event.getPlayer();
if (!player.getWorld().getName().equalsIgnoreCase("spawn")) {
// Optional if you want to send cancelled message, Support only MiniMessage.
// event.setCancelledMessage("You can only join the game in the spawn world!");
event.setCancelled(true);
}
}
}
MinesweeperPlayerSpectateEventβ
Set spectator spectate target to the game player:
public class SetSpectateTargetListener implements Listener {
@EventHandler
public void onSpectate(MinesweeperPlayerSpectateEvent event) {
Player player = event.getPlayer();
Player target = event.getTarget();
player.setGameMode(GameMode.SPECTATOR);
player.setSpectatorTarget(target);
}
}