mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-10-17 07:45:33 +02:00
#1194 Add API methods to access the GeoIpAPI
This commit is contained in:
parent
c803822fa8
commit
5dfb63c00f
@ -9,6 +9,7 @@ import fr.xephi.authme.process.register.executors.ApiPasswordRegisterParams;
|
|||||||
import fr.xephi.authme.process.register.executors.RegistrationMethod;
|
import fr.xephi.authme.process.register.executors.RegistrationMethod;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
|
import fr.xephi.authme.service.GeoIpService;
|
||||||
import fr.xephi.authme.service.PluginHookService;
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.service.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -37,13 +38,14 @@ public class AuthMeApi {
|
|||||||
private final Management management;
|
private final Management management;
|
||||||
private final ValidationService validationService;
|
private final ValidationService validationService;
|
||||||
private final PlayerCache playerCache;
|
private final PlayerCache playerCache;
|
||||||
|
private final GeoIpService geoIpService;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructor for AuthMeApi.
|
* Constructor for AuthMeApi.
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
AuthMeApi(AuthMe plugin, PluginHookService pluginHookService, DataSource dataSource, PasswordSecurity passwordSecurity,
|
AuthMeApi(AuthMe plugin, PluginHookService pluginHookService, DataSource dataSource, PasswordSecurity passwordSecurity,
|
||||||
Management management, ValidationService validationService, PlayerCache playerCache) {
|
Management management, ValidationService validationService, PlayerCache playerCache, GeoIpService geoIpService) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.pluginHookService = pluginHookService;
|
this.pluginHookService = pluginHookService;
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
@ -51,6 +53,7 @@ public class AuthMeApi {
|
|||||||
this.management = management;
|
this.management = management;
|
||||||
this.validationService = validationService;
|
this.validationService = validationService;
|
||||||
this.playerCache = playerCache;
|
this.playerCache = playerCache;
|
||||||
|
this.geoIpService = geoIpService;
|
||||||
AuthMeApi.singleton = this;
|
AuthMeApi.singleton = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,4 +260,26 @@ public class AuthMeApi {
|
|||||||
dataSource.getAllAuths().forEach(auth -> registeredNames.add(auth.getRealName()));
|
dataSource.getAllAuths().forEach(auth -> registeredNames.add(auth.getRealName()));
|
||||||
return registeredNames;
|
return registeredNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the country code of the given IP address.
|
||||||
|
*
|
||||||
|
* @param ip textual IP address to lookup.
|
||||||
|
*
|
||||||
|
* @return two-character ISO 3166-1 alpha code for the country.
|
||||||
|
*/
|
||||||
|
public String getCountryCode(String ip) {
|
||||||
|
return geoIpService.getCountryCode(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the country name of the given IP address.
|
||||||
|
*
|
||||||
|
* @param ip textual IP address to lookup.
|
||||||
|
*
|
||||||
|
* @return The name of the country.
|
||||||
|
*/
|
||||||
|
public String getCountryName(String ip) {
|
||||||
|
return geoIpService.getCountryName(ip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user