forked from MinecraftUtilities/Backend
don't return maxmind data if it failed to load
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…
Reference in New Issue
Block a user