use of com.gianlu.pyxreborn.Models.Player in project PretendYoureXyzzyReborn by devgianlu.
the class Games method kickPlayer.
/**
* Kicks a player from the game.
*/
public void kickPlayer(@NotNull Game game, @NotNull Player user, KickReason reason) {
for (Player player : game.players) {
if (Objects.equals(player, user)) {
game.players.remove(user);
JsonObject obj = new JsonObject();
obj.addProperty(Fields.KICKED.toString(), reason.toString());
server.sendMessage(user.user, obj);
}
}
}
use of com.gianlu.pyxreborn.Models.Player in project PretendYoureXyzzyReborn by devgianlu.
the class Games method killGame.
/**
* Kills the game, kicking everyone and deleting the game
*/
@AdminOnly
public void killGame(@NotNull Game game, KickReason majorReason) {
GameManager manager = managedGames.findGameManagerByGameId(game.gid);
if (manager != null) {
try {
manager.stop();
} catch (GeneralException ignored) {
}
}
if (!game.players.isEmpty()) {
for (Player player : game.players) {
kickPlayer(game, player, majorReason);
}
}
if (!game.spectators.isEmpty()) {
for (User spectator : game.spectators) {
kickSpectator(game, spectator, majorReason);
}
}
if (manager != null)
managedGames.remove(manager);
remove(game);
server.broadcastMessage(Utils.event(Events.GAME_REMOVED));
}
Aggregations