don't return maxmind data if it failed to load
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m22s
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m22s
This commit is contained in:
parent
2ad5556041
commit
67efda71d2
@ -191,6 +191,9 @@ public class MinecraftServer {
|
||||
* @return the location of the server
|
||||
*/
|
||||
public static GeoLocation fromMaxMind(CityResponse response) {
|
||||
if (response == null) {
|
||||
return null;
|
||||
}
|
||||
return new GeoLocation(
|
||||
response.getCountry().getName(),
|
||||
response.getMostSpecificSubdivision().getName(),
|
||||
|
@ -40,8 +40,8 @@ public class MaxMindService {
|
||||
public MaxMindService(@Value("${maxmind.license}") String maxMindLicense) {
|
||||
this.maxMindLicense = maxMindLicense;
|
||||
if (maxMindLicense.isBlank()) {
|
||||
log.error("The MaxMind license key is not set, please set it in the configuration and try again");
|
||||
System.exit(1);
|
||||
log.error("The MaxMind license key is not set, please set it in the configuration and try again, disabling the MaxMind service...");
|
||||
return;
|
||||
}
|
||||
|
||||
File databaseFile = loadDatabase();
|
||||
@ -61,6 +61,9 @@ public class MaxMindService {
|
||||
* @return The GeoIP information
|
||||
*/
|
||||
public static CityResponse lookup(String query) {
|
||||
if (database == null) { // The database isn't loaded, return null
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return database.city(InetAddress.getByName(query));
|
||||
} catch (IOException | GeoIp2Exception e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user