mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 04:35:12 +01:00
Remove useless packages
This commit is contained in:
parent
71f3b86383
commit
7b5a857f74
@ -26,6 +26,7 @@ import fr.xephi.authme.permission.PermissionsManager;
|
|||||||
import fr.xephi.authme.permission.PermissionsSystemType;
|
import fr.xephi.authme.permission.PermissionsSystemType;
|
||||||
import fr.xephi.authme.security.crypts.SHA256;
|
import fr.xephi.authme.security.crypts.SHA256;
|
||||||
import fr.xephi.authme.service.BackupService;
|
import fr.xephi.authme.service.BackupService;
|
||||||
|
import fr.xephi.authme.service.GeoIpService;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
@ -33,7 +34,6 @@ import fr.xephi.authme.settings.properties.SecuritySettings;
|
|||||||
import fr.xephi.authme.task.CleanupTask;
|
import fr.xephi.authme.task.CleanupTask;
|
||||||
import fr.xephi.authme.task.purge.PurgeService;
|
import fr.xephi.authme.task.purge.PurgeService;
|
||||||
import fr.xephi.authme.service.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.geoip.GeoIpManager;
|
|
||||||
import fr.xephi.authme.service.MigrationService;
|
import fr.xephi.authme.service.MigrationService;
|
||||||
import fr.xephi.authme.util.PlayerUtils;
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
@ -74,7 +74,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
private DataSource database;
|
private DataSource database;
|
||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
private Injector injector;
|
private Injector injector;
|
||||||
private GeoIpManager geoIpManager;
|
private GeoIpService geoIpService;
|
||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -248,7 +248,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
permsMan = injector.getSingleton(PermissionsManager.class);
|
permsMan = injector.getSingleton(PermissionsManager.class);
|
||||||
bukkitService = injector.getSingleton(BukkitService.class);
|
bukkitService = injector.getSingleton(BukkitService.class);
|
||||||
commandHandler = injector.getSingleton(CommandHandler.class);
|
commandHandler = injector.getSingleton(CommandHandler.class);
|
||||||
geoIpManager = injector.getSingleton(GeoIpManager.class);
|
geoIpService = injector.getSingleton(GeoIpService.class);
|
||||||
|
|
||||||
// Trigger construction of API classes; they will keep track of the singleton
|
// Trigger construction of API classes; they will keep track of the singleton
|
||||||
injector.getSingleton(NewAPI.class);
|
injector.getSingleton(NewAPI.class);
|
||||||
@ -374,7 +374,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
.replace("{SERVER}", server.getServerName())
|
.replace("{SERVER}", server.getServerName())
|
||||||
.replace("{VERSION}", server.getBukkitVersion())
|
.replace("{VERSION}", server.getBukkitVersion())
|
||||||
// TODO: We should cache info like this, maybe with a class that extends Player?
|
// TODO: We should cache info like this, maybe with a class that extends Player?
|
||||||
.replace("{COUNTRY}", geoIpManager.getCountryName(ipAddress));
|
.replace("{COUNTRY}", geoIpService.getCountryName(ipAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.data.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
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;
|
||||||
@ -28,7 +28,7 @@ public class API {
|
|||||||
private static DataSource dataSource;
|
private static DataSource dataSource;
|
||||||
private static PasswordSecurity passwordSecurity;
|
private static PasswordSecurity passwordSecurity;
|
||||||
private static Management management;
|
private static Management management;
|
||||||
private static PluginHooks pluginHooks;
|
private static PluginHookService pluginHookService;
|
||||||
private static ValidationService validationService;
|
private static ValidationService validationService;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -36,12 +36,12 @@ public class API {
|
|||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
API(AuthMe instance, DataSource dataSource, PasswordSecurity passwordSecurity, Management management,
|
API(AuthMe instance, DataSource dataSource, PasswordSecurity passwordSecurity, Management management,
|
||||||
PluginHooks pluginHooks, ValidationService validationService) {
|
PluginHookService pluginHookService, ValidationService validationService) {
|
||||||
API.instance = instance;
|
API.instance = instance;
|
||||||
API.dataSource = dataSource;
|
API.dataSource = dataSource;
|
||||||
API.passwordSecurity = passwordSecurity;
|
API.passwordSecurity = passwordSecurity;
|
||||||
API.management = management;
|
API.management = management;
|
||||||
API.pluginHooks = pluginHooks;
|
API.pluginHookService = pluginHookService;
|
||||||
API.validationService = validationService;
|
API.validationService = validationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ public class API {
|
|||||||
* @return true if player is an npc
|
* @return true if player is an npc
|
||||||
*/
|
*/
|
||||||
public boolean isNPC(Player player) {
|
public boolean isNPC(Player player) {
|
||||||
return pluginHooks.isNpc(player);
|
return pluginHookService.isNpc(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.data.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
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;
|
||||||
@ -27,7 +27,7 @@ public class NewAPI {
|
|||||||
|
|
||||||
public static NewAPI singleton;
|
public static NewAPI singleton;
|
||||||
public final AuthMe plugin;
|
public final AuthMe plugin;
|
||||||
private final PluginHooks pluginHooks;
|
private final PluginHookService pluginHookService;
|
||||||
private final DataSource dataSource;
|
private final DataSource dataSource;
|
||||||
private final PasswordSecurity passwordSecurity;
|
private final PasswordSecurity passwordSecurity;
|
||||||
private final Management management;
|
private final Management management;
|
||||||
@ -38,10 +38,10 @@ public class NewAPI {
|
|||||||
* Constructor for NewAPI.
|
* Constructor for NewAPI.
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
NewAPI(AuthMe plugin, PluginHooks pluginHooks, DataSource dataSource, PasswordSecurity passwordSecurity,
|
NewAPI(AuthMe plugin, PluginHookService pluginHookService, DataSource dataSource, PasswordSecurity passwordSecurity,
|
||||||
Management management, ValidationService validationService, PlayerCache playerCache) {
|
Management management, ValidationService validationService, PlayerCache playerCache) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.pluginHooks = pluginHooks;
|
this.pluginHookService = pluginHookService;
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.passwordSecurity = passwordSecurity;
|
this.passwordSecurity = passwordSecurity;
|
||||||
this.management = management;
|
this.management = management;
|
||||||
@ -100,7 +100,7 @@ public class NewAPI {
|
|||||||
* @return true if the player is an npc
|
* @return true if the player is an npc
|
||||||
*/
|
*/
|
||||||
public boolean isNPC(Player player) {
|
public boolean isNPC(Player player) {
|
||||||
return pluginHooks.isNpc(player);
|
return pluginHookService.isNpc(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,7 +5,7 @@ import fr.xephi.authme.data.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.data.backup.LimboPlayerStorage;
|
import fr.xephi.authme.data.backup.LimboPlayerStorage;
|
||||||
import fr.xephi.authme.data.limbo.LimboCache;
|
import fr.xephi.authme.data.limbo.LimboCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
@ -36,7 +36,7 @@ public class OnShutdownPlayerSaver {
|
|||||||
@Inject
|
@Inject
|
||||||
private SpawnLoader spawnLoader;
|
private SpawnLoader spawnLoader;
|
||||||
@Inject
|
@Inject
|
||||||
private PluginHooks pluginHooks;
|
private PluginHookService pluginHookService;
|
||||||
@Inject
|
@Inject
|
||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ public class OnShutdownPlayerSaver {
|
|||||||
|
|
||||||
private void savePlayer(Player player) {
|
private void savePlayer(Player player) {
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
if (pluginHooks.isNpc(player) || validationService.isUnrestricted(name)) {
|
if (pluginHookService.isNpc(player) || validationService.isUnrestricted(name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (limboCache.hasPlayerData(name)) {
|
if (limboCache.hasPlayerData(name)) {
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.listener;
|
|||||||
|
|
||||||
import fr.xephi.authme.data.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
import fr.xephi.authme.initialization.SettingsDependent;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
@ -20,17 +20,17 @@ import javax.inject.Inject;
|
|||||||
class ListenerService implements SettingsDependent {
|
class ListenerService implements SettingsDependent {
|
||||||
|
|
||||||
private final DataSource dataSource;
|
private final DataSource dataSource;
|
||||||
private final PluginHooks pluginHooks;
|
private final PluginHookService pluginHookService;
|
||||||
private final PlayerCache playerCache;
|
private final PlayerCache playerCache;
|
||||||
private final ValidationService validationService;
|
private final ValidationService validationService;
|
||||||
|
|
||||||
private boolean isRegistrationForced;
|
private boolean isRegistrationForced;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ListenerService(Settings settings, DataSource dataSource, PluginHooks pluginHooks,
|
ListenerService(Settings settings, DataSource dataSource, PluginHookService pluginHookService,
|
||||||
PlayerCache playerCache, ValidationService validationService) {
|
PlayerCache playerCache, ValidationService validationService) {
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.pluginHooks = pluginHooks;
|
this.pluginHookService = pluginHookService;
|
||||||
this.playerCache = playerCache;
|
this.playerCache = playerCache;
|
||||||
this.validationService = validationService;
|
this.validationService = validationService;
|
||||||
reload(settings);
|
reload(settings);
|
||||||
@ -79,7 +79,7 @@ class ListenerService implements SettingsDependent {
|
|||||||
* @return true if the associated event should be canceled, false otherwise
|
* @return true if the associated event should be canceled, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean shouldCancelEvent(Player player) {
|
public boolean shouldCancelEvent(Player player) {
|
||||||
return player != null && !checkAuth(player.getName()) && !pluginHooks.isNpc(player);
|
return player != null && !checkAuth(player.getName()) && !pluginHookService.isNpc(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.listener;
|
package fr.xephi.authme.listener;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
|
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
@ -17,7 +17,7 @@ import javax.inject.Inject;
|
|||||||
public class ServerListener implements Listener {
|
public class ServerListener implements Listener {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PluginHooks pluginHooks;
|
private PluginHookService pluginHookService;
|
||||||
@Inject
|
@Inject
|
||||||
private SpawnLoader spawnLoader;
|
private SpawnLoader spawnLoader;
|
||||||
@Inject
|
@Inject
|
||||||
@ -38,13 +38,13 @@ public class ServerListener implements Listener {
|
|||||||
permissionsManager.onPluginDisable(pluginName);
|
permissionsManager.onPluginDisable(pluginName);
|
||||||
|
|
||||||
if ("Essentials".equalsIgnoreCase(pluginName)) {
|
if ("Essentials".equalsIgnoreCase(pluginName)) {
|
||||||
pluginHooks.unhookEssentials();
|
pluginHookService.unhookEssentials();
|
||||||
ConsoleLogger.info("Essentials has been disabled: unhooking");
|
ConsoleLogger.info("Essentials has been disabled: unhooking");
|
||||||
} else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) {
|
} else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) {
|
||||||
pluginHooks.unhookMultiverse();
|
pluginHookService.unhookMultiverse();
|
||||||
ConsoleLogger.info("Multiverse-Core has been disabled: unhooking");
|
ConsoleLogger.info("Multiverse-Core has been disabled: unhooking");
|
||||||
} else if ("CombatTagPlus".equalsIgnoreCase(pluginName)) {
|
} else if ("CombatTagPlus".equalsIgnoreCase(pluginName)) {
|
||||||
pluginHooks.unhookCombatPlus();
|
pluginHookService.unhookCombatPlus();
|
||||||
ConsoleLogger.info("CombatTagPlus has been disabled: unhooking");
|
ConsoleLogger.info("CombatTagPlus has been disabled: unhooking");
|
||||||
} else if ("EssentialsSpawn".equalsIgnoreCase(pluginName)) {
|
} else if ("EssentialsSpawn".equalsIgnoreCase(pluginName)) {
|
||||||
spawnLoader.unloadEssentialsSpawn();
|
spawnLoader.unloadEssentialsSpawn();
|
||||||
@ -68,11 +68,11 @@ public class ServerListener implements Listener {
|
|||||||
permissionsManager.onPluginEnable(pluginName);
|
permissionsManager.onPluginEnable(pluginName);
|
||||||
|
|
||||||
if ("Essentials".equalsIgnoreCase(pluginName)) {
|
if ("Essentials".equalsIgnoreCase(pluginName)) {
|
||||||
pluginHooks.tryHookToEssentials();
|
pluginHookService.tryHookToEssentials();
|
||||||
} else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) {
|
} else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) {
|
||||||
pluginHooks.tryHookToMultiverse();
|
pluginHookService.tryHookToMultiverse();
|
||||||
} else if ("CombatTagPlus".equalsIgnoreCase(pluginName)) {
|
} else if ("CombatTagPlus".equalsIgnoreCase(pluginName)) {
|
||||||
pluginHooks.tryHookToCombatPlus();
|
pluginHookService.tryHookToCombatPlus();
|
||||||
} else if ("EssentialsSpawn".equalsIgnoreCase(pluginName)) {
|
} else if ("EssentialsSpawn".equalsIgnoreCase(pluginName)) {
|
||||||
spawnLoader.loadEssentialsSpawn();
|
spawnLoader.loadEssentialsSpawn();
|
||||||
} else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
|
} else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
|
||||||
|
@ -8,7 +8,7 @@ import fr.xephi.authme.data.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.data.limbo.LimboCache;
|
import fr.xephi.authme.data.limbo.LimboCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.events.ProtectInventoryEvent;
|
import fr.xephi.authme.events.ProtectInventoryEvent;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.permission.AuthGroupType;
|
import fr.xephi.authme.permission.AuthGroupType;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||||
@ -61,7 +61,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
|||||||
private SessionManager sessionManager;
|
private SessionManager sessionManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PluginHooks pluginHooks;
|
private PluginHookService pluginHookService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
@ -95,7 +95,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (service.getProperty(HooksSettings.DISABLE_SOCIAL_SPY)) {
|
if (service.getProperty(HooksSettings.DISABLE_SOCIAL_SPY)) {
|
||||||
pluginHooks.setEssentialsSocialSpyStatus(player, false);
|
pluginHookService.setEssentialsSocialSpyStatus(player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNameRestricted(name, ip, player.getAddress().getHostName())) {
|
if (isNameRestricted(name, ip, player.getAddress().getHostName())) {
|
||||||
@ -172,7 +172,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
|||||||
player.setWalkSpeed(0.0f);
|
player.setWalkSpeed(0.0f);
|
||||||
}
|
}
|
||||||
player.setNoDamageTicks(registrationTimeout);
|
player.setNoDamageTicks(registrationTimeout);
|
||||||
if (pluginHooks.isEssentialsAvailable() && service.getProperty(HooksSettings.USE_ESSENTIALS_MOTD)) {
|
if (pluginHookService.isEssentialsAvailable() && service.getProperty(HooksSettings.USE_ESSENTIALS_MOTD)) {
|
||||||
player.performCommand("motd");
|
player.performCommand("motd");
|
||||||
}
|
}
|
||||||
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package fr.xephi.authme.geoip;
|
package fr.xephi.authme.service;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.maxmind.geoip.LookupService;
|
import com.maxmind.geoip.LookupService;
|
||||||
@ -17,7 +17,7 @@ import java.net.URLConnection;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
public class GeoIpManager {
|
public class GeoIpService {
|
||||||
private static final String LICENSE =
|
private static final String LICENSE =
|
||||||
"[LICENSE] This product uses data from the GeoLite API created by MaxMind, available at http://www.maxmind.com";
|
"[LICENSE] This product uses data from the GeoLite API created by MaxMind, available at http://www.maxmind.com";
|
||||||
private static final String GEOIP_URL =
|
private static final String GEOIP_URL =
|
||||||
@ -28,14 +28,14 @@ public class GeoIpManager {
|
|||||||
private final File dataFile;
|
private final File dataFile;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
GeoIpManager(@DataFolder File dataFolder) {
|
GeoIpService(@DataFolder File dataFolder) {
|
||||||
this.dataFile = new File(dataFolder, "GeoIP.dat");
|
this.dataFile = new File(dataFolder, "GeoIP.dat");
|
||||||
// Fires download of recent data or the initialization of the look up service
|
// Fires download of recent data or the initialization of the look up service
|
||||||
isDataAvailable();
|
isDataAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
GeoIpManager(@DataFolder File dataFolder, LookupService lookupService) {
|
GeoIpService(@DataFolder File dataFolder, LookupService lookupService) {
|
||||||
this.dataFile = dataFolder;
|
this.dataFile = dataFolder;
|
||||||
this.lookupService = lookupService;
|
this.lookupService = lookupService;
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package fr.xephi.authme.hooks;
|
package fr.xephi.authme.service;
|
||||||
|
|
||||||
import ch.jalu.injector.annotations.NoFieldScan;
|
import ch.jalu.injector.annotations.NoFieldScan;
|
||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
@ -19,7 +19,7 @@ import java.io.File;
|
|||||||
* Hooks into third-party plugins and allows to perform actions on them.
|
* Hooks into third-party plugins and allows to perform actions on them.
|
||||||
*/
|
*/
|
||||||
@NoFieldScan
|
@NoFieldScan
|
||||||
public class PluginHooks {
|
public class PluginHookService {
|
||||||
|
|
||||||
private final PluginManager pluginManager;
|
private final PluginManager pluginManager;
|
||||||
private Essentials essentials;
|
private Essentials essentials;
|
||||||
@ -32,7 +32,7 @@ public class PluginHooks {
|
|||||||
* @param pluginManager The server's plugin manager
|
* @param pluginManager The server's plugin manager
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public PluginHooks(PluginManager pluginManager) {
|
public PluginHookService(PluginManager pluginManager) {
|
||||||
this.pluginManager = pluginManager;
|
this.pluginManager = pluginManager;
|
||||||
tryHookToCombatPlus();
|
tryHookToCombatPlus();
|
||||||
tryHookToEssentials();
|
tryHookToEssentials();
|
@ -2,7 +2,6 @@ package fr.xephi.authme.service;
|
|||||||
|
|
||||||
import com.github.authme.configme.properties.Property;
|
import com.github.authme.configme.properties.Property;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.geoip.GeoIpManager;
|
|
||||||
import fr.xephi.authme.initialization.Reloadable;
|
import fr.xephi.authme.initialization.Reloadable;
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
@ -36,7 +35,7 @@ public class ValidationService implements Reloadable {
|
|||||||
@Inject
|
@Inject
|
||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
@Inject
|
@Inject
|
||||||
private GeoIpManager geoIpManager;
|
private GeoIpService geoIpService;
|
||||||
|
|
||||||
private Pattern passwordRegex;
|
private Pattern passwordRegex;
|
||||||
private Set<String> unrestrictedNames;
|
private Set<String> unrestrictedNames;
|
||||||
@ -115,7 +114,7 @@ public class ValidationService implements Reloadable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String countryCode = geoIpManager.getCountryCode(hostAddress);
|
String countryCode = geoIpService.getCountryCode(hostAddress);
|
||||||
return validateWhitelistAndBlacklist(countryCode,
|
return validateWhitelistAndBlacklist(countryCode,
|
||||||
ProtectionSettings.COUNTRIES_WHITELIST,
|
ProtectionSettings.COUNTRIES_WHITELIST,
|
||||||
ProtectionSettings.COUNTRIES_BLACKLIST);
|
ProtectionSettings.COUNTRIES_BLACKLIST);
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.settings;
|
|||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.initialization.DataFolder;
|
import fr.xephi.authme.initialization.DataFolder;
|
||||||
import fr.xephi.authme.initialization.Reloadable;
|
import fr.xephi.authme.initialization.Reloadable;
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
@ -32,7 +32,7 @@ public class SpawnLoader implements Reloadable {
|
|||||||
|
|
||||||
private final File authMeConfigurationFile;
|
private final File authMeConfigurationFile;
|
||||||
private final Settings settings;
|
private final Settings settings;
|
||||||
private final PluginHooks pluginHooks;
|
private final PluginHookService pluginHookService;
|
||||||
private FileConfiguration authMeConfiguration;
|
private FileConfiguration authMeConfiguration;
|
||||||
private String[] spawnPriority;
|
private String[] spawnPriority;
|
||||||
private Location essentialsSpawn;
|
private Location essentialsSpawn;
|
||||||
@ -42,18 +42,18 @@ public class SpawnLoader implements Reloadable {
|
|||||||
*
|
*
|
||||||
* @param pluginFolder The AuthMe data folder
|
* @param pluginFolder The AuthMe data folder
|
||||||
* @param settings The setting instance
|
* @param settings The setting instance
|
||||||
* @param pluginHooks The plugin hooks instance
|
* @param pluginHookService The plugin hooks instance
|
||||||
* @param dataSource The plugin auth database instance
|
* @param dataSource The plugin auth database instance
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
SpawnLoader(@DataFolder File pluginFolder, Settings settings, PluginHooks pluginHooks,
|
SpawnLoader(@DataFolder File pluginFolder, Settings settings, PluginHookService pluginHookService,
|
||||||
DataSource dataSource) {
|
DataSource dataSource) {
|
||||||
File spawnFile = new File(pluginFolder, "spawn.yml");
|
File spawnFile = new File(pluginFolder, "spawn.yml");
|
||||||
// TODO ljacqu 20160312: Check if resource could be copied and handle the case if not
|
// TODO ljacqu 20160312: Check if resource could be copied and handle the case if not
|
||||||
FileUtils.copyFileFromResource(spawnFile, "spawn.yml");
|
FileUtils.copyFileFromResource(spawnFile, "spawn.yml");
|
||||||
this.authMeConfigurationFile = new File(pluginFolder, "spawn.yml");
|
this.authMeConfigurationFile = new File(pluginFolder, "spawn.yml");
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.pluginHooks = pluginHooks;
|
this.pluginHookService = pluginHookService;
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ public class SpawnLoader implements Reloadable {
|
|||||||
*/
|
*/
|
||||||
public void loadEssentialsSpawn() {
|
public void loadEssentialsSpawn() {
|
||||||
// EssentialsSpawn cannot run without Essentials, so it's fine to get the Essentials data folder
|
// EssentialsSpawn cannot run without Essentials, so it's fine to get the Essentials data folder
|
||||||
File essentialsFolder = pluginHooks.getEssentialsDataFolder();
|
File essentialsFolder = pluginHookService.getEssentialsDataFolder();
|
||||||
if (essentialsFolder == null) {
|
if (essentialsFolder == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ public class SpawnLoader implements Reloadable {
|
|||||||
break;
|
break;
|
||||||
case "multiverse":
|
case "multiverse":
|
||||||
if (settings.getProperty(HooksSettings.MULTIVERSE)) {
|
if (settings.getProperty(HooksSettings.MULTIVERSE)) {
|
||||||
spawnLoc = pluginHooks.getMultiverseSpawn(world);
|
spawnLoc = pluginHookService.getMultiverseSpawn(world);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "essentials":
|
case "essentials":
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.task.purge;
|
|||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.PurgeSettings;
|
import fr.xephi.authme.settings.properties.PurgeSettings;
|
||||||
@ -33,7 +33,7 @@ class PurgeExecutor {
|
|||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PluginHooks pluginHooks;
|
private PluginHookService pluginHookService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
@ -172,7 +172,7 @@ class PurgeExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
File essentialsDataFolder = pluginHooks.getEssentialsDataFolder();
|
File essentialsDataFolder = pluginHookService.getEssentialsDataFolder();
|
||||||
if (essentialsDataFolder == null) {
|
if (essentialsDataFolder == null) {
|
||||||
ConsoleLogger.info("Cannot purge Essentials: plugin is not loaded");
|
ConsoleLogger.info("Cannot purge Essentials: plugin is not loaded");
|
||||||
return;
|
return;
|
||||||
|
@ -5,7 +5,7 @@ import fr.xephi.authme.ReflectionTestUtils;
|
|||||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.data.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.service.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
@ -46,7 +46,7 @@ public class NewAPITest {
|
|||||||
@Mock
|
@Mock
|
||||||
private AuthMe authMe;
|
private AuthMe authMe;
|
||||||
@Mock
|
@Mock
|
||||||
private PluginHooks pluginHooks;
|
private PluginHookService pluginHookService;
|
||||||
@Mock
|
@Mock
|
||||||
private ValidationService validationService;
|
private ValidationService validationService;
|
||||||
@Mock
|
@Mock
|
||||||
@ -86,7 +86,7 @@ public class NewAPITest {
|
|||||||
public void shouldReturnIfPlayerIsNpc() {
|
public void shouldReturnIfPlayerIsNpc() {
|
||||||
// given
|
// given
|
||||||
Player player = mock(Player.class);
|
Player player = mock(Player.class);
|
||||||
given(pluginHooks.isNpc(player)).willReturn(true);
|
given(pluginHookService.isNpc(player)).willReturn(true);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
boolean result = api.isNPC(player);
|
boolean result = api.isNPC(player);
|
||||||
|
@ -5,7 +5,7 @@ import ch.jalu.injector.testing.DelayedInjectionRunner;
|
|||||||
import ch.jalu.injector.testing.InjectDelayed;
|
import ch.jalu.injector.testing.InjectDelayed;
|
||||||
import fr.xephi.authme.data.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.service.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
@ -41,7 +41,7 @@ public class ListenerServiceTest {
|
|||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PluginHooks pluginHooks;
|
private PluginHookService pluginHookService;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
@ -161,14 +161,14 @@ public class ListenerServiceTest {
|
|||||||
Player player = mockPlayerWithName(playerName);
|
Player player = mockPlayerWithName(playerName);
|
||||||
EntityEvent event = mock(EntityEvent.class);
|
EntityEvent event = mock(EntityEvent.class);
|
||||||
given(event.getEntity()).willReturn(player);
|
given(event.getEntity()).willReturn(player);
|
||||||
given(pluginHooks.isNpc(player)).willReturn(true);
|
given(pluginHookService.isNpc(player)).willReturn(true);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
boolean result = listenerService.shouldCancelEvent(event);
|
boolean result = listenerService.shouldCancelEvent(event);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verify(pluginHooks).isNpc(player);
|
verify(pluginHookService).isNpc(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -215,7 +215,7 @@ public class ListenerServiceTest {
|
|||||||
assertThat(result, equalTo(true));
|
assertThat(result, equalTo(true));
|
||||||
verify(playerCache).isAuthenticated(playerName);
|
verify(playerCache).isAuthenticated(playerName);
|
||||||
verifyZeroInteractions(dataSource);
|
verifyZeroInteractions(dataSource);
|
||||||
verify(pluginHooks).isNpc(player);
|
verify(pluginHookService).isNpc(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Player mockPlayerWithName(String name) {
|
private static Player mockPlayerWithName(String name) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.listener;
|
package fr.xephi.authme.listener;
|
||||||
|
|
||||||
import fr.xephi.authme.TestHelper;
|
import fr.xephi.authme.TestHelper;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
|
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
@ -41,7 +41,7 @@ public class ServerListenerTest {
|
|||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PluginHooks pluginHooks;
|
private PluginHookService pluginHookService;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private ProtocolLibService protocolLibService;
|
private ProtocolLibService protocolLibService;
|
||||||
@ -59,7 +59,7 @@ public class ServerListenerTest {
|
|||||||
checkEnableHandling(ESSENTIALS, new Runnable() {
|
checkEnableHandling(ESSENTIALS, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
verify(pluginHooks).tryHookToEssentials();
|
verify(pluginHookService).tryHookToEssentials();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
checkEnableHandling(ESSENTIALS_SPAWN, new Runnable() {
|
checkEnableHandling(ESSENTIALS_SPAWN, new Runnable() {
|
||||||
@ -71,13 +71,13 @@ public class ServerListenerTest {
|
|||||||
checkEnableHandling(MULTIVERSE, new Runnable() {
|
checkEnableHandling(MULTIVERSE, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
verify(pluginHooks).tryHookToMultiverse();
|
verify(pluginHookService).tryHookToMultiverse();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
checkEnableHandling(COMBAT_TAG, new Runnable() {
|
checkEnableHandling(COMBAT_TAG, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
verify(pluginHooks).tryHookToCombatPlus();
|
verify(pluginHookService).tryHookToCombatPlus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
checkEnableHandling(PROTOCOL_LIB, new Runnable() {
|
checkEnableHandling(PROTOCOL_LIB, new Runnable() {
|
||||||
@ -99,7 +99,7 @@ public class ServerListenerTest {
|
|||||||
checkDisableHandling(ESSENTIALS, new Runnable() {
|
checkDisableHandling(ESSENTIALS, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
verify(pluginHooks).unhookEssentials();
|
verify(pluginHookService).unhookEssentials();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
checkDisableHandling(ESSENTIALS_SPAWN, new Runnable() {
|
checkDisableHandling(ESSENTIALS_SPAWN, new Runnable() {
|
||||||
@ -111,13 +111,13 @@ public class ServerListenerTest {
|
|||||||
checkDisableHandling(MULTIVERSE, new Runnable() {
|
checkDisableHandling(MULTIVERSE, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
verify(pluginHooks).unhookMultiverse();
|
verify(pluginHookService).unhookMultiverse();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
checkDisableHandling(COMBAT_TAG, new Runnable() {
|
checkDisableHandling(COMBAT_TAG, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
verify(pluginHooks).unhookCombatPlus();
|
verify(pluginHookService).unhookCombatPlus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
checkDisableHandling(PROTOCOL_LIB, new Runnable() {
|
checkDisableHandling(PROTOCOL_LIB, new Runnable() {
|
||||||
@ -164,8 +164,8 @@ public class ServerListenerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void verifyNoMoreInteractionsAndReset() {
|
private void verifyNoMoreInteractionsAndReset() {
|
||||||
verifyNoMoreInteractions(permissionsManager, pluginHooks, protocolLibService, spawnLoader);
|
verifyNoMoreInteractions(permissionsManager, pluginHookService, protocolLibService, spawnLoader);
|
||||||
reset(permissionsManager, pluginHooks, protocolLibService, spawnLoader);
|
reset(permissionsManager, pluginHookService, protocolLibService, spawnLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T extends PluginEvent> T mockEventWithPluginName(Class<T> eventClass, String name) {
|
private static <T extends PluginEvent> T mockEventWithPluginName(Class<T> eventClass, String name) {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package fr.xephi.authme.geoip;
|
package fr.xephi.authme.service;
|
||||||
|
|
||||||
import com.maxmind.geoip.Country;
|
import com.maxmind.geoip.Country;
|
||||||
import com.maxmind.geoip.LookupService;
|
import com.maxmind.geoip.LookupService;
|
||||||
|
import fr.xephi.authme.service.GeoIpService;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -22,12 +23,12 @@ import static org.mockito.Mockito.never;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link GeoIpManager}.
|
* Test for {@link GeoIpService}.
|
||||||
*/
|
*/
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class GeoIpManagerTest {
|
public class GeoIpServiceTest {
|
||||||
|
|
||||||
private GeoIpManager geoIpManager;
|
private GeoIpService geoIpService;
|
||||||
private File dataFolder;
|
private File dataFolder;
|
||||||
@Mock
|
@Mock
|
||||||
private LookupService lookupService;
|
private LookupService lookupService;
|
||||||
@ -38,7 +39,7 @@ public class GeoIpManagerTest {
|
|||||||
@Before
|
@Before
|
||||||
public void initializeGeoLiteApi() throws IOException {
|
public void initializeGeoLiteApi() throws IOException {
|
||||||
dataFolder = temporaryFolder.newFolder();
|
dataFolder = temporaryFolder.newFolder();
|
||||||
geoIpManager = new GeoIpManager(dataFolder, lookupService);
|
geoIpService = new GeoIpService(dataFolder, lookupService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -51,7 +52,7 @@ public class GeoIpManagerTest {
|
|||||||
given(lookupService.getCountry(ip)).willReturn(country);
|
given(lookupService.getCountry(ip)).willReturn(country);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String result = geoIpManager.getCountryCode(ip);
|
String result = geoIpService.getCountryCode(ip);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(countryCode));
|
assertThat(result, equalTo(countryCode));
|
||||||
@ -64,7 +65,7 @@ public class GeoIpManagerTest {
|
|||||||
String ip = "127.0.0.1";
|
String ip = "127.0.0.1";
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String result = geoIpManager.getCountryCode(ip);
|
String result = geoIpService.getCountryCode(ip);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo("--"));
|
assertThat(result, equalTo("--"));
|
||||||
@ -81,7 +82,7 @@ public class GeoIpManagerTest {
|
|||||||
given(lookupService.getCountry(ip)).willReturn(country);
|
given(lookupService.getCountry(ip)).willReturn(country);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String result = geoIpManager.getCountryName(ip);
|
String result = geoIpService.getCountryName(ip);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(countryName));
|
assertThat(result, equalTo(countryName));
|
||||||
@ -94,7 +95,7 @@ public class GeoIpManagerTest {
|
|||||||
String ip = "127.0.0.1";
|
String ip = "127.0.0.1";
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String result = geoIpManager.getCountryName(ip);
|
String result = geoIpService.getCountryName(ip);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo("N/A"));
|
assertThat(result, equalTo("N/A"));
|
@ -1,10 +1,11 @@
|
|||||||
package fr.xephi.authme.hooks;
|
package fr.xephi.authme.service;
|
||||||
|
|
||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.ReflectionTestUtils;
|
import fr.xephi.authme.ReflectionTestUtils;
|
||||||
import fr.xephi.authme.TestHelper;
|
import fr.xephi.authme.TestHelper;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -29,9 +30,9 @@ import static org.mockito.Mockito.never;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link PluginHooks}.
|
* Test for {@link PluginHookService}.
|
||||||
*/
|
*/
|
||||||
public class PluginHooksTest {
|
public class PluginHookServiceTest {
|
||||||
|
|
||||||
/** The plugin name of Essentials. */
|
/** The plugin name of Essentials. */
|
||||||
private static final String ESSENTIALS = "Essentials";
|
private static final String ESSENTIALS = "Essentials";
|
||||||
@ -47,15 +48,15 @@ public class PluginHooksTest {
|
|||||||
public void shouldHookIntoEssentials() {
|
public void shouldHookIntoEssentials() {
|
||||||
// given
|
// given
|
||||||
PluginManager pluginManager = mock(PluginManager.class);
|
PluginManager pluginManager = mock(PluginManager.class);
|
||||||
PluginHooks pluginHooks = new PluginHooks(pluginManager);
|
PluginHookService pluginHookService = new PluginHookService(pluginManager);
|
||||||
setPluginAvailable(pluginManager, ESSENTIALS, Essentials.class);
|
setPluginAvailable(pluginManager, ESSENTIALS, Essentials.class);
|
||||||
assertThat(pluginHooks.isEssentialsAvailable(), equalTo(false));
|
assertThat(pluginHookService.isEssentialsAvailable(), equalTo(false));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
pluginHooks.tryHookToEssentials();
|
pluginHookService.tryHookToEssentials();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(pluginHooks.isEssentialsAvailable(), equalTo(true));
|
assertThat(pluginHookService.isEssentialsAvailable(), equalTo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note ljacqu 20160312: Cannot test with Multiverse or CombatTagPlus because their classes are declared final
|
// Note ljacqu 20160312: Cannot test with Multiverse or CombatTagPlus because their classes are declared final
|
||||||
@ -67,10 +68,10 @@ public class PluginHooksTest {
|
|||||||
setPluginAvailable(pluginManager, ESSENTIALS, Essentials.class);
|
setPluginAvailable(pluginManager, ESSENTIALS, Essentials.class);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
PluginHooks pluginHooks = new PluginHooks(pluginManager);
|
PluginHookService pluginHookService = new PluginHookService(pluginManager);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(pluginHooks.isEssentialsAvailable(), equalTo(true));
|
assertThat(pluginHookService.isEssentialsAvailable(), equalTo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -80,10 +81,10 @@ public class PluginHooksTest {
|
|||||||
setPluginAvailable(pluginManager, MULTIVERSE, MultiverseCore.class);
|
setPluginAvailable(pluginManager, MULTIVERSE, MultiverseCore.class);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
PluginHooks pluginHooks = new PluginHooks(pluginManager);
|
PluginHookService pluginHookService = new PluginHookService(pluginManager);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(pluginHooks.isMultiverseAvailable(), equalTo(true));
|
assertThat(pluginHookService.isMultiverseAvailable(), equalTo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -96,10 +97,10 @@ public class PluginHooksTest {
|
|||||||
|
|
||||||
PluginManager pluginManager = mock(PluginManager.class);
|
PluginManager pluginManager = mock(PluginManager.class);
|
||||||
setPluginAvailable(pluginManager, ESSENTIALS, ess);
|
setPluginAvailable(pluginManager, ESSENTIALS, ess);
|
||||||
PluginHooks pluginHooks = new PluginHooks(pluginManager);
|
PluginHookService pluginHookService = new PluginHookService(pluginManager);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
File dataFolder = pluginHooks.getEssentialsDataFolder();
|
File dataFolder = pluginHookService.getEssentialsDataFolder();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(dataFolder, equalTo(essDataFolder));
|
assertThat(dataFolder, equalTo(essDataFolder));
|
||||||
@ -109,10 +110,10 @@ public class PluginHooksTest {
|
|||||||
public void shouldReturnNullForUnhookedEssentials() {
|
public void shouldReturnNullForUnhookedEssentials() {
|
||||||
// given
|
// given
|
||||||
PluginManager pluginManager = mock(PluginManager.class);
|
PluginManager pluginManager = mock(PluginManager.class);
|
||||||
PluginHooks pluginHooks = new PluginHooks(pluginManager);
|
PluginHookService pluginHookService = new PluginHookService(pluginManager);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
File result = pluginHooks.getEssentialsDataFolder();
|
File result = pluginHookService.getEssentialsDataFolder();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, nullValue());
|
assertThat(result, nullValue());
|
||||||
@ -129,10 +130,10 @@ public class PluginHooksTest {
|
|||||||
|
|
||||||
PluginManager pluginManager = mock(PluginManager.class);
|
PluginManager pluginManager = mock(PluginManager.class);
|
||||||
setPluginAvailable(pluginManager, ESSENTIALS, ess);
|
setPluginAvailable(pluginManager, ESSENTIALS, ess);
|
||||||
PluginHooks pluginHooks = new PluginHooks(pluginManager);
|
PluginHookService pluginHookService = new PluginHookService(pluginManager);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
pluginHooks.setEssentialsSocialSpyStatus(player, true);
|
pluginHookService.setEssentialsSocialSpyStatus(player, true);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verify(ess).getUser(player);
|
verify(ess).getUser(player);
|
||||||
@ -142,10 +143,10 @@ public class PluginHooksTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldNotDoAnythingForUnhookedEssentials() {
|
public void shouldNotDoAnythingForUnhookedEssentials() {
|
||||||
// given
|
// given
|
||||||
PluginHooks pluginHooks = new PluginHooks(mock(PluginManager.class));
|
PluginHookService pluginHookService = new PluginHookService(mock(PluginManager.class));
|
||||||
|
|
||||||
// when/then
|
// when/then
|
||||||
pluginHooks.setEssentialsSocialSpyStatus(mock(Player.class), false);
|
pluginHookService.setEssentialsSocialSpyStatus(mock(Player.class), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -154,15 +155,15 @@ public class PluginHooksTest {
|
|||||||
PluginManager pluginManager = mock(PluginManager.class);
|
PluginManager pluginManager = mock(PluginManager.class);
|
||||||
setPluginAvailable(pluginManager, ESSENTIALS, Essentials.class);
|
setPluginAvailable(pluginManager, ESSENTIALS, Essentials.class);
|
||||||
setPluginAvailable(pluginManager, MULTIVERSE, MultiverseCore.class);
|
setPluginAvailable(pluginManager, MULTIVERSE, MultiverseCore.class);
|
||||||
PluginHooks pluginHooks = new PluginHooks(pluginManager);
|
PluginHookService pluginHookService = new PluginHookService(pluginManager);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
pluginHooks.unhookEssentials();
|
pluginHookService.unhookEssentials();
|
||||||
pluginHooks.unhookMultiverse();
|
pluginHookService.unhookMultiverse();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(pluginHooks.isEssentialsAvailable(), equalTo(false));
|
assertThat(pluginHookService.isEssentialsAvailable(), equalTo(false));
|
||||||
assertThat(pluginHooks.isMultiverseAvailable(), equalTo(false));
|
assertThat(pluginHookService.isMultiverseAvailable(), equalTo(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -173,23 +174,23 @@ public class PluginHooksTest {
|
|||||||
doThrow(IllegalStateException.class).when(pluginManager).getPlugin(anyString());
|
doThrow(IllegalStateException.class).when(pluginManager).getPlugin(anyString());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
PluginHooks pluginHooks = new PluginHooks(pluginManager);
|
PluginHookService pluginHookService = new PluginHookService(pluginManager);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(pluginHooks.isEssentialsAvailable(), equalTo(false));
|
assertThat(pluginHookService.isEssentialsAvailable(), equalTo(false));
|
||||||
assertThat(pluginHooks.isMultiverseAvailable(), equalTo(false));
|
assertThat(pluginHookService.isMultiverseAvailable(), equalTo(false));
|
||||||
assertThat(pluginHooks.isCombatTagPlusAvailable(), equalTo(false));
|
assertThat(pluginHookService.isCombatTagPlusAvailable(), equalTo(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldReturnNullForUnavailableMultiverse() {
|
public void shouldReturnNullForUnavailableMultiverse() {
|
||||||
// given
|
// given
|
||||||
PluginManager pluginManager = mock(PluginManager.class);
|
PluginManager pluginManager = mock(PluginManager.class);
|
||||||
PluginHooks pluginHooks = new PluginHooks(pluginManager);
|
PluginHookService pluginHookService = new PluginHookService(pluginManager);
|
||||||
World world = mock(World.class);
|
World world = mock(World.class);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Location result = pluginHooks.getMultiverseSpawn(world);
|
Location result = pluginHookService.getMultiverseSpawn(world);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, nullValue());
|
assertThat(result, nullValue());
|
||||||
@ -211,10 +212,10 @@ public class PluginHooksTest {
|
|||||||
|
|
||||||
PluginManager pluginManager = mock(PluginManager.class);
|
PluginManager pluginManager = mock(PluginManager.class);
|
||||||
setPluginAvailable(pluginManager, MULTIVERSE, multiverse);
|
setPluginAvailable(pluginManager, MULTIVERSE, multiverse);
|
||||||
PluginHooks pluginHooks = new PluginHooks(pluginManager);
|
PluginHookService pluginHookService = new PluginHookService(pluginManager);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Location spawn = pluginHooks.getMultiverseSpawn(world);
|
Location spawn = pluginHookService.getMultiverseSpawn(world);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(spawn, equalTo(location));
|
assertThat(spawn, equalTo(location));
|
||||||
@ -234,10 +235,10 @@ public class PluginHooksTest {
|
|||||||
MultiverseCore multiverse = mock(MultiverseCore.class);
|
MultiverseCore multiverse = mock(MultiverseCore.class);
|
||||||
setPluginAvailable(pluginManager, MULTIVERSE, multiverse);
|
setPluginAvailable(pluginManager, MULTIVERSE, multiverse);
|
||||||
given(multiverse.getMVWorldManager()).willReturn(mvWorldManager);
|
given(multiverse.getMVWorldManager()).willReturn(mvWorldManager);
|
||||||
PluginHooks pluginHooks = new PluginHooks(pluginManager);
|
PluginHookService pluginHookService = new PluginHookService(pluginManager);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Location spawn = pluginHooks.getMultiverseSpawn(world);
|
Location spawn = pluginHookService.getMultiverseSpawn(world);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(spawn, nullValue());
|
assertThat(spawn, nullValue());
|
@ -5,7 +5,6 @@ import ch.jalu.injector.testing.DelayedInjectionRunner;
|
|||||||
import ch.jalu.injector.testing.InjectDelayed;
|
import ch.jalu.injector.testing.InjectDelayed;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.geoip.GeoIpManager;
|
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||||
@ -45,7 +44,7 @@ public class ValidationServiceTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
@Mock
|
@Mock
|
||||||
private GeoIpManager geoIpManager;
|
private GeoIpService geoIpService;
|
||||||
|
|
||||||
@BeforeInjecting
|
@BeforeInjecting
|
||||||
public void createService() {
|
public void createService() {
|
||||||
@ -266,7 +265,7 @@ public class ValidationServiceTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(true));
|
assertThat(result, equalTo(true));
|
||||||
verifyZeroInteractions(geoIpManager);
|
verifyZeroInteractions(geoIpService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -275,14 +274,14 @@ public class ValidationServiceTest {
|
|||||||
given(settings.getProperty(ProtectionSettings.COUNTRIES_WHITELIST)).willReturn(asList("ch", "it"));
|
given(settings.getProperty(ProtectionSettings.COUNTRIES_WHITELIST)).willReturn(asList("ch", "it"));
|
||||||
given(settings.getProperty(ProtectionSettings.COUNTRIES_BLACKLIST)).willReturn(Collections.<String>emptyList());
|
given(settings.getProperty(ProtectionSettings.COUNTRIES_BLACKLIST)).willReturn(Collections.<String>emptyList());
|
||||||
String ip = "127.0.0.1";
|
String ip = "127.0.0.1";
|
||||||
given(geoIpManager.getCountryCode(ip)).willReturn("CH");
|
given(geoIpService.getCountryCode(ip)).willReturn("CH");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
boolean result = validationService.isCountryAdmitted(ip);
|
boolean result = validationService.isCountryAdmitted(ip);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(true));
|
assertThat(result, equalTo(true));
|
||||||
verify(geoIpManager).getCountryCode(ip);
|
verify(geoIpService).getCountryCode(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -291,14 +290,14 @@ public class ValidationServiceTest {
|
|||||||
given(settings.getProperty(ProtectionSettings.COUNTRIES_WHITELIST)).willReturn(asList("ch", "it"));
|
given(settings.getProperty(ProtectionSettings.COUNTRIES_WHITELIST)).willReturn(asList("ch", "it"));
|
||||||
given(settings.getProperty(ProtectionSettings.COUNTRIES_BLACKLIST)).willReturn(Collections.<String>emptyList());
|
given(settings.getProperty(ProtectionSettings.COUNTRIES_BLACKLIST)).willReturn(Collections.<String>emptyList());
|
||||||
String ip = "123.45.67.89";
|
String ip = "123.45.67.89";
|
||||||
given(geoIpManager.getCountryCode(ip)).willReturn("BR");
|
given(geoIpService.getCountryCode(ip)).willReturn("BR");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
boolean result = validationService.isCountryAdmitted(ip);
|
boolean result = validationService.isCountryAdmitted(ip);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verify(geoIpManager).getCountryCode(ip);
|
verify(geoIpService).getCountryCode(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -307,14 +306,14 @@ public class ValidationServiceTest {
|
|||||||
given(settings.getProperty(ProtectionSettings.COUNTRIES_WHITELIST)).willReturn(Collections.<String>emptyList());
|
given(settings.getProperty(ProtectionSettings.COUNTRIES_WHITELIST)).willReturn(Collections.<String>emptyList());
|
||||||
given(settings.getProperty(ProtectionSettings.COUNTRIES_BLACKLIST)).willReturn(asList("ch", "it"));
|
given(settings.getProperty(ProtectionSettings.COUNTRIES_BLACKLIST)).willReturn(asList("ch", "it"));
|
||||||
String ip = "127.0.0.1";
|
String ip = "127.0.0.1";
|
||||||
given(geoIpManager.getCountryCode(ip)).willReturn("BR");
|
given(geoIpService.getCountryCode(ip)).willReturn("BR");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
boolean result = validationService.isCountryAdmitted(ip);
|
boolean result = validationService.isCountryAdmitted(ip);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(true));
|
assertThat(result, equalTo(true));
|
||||||
verify(geoIpManager).getCountryCode(ip);
|
verify(geoIpService).getCountryCode(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -323,14 +322,14 @@ public class ValidationServiceTest {
|
|||||||
given(settings.getProperty(ProtectionSettings.COUNTRIES_WHITELIST)).willReturn(Collections.<String>emptyList());
|
given(settings.getProperty(ProtectionSettings.COUNTRIES_WHITELIST)).willReturn(Collections.<String>emptyList());
|
||||||
given(settings.getProperty(ProtectionSettings.COUNTRIES_BLACKLIST)).willReturn(asList("ch", "it"));
|
given(settings.getProperty(ProtectionSettings.COUNTRIES_BLACKLIST)).willReturn(asList("ch", "it"));
|
||||||
String ip = "123.45.67.89";
|
String ip = "123.45.67.89";
|
||||||
given(geoIpManager.getCountryCode(ip)).willReturn("IT");
|
given(geoIpService.getCountryCode(ip)).willReturn("IT");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
boolean result = validationService.isCountryAdmitted(ip);
|
boolean result = validationService.isCountryAdmitted(ip);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verify(geoIpManager).getCountryCode(ip);
|
verify(geoIpService).getCountryCode(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertErrorEquals(ValidationResult validationResult, MessageKey messageKey, String... args) {
|
private static void assertErrorEquals(ValidationResult validationResult, MessageKey messageKey, String... args) {
|
||||||
|
@ -6,7 +6,7 @@ import ch.jalu.injector.testing.InjectDelayed;
|
|||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import fr.xephi.authme.TestHelper;
|
import fr.xephi.authme.TestHelper;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.service.PluginHookService;
|
||||||
import fr.xephi.authme.initialization.DataFolder;
|
import fr.xephi.authme.initialization.DataFolder;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -42,7 +42,7 @@ public class SpawnLoaderTest {
|
|||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PluginHooks pluginHooks;
|
private PluginHookService pluginHookService;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||||
|
Loading…
Reference in New Issue
Block a user