/** * Removes a channel from the player's subscriptions. * * @return * @throws LeaveChannelException */ public boolean leaveChannel(Channel channel) throws LeaveChannelException { if (channel != null) { try { ChannelPermissions.playerCanLeave(player, channel); } catch (ChannelPermissionException e) { throw new LeaveChannelException(e.getMessage()); } if (channel.getShortName().equals(focusedChannel)) { if (channels.size() > 1) { // Find the first channel that isn't this one for (String alias : channels) { if (!alias.equals(channel.getShortName())) { focusedChannel = alias; break; } } } else { throw new LeaveChannelException("May not leave only subscribed channel."); } } removeChannel(channel); } return false; }
/** * Subscribes a player to a channel. * * @param c * @throws JoinChannelException */ public void joinChannel(Channel c) throws JoinChannelException { try { ChannelPermissions.playerCanJoin(player, c); } catch (ChannelPermissionException e) { throw new JoinChannelException(e.getMessage()); } addChannel(c); }