use of com.faforever.server.config.ServerProperties.Chat in project faf-java-server by FAForever.
the class ChatServiceTest method setUp.
@Before
public void setUp() throws Exception {
ServerProperties properties = new ServerProperties();
Chat chat = properties.getChat();
chat.setAdminChannels(Collections.singletonList("#admins"));
chat.setModeratorChannels(Collections.singletonList("#moderators"));
chat.setDefaultChannels(Arrays.asList("#foo", "#bar"));
chat.setClanChannelFormat("#clan_%s");
instance = new ChatService(nickCoreRepository, properties, clientService);
}
use of com.faforever.server.config.ServerProperties.Chat in project faf-java-server by FAForever.
the class ChatService method onPlayerOnlineEvent.
@EventListener
public void onPlayerOnlineEvent(PlayerOnlineEvent event) {
Chat chat = properties.getChat();
Set<String> channels = new HashSet<>(3, 1);
channels.addAll(chat.getDefaultChannels());
Optional.ofNullable(event.getPlayer().getClan()).map(clan -> (String.format(chat.getClanChannelFormat(), clan.getTag()))).ifPresent(channels::add);
User user = event.getPlayer().getUser();
GroupAssociation groupAssociation = user.getGroupAssociation();
if (groupAssociation != null) {
switch(groupAssociation.getGroup()) {
case ADMIN:
channels.addAll(chat.getAdminChannels());
break;
case MODERATOR:
channels.addAll(chat.getModeratorChannels());
break;
default:
throw new ProgrammingError("Uncovered group: " + groupAssociation.getGroup());
}
}
clientService.sendChatChannels(channels, event.getPlayer());
}
Aggregations