use of com.gianlu.pyxreborn.Annotations.AdminOnly in project PretendYoureXyzzyReborn by devgianlu.
the class ConnectedUsers method kickUser.
/**
* Kicks an user from the server. Not allowing reconnection.
*/
@AdminOnly
public void kickUser(@NotNull User user, @Nullable KickReason reason) {
Game playingIn = server.games.playingIn(user);
if (playingIn != null) {
Player player = playingIn.findPlayerByNickname(user.nickname);
if (player != null)
server.games.kickPlayer(playingIn, player, reason);
}
WebSocket socket = server.findWebSocketByAddress(user.address);
if (socket == null)
return;
socket.close(CloseFrame.POLICY_VALIDATION, (reason == null ? KickReason.GENERAL_KICK : reason).toString());
}
use of com.gianlu.pyxreborn.Annotations.AdminOnly 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