package org.royaldev.thehumanity.server.services.serverinfo;
import org.jetbrains.annotations.NotNull;
import org.kitteh.irc.client.library.Client;
import org.kitteh.irc.client.library.feature.ServerInfo;
import org.royaldev.thehumanity.server.services.client.ClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Nullable;
@Service
public class HumanityServerInfoService implements ServerInfoService {
@Autowired
private ClientService clientService;
@NotNull
@Override
public ServerInfo getServerInfo(@NotNull final Client client) {
return client.getServerInfo();
}
@Nullable
@Override
public ServerInfo getServerInfo(@NotNull String hostname) {
final Client client = this.clientService.getFromHostname(hostname);
if (client == null) {
return null;
}
return this.getServerInfo(client);
}
}