use of com.voxelgameslib.voxelgameslib.event.events.game.GameJoinEvent in project VoxelGamesLibv2 by VoxelGamesLib.
the class AbstractGame method join.
@Override
public boolean join(@Nonnull User user) {
if (!getActivePhase().allowJoin() || getMaxPlayers() == players.size()) {
return spectate(user);
}
if (!isPlaying(user.getUuid())) {
players.add(user);
allUsers.add(user);
playerStates.put(user.getUuid(), PlayerState.of(user));
GameJoinEvent event = new GameJoinEvent(this, user);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
players.remove(user);
allUsers.remove(user);
return false;
}
broadcastMessage(LangKey.GAME_PLAYER_JOIN, (Object) user.getDisplayName());
}
// todo: perhaps consider having this handled by phases instead
// disable listening to global messages
user.removeListeningChannel(chatHandler.defaultChannel.getIdentifier());
// local channel
user.addListeningChannel(chatChannel.getIdentifier());
user.setActiveChannel(chatChannel.getIdentifier());
return true;
}
Aggregations