Skip to main content

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);
}

}