mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-20 15:47:38 +01:00
#707 Convert sync processes into services
This commit is contained in:
parent
f5c89e897f
commit
3f039d641a
@ -0,0 +1,10 @@
|
|||||||
|
package fr.xephi.authme.process;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marker interface for asynchronous AuthMe processes.
|
||||||
|
* <p>
|
||||||
|
* These processes handle intensive (I/O or otherwise) actions and are
|
||||||
|
* therefore scheduled to run asynchronously.
|
||||||
|
*/
|
||||||
|
public interface AsynchronousProcess {
|
||||||
|
}
|
@ -1,7 +0,0 @@
|
|||||||
package fr.xephi.authme.process;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Marker interface for AuthMe processes.
|
|
||||||
*/
|
|
||||||
public interface NewProcess {
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
package fr.xephi.authme.process;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Common interface for AuthMe processes.
|
|
||||||
*/
|
|
||||||
public interface Process extends Runnable {
|
|
||||||
|
|
||||||
}
|
|
@ -3,8 +3,6 @@ package fr.xephi.authme.process;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
|
||||||
import fr.xephi.authme.settings.NewSetting;
|
import fr.xephi.authme.settings.NewSetting;
|
||||||
import fr.xephi.authme.settings.domain.Property;
|
import fr.xephi.authme.settings.domain.Property;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
@ -29,8 +27,6 @@ public class ProcessService {
|
|||||||
@Inject
|
@Inject
|
||||||
private AuthMe authMe;
|
private AuthMe authMe;
|
||||||
@Inject
|
@Inject
|
||||||
private PasswordSecurity passwordSecurity;
|
|
||||||
@Inject
|
|
||||||
private ValidationService validationService;
|
private ValidationService validationService;
|
||||||
@Inject
|
@Inject
|
||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
@ -145,17 +141,6 @@ public class ProcessService {
|
|||||||
return authMe;
|
return authMe;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the hash for the given password.
|
|
||||||
*
|
|
||||||
* @param password the password to hash
|
|
||||||
* @param username the user to hash for
|
|
||||||
* @return the resulting hash
|
|
||||||
*/
|
|
||||||
public HashedPassword computeHash(String password, String username) {
|
|
||||||
return passwordSecurity.computeHash(password, username);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies whether a password is valid according to the plugin settings.
|
* Verifies whether a password is valid according to the plugin settings.
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,86 @@
|
|||||||
|
package fr.xephi.authme.process;
|
||||||
|
|
||||||
|
import fr.xephi.authme.process.login.ProcessSyncPlayerLogin;
|
||||||
|
import fr.xephi.authme.process.logout.ProcessSynchronousPlayerLogout;
|
||||||
|
import fr.xephi.authme.process.quit.ProcessSyncronousPlayerQuit;
|
||||||
|
import fr.xephi.authme.process.register.ProcessSyncEmailRegister;
|
||||||
|
import fr.xephi.authme.process.register.ProcessSyncPasswordRegister;
|
||||||
|
import fr.xephi.authme.util.BukkitService;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manager for scheduling synchronous processes internally from the asynchronous processes.
|
||||||
|
* These synchronous processes are a continuation of the associated async processes; they only
|
||||||
|
* contain certain tasks which may only be run synchronously (most interactions with Bukkit).
|
||||||
|
* These synchronous tasks should never be called aside from the asynchronous processes.
|
||||||
|
*
|
||||||
|
* @see Management
|
||||||
|
*/
|
||||||
|
public class SyncProcessManager {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BukkitService bukkitService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ProcessSyncEmailRegister processSyncEmailRegister;
|
||||||
|
@Inject
|
||||||
|
private ProcessSyncPasswordRegister processSyncPasswordRegister;
|
||||||
|
@Inject
|
||||||
|
private ProcessSyncPlayerLogin processSyncPlayerLogin;
|
||||||
|
@Inject
|
||||||
|
private ProcessSynchronousPlayerLogout processSynchronousPlayerLogout;
|
||||||
|
@Inject
|
||||||
|
private ProcessSyncronousPlayerQuit processSyncronousPlayerQuit;
|
||||||
|
|
||||||
|
|
||||||
|
public void processSyncEmailRegister(final Player player) {
|
||||||
|
runTask(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
processSyncEmailRegister.processEmailRegister(player);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processSyncPasswordRegister(final Player player) {
|
||||||
|
runTask(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
processSyncPasswordRegister.processPasswordRegister(player);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processSyncPlayerLogout(final Player player) {
|
||||||
|
runTask(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
processSynchronousPlayerLogout.processSyncLogout(player);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processSyncPlayerLogin(final Player player) {
|
||||||
|
runTask(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
processSyncPlayerLogin.processPlayerLogin(player);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processSyncPlayerQuit(final Player player, final boolean isOp, final boolean needToChange) {
|
||||||
|
runTask(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
processSyncronousPlayerQuit.processSyncQuit(player, isOp, needToChange);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runTask(Runnable runnable) {
|
||||||
|
bukkitService.scheduleSyncDelayedTask(runnable);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package fr.xephi.authme.process;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marker interface for synchronous processes.
|
||||||
|
* <p>
|
||||||
|
* Such processes are scheduled by {@link AsynchronousProcess asynchronous tasks} to perform tasks
|
||||||
|
* which are required to be executed synchronously (e.g. interactions with the Bukkit API).
|
||||||
|
*/
|
||||||
|
public interface SynchronousProcess {
|
||||||
|
}
|
@ -5,7 +5,7 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.process.NewProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -15,7 +15,7 @@ import javax.inject.Inject;
|
|||||||
/**
|
/**
|
||||||
* Async task to add an email to an account.
|
* Async task to add an email to an account.
|
||||||
*/
|
*/
|
||||||
public class AsyncAddEmail implements NewProcess {
|
public class AsyncAddEmail implements AsynchronousProcess {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ProcessService service;
|
private ProcessService service;
|
||||||
|
@ -4,7 +4,7 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.process.NewProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -14,7 +14,7 @@ import javax.inject.Inject;
|
|||||||
/**
|
/**
|
||||||
* Async task for changing the email.
|
* Async task for changing the email.
|
||||||
*/
|
*/
|
||||||
public class AsyncChangeEmail implements NewProcess {
|
public class AsyncChangeEmail implements AsynchronousProcess {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ProcessService service;
|
private ProcessService service;
|
||||||
|
@ -14,7 +14,7 @@ import fr.xephi.authme.hooks.PluginHooks;
|
|||||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||||
import fr.xephi.authme.process.NewProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
@ -40,9 +40,8 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN;
|
import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
public class AsynchronousJoin implements AsynchronousProcess {
|
||||||
public class AsynchronousJoin implements NewProcess {
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AuthMe plugin;
|
private AuthMe plugin;
|
||||||
|
@ -13,8 +13,9 @@ import fr.xephi.authme.permission.AdminPermission;
|
|||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
import fr.xephi.authme.permission.PlayerPermission;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||||
import fr.xephi.authme.process.NewProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
|
import fr.xephi.authme.process.SyncProcessManager;
|
||||||
import fr.xephi.authme.security.RandomString;
|
import fr.xephi.authme.security.RandomString;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
@ -34,7 +35,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class AsynchronousLogin implements NewProcess {
|
public class AsynchronousLogin implements AsynchronousProcess {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AuthMe plugin;
|
private AuthMe plugin;
|
||||||
@ -54,6 +55,10 @@ public class AsynchronousLogin implements NewProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private LimboCache limboCache;
|
private LimboCache limboCache;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SyncProcessManager syncProcessManager;
|
||||||
|
|
||||||
|
|
||||||
AsynchronousLogin() { }
|
AsynchronousLogin() { }
|
||||||
|
|
||||||
private boolean needsCaptcha(Player player) {
|
private boolean needsCaptcha(Player player) {
|
||||||
@ -187,16 +192,16 @@ public class AsynchronousLogin implements NewProcess {
|
|||||||
// task, we schedule it in the end
|
// task, we schedule it in the end
|
||||||
// so that we can be sure, and have not to care if it might be
|
// so that we can be sure, and have not to care if it might be
|
||||||
// processed in other order.
|
// processed in other order.
|
||||||
ProcessSyncPlayerLogin syncPlayerLogin = new ProcessSyncPlayerLogin(player, plugin, database, service);
|
LimboPlayer limboPlayer = limboCache.getLimboPlayer(name);
|
||||||
if (syncPlayerLogin.getLimbo() != null) {
|
if (limboPlayer != null) {
|
||||||
if (syncPlayerLogin.getLimbo().getTimeoutTask() != null) {
|
if (limboPlayer.getTimeoutTask() != null) {
|
||||||
syncPlayerLogin.getLimbo().getTimeoutTask().cancel();
|
limboPlayer.getTimeoutTask().cancel();
|
||||||
}
|
}
|
||||||
if (syncPlayerLogin.getLimbo().getMessageTask() != null) {
|
if (limboPlayer.getMessageTask() != null) {
|
||||||
syncPlayerLogin.getLimbo().getMessageTask().cancel();
|
limboPlayer.getMessageTask().cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, syncPlayerLogin);
|
syncProcessManager.processSyncPlayerLogin(player);
|
||||||
} else if (player.isOnline()) {
|
} else if (player.isOnline()) {
|
||||||
if (!service.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)) {
|
if (!service.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)) {
|
||||||
ConsoleLogger.info(player.getName() + " used the wrong password");
|
ConsoleLogger.info(player.getName() + " used the wrong password");
|
||||||
@ -233,12 +238,12 @@ public class AsynchronousLogin implements NewProcess {
|
|||||||
ConsoleLogger.info(message);
|
ConsoleLogger.info(message);
|
||||||
|
|
||||||
for (Player onlinePlayer : service.getOnlinePlayers()) {
|
for (Player onlinePlayer : service.getOnlinePlayers()) {
|
||||||
if ((onlinePlayer.getName().equalsIgnoreCase(onlinePlayer.getName())
|
if (onlinePlayer.getName().equalsIgnoreCase(player.getName())
|
||||||
&& permissionsManager.hasPermission(onlinePlayer, PlayerPermission.SEE_OWN_ACCOUNTS))) {
|
&& permissionsManager.hasPermission(onlinePlayer, PlayerPermission.SEE_OWN_ACCOUNTS)) {
|
||||||
onlinePlayer.sendMessage("You own " + auths.size() + " accounts:");
|
onlinePlayer.sendMessage("You own " + auths.size() + " accounts:");
|
||||||
onlinePlayer.sendMessage(message);
|
onlinePlayer.sendMessage(message);
|
||||||
} else if (permissionsManager.hasPermission(onlinePlayer, AdminPermission.SEE_OTHER_ACCOUNTS)) {
|
} else if (permissionsManager.hasPermission(onlinePlayer, AdminPermission.SEE_OTHER_ACCOUNTS)) {
|
||||||
onlinePlayer.sendMessage("The user " + onlinePlayer.getName() + " has " + auths.size() + " accounts:");
|
onlinePlayer.sendMessage("The user " + player.getName() + " has " + auths.size() + " accounts:");
|
||||||
onlinePlayer.sendMessage(message);
|
onlinePlayer.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.google.common.io.ByteArrayDataOutput;
|
|||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.backup.JsonCache;
|
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
@ -13,8 +12,8 @@ import fr.xephi.authme.events.LoginEvent;
|
|||||||
import fr.xephi.authme.events.RestoreInventoryEvent;
|
import fr.xephi.authme.events.RestoreInventoryEvent;
|
||||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||||
import fr.xephi.authme.process.Process;
|
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
|
import fr.xephi.authme.process.SynchronousProcess;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
@ -29,125 +28,106 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static fr.xephi.authme.settings.properties.PluginSettings.KEEP_COLLISIONS_DISABLED;
|
import static fr.xephi.authme.settings.properties.PluginSettings.KEEP_COLLISIONS_DISABLED;
|
||||||
import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN;
|
import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN;
|
||||||
|
|
||||||
public class ProcessSyncPlayerLogin implements Process {
|
public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||||
|
|
||||||
private final LimboPlayer limbo;
|
@Inject
|
||||||
private final Player player;
|
private AuthMe plugin;
|
||||||
private final String name;
|
|
||||||
private final PlayerAuth auth;
|
@Inject
|
||||||
private final AuthMe plugin;
|
private ProcessService service;
|
||||||
private final PluginManager pm;
|
|
||||||
private final JsonCache playerCache;
|
@Inject
|
||||||
private final ProcessService service;
|
private LimboCache limboCache;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private DataSource dataSource;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
// TODO ljacqu 20160520: Need to check whether we want to inject PluginManager, or some intermediate service
|
||||||
|
private PluginManager pluginManager;
|
||||||
|
|
||||||
private final boolean restoreCollisions = MethodUtils
|
private final boolean restoreCollisions = MethodUtils
|
||||||
.getAccessibleMethod(LivingEntity.class, "setCollidable", new Class[]{}) != null;
|
.getAccessibleMethod(LivingEntity.class, "setCollidable", new Class[]{}) != null;
|
||||||
|
|
||||||
/**
|
ProcessSyncPlayerLogin() { }
|
||||||
* Constructor for ProcessSyncPlayerLogin.
|
|
||||||
*
|
|
||||||
* @param player Player
|
|
||||||
* @param plugin AuthMe
|
|
||||||
* @param database DataSource
|
|
||||||
* @param service The process service
|
|
||||||
*/
|
|
||||||
public ProcessSyncPlayerLogin(Player player, AuthMe plugin, DataSource database, ProcessService service) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.pm = plugin.getServer().getPluginManager();
|
|
||||||
this.player = player;
|
|
||||||
this.name = player.getName().toLowerCase();
|
|
||||||
this.limbo = LimboCache.getInstance().getLimboPlayer(name);
|
|
||||||
this.auth = database.getAuth(name);
|
|
||||||
this.playerCache = new JsonCache();
|
|
||||||
this.service = service;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LimboPlayer getLimbo() {
|
|
||||||
return limbo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void restoreOpState() {
|
private void packQuitLocation(Player player, PlayerAuth auth) {
|
||||||
player.setOp(limbo.isOperator());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void packQuitLocation() {
|
|
||||||
Utils.packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player);
|
Utils.packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void teleportBackFromSpawn() {
|
private void teleportBackFromSpawn(Player player, LimboPlayer limboPlayer) {
|
||||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limboPlayer.getLoc());
|
||||||
pm.callEvent(tpEvent);
|
pluginManager.callEvent(tpEvent);
|
||||||
if (!tpEvent.isCancelled() && tpEvent.getTo() != null) {
|
if (!tpEvent.isCancelled() && tpEvent.getTo() != null) {
|
||||||
player.teleport(tpEvent.getTo());
|
player.teleport(tpEvent.getTo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void teleportToSpawn() {
|
private void teleportToSpawn(Player player) {
|
||||||
Location spawnL = plugin.getSpawnLocation(player);
|
Location spawnL = plugin.getSpawnLocation(player);
|
||||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnL, true);
|
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnL, true);
|
||||||
pm.callEvent(tpEvent);
|
pluginManager.callEvent(tpEvent);
|
||||||
if (!tpEvent.isCancelled() && tpEvent.getTo() != null) {
|
if (!tpEvent.isCancelled() && tpEvent.getTo() != null) {
|
||||||
player.teleport(tpEvent.getTo());
|
player.teleport(tpEvent.getTo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreSpeedEffects() {
|
private void restoreSpeedEffects(Player player) {
|
||||||
if (!service.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT) && service.getProperty(RestrictionSettings.REMOVE_SPEED)) {
|
if (!service.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT)
|
||||||
|
&& service.getProperty(RestrictionSettings.REMOVE_SPEED)) {
|
||||||
player.setWalkSpeed(0.2F);
|
player.setWalkSpeed(0.2F);
|
||||||
player.setFlySpeed(0.1F);
|
player.setFlySpeed(0.1F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreInventory() {
|
private void restoreInventory(Player player) {
|
||||||
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
|
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
|
||||||
pm.callEvent(event);
|
pluginManager.callEvent(event);
|
||||||
if (!event.isCancelled() && plugin.inventoryProtector != null) {
|
if (!event.isCancelled() && plugin.inventoryProtector != null) {
|
||||||
plugin.inventoryProtector.sendInventoryPacket(player);
|
plugin.inventoryProtector.sendInventoryPacket(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void forceCommands() {
|
private void forceCommands(Player player) {
|
||||||
for (String command : service.getProperty(RegistrationSettings.FORCE_COMMANDS)) {
|
for (String command : service.getProperty(RegistrationSettings.FORCE_COMMANDS)) {
|
||||||
player.performCommand(command.replace("%p", player.getName()));
|
player.performCommand(command.replace("%p", player.getName()));
|
||||||
}
|
}
|
||||||
for (String command : service.getProperty(RegistrationSettings.FORCE_COMMANDS_AS_CONSOLE)) {
|
for (String command : service.getProperty(RegistrationSettings.FORCE_COMMANDS_AS_CONSOLE)) {
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.replace("%p", player.getName()));
|
Bukkit.getServer().dispatchCommand(
|
||||||
|
Bukkit.getServer().getConsoleSender(), command.replace("%p", player.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendBungeeMessage() {
|
public void processPlayerLogin(Player player) {
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
final String name = player.getName().toLowerCase();
|
||||||
out.writeUTF("Forward");
|
|
||||||
out.writeUTF("ALL");
|
|
||||||
out.writeUTF("AuthMe");
|
|
||||||
out.writeUTF("login;" + name);
|
|
||||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// Limbo contains the State of the Player before /login
|
// Limbo contains the State of the Player before /login
|
||||||
|
final LimboPlayer limbo = limboCache.getLimboPlayer(name);
|
||||||
|
final PlayerAuth auth = dataSource.getAuth(name);
|
||||||
|
|
||||||
if (limbo != null) {
|
if (limbo != null) {
|
||||||
// Restore Op state and Permission Group
|
// Restore Op state and Permission Group
|
||||||
restoreOpState();
|
restoreOpState(player, limbo);
|
||||||
Utils.setGroup(player, GroupType.LOGGEDIN);
|
Utils.setGroup(player, GroupType.LOGGEDIN);
|
||||||
|
|
||||||
if (!Settings.noTeleport) {
|
if (!Settings.noTeleport) {
|
||||||
if (Settings.isTeleportToSpawnEnabled && !Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
if (Settings.isTeleportToSpawnEnabled && !Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
||||||
if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
|
if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
|
||||||
packQuitLocation();
|
packQuitLocation(player, auth);
|
||||||
} else {
|
} else {
|
||||||
teleportBackFromSpawn();
|
teleportBackFromSpawn(player, limbo);
|
||||||
}
|
}
|
||||||
} else if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
} else if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
||||||
teleportToSpawn();
|
teleportToSpawn(player);
|
||||||
} else if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
|
} else if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
|
||||||
packQuitLocation();
|
packQuitLocation(player, auth);
|
||||||
} else {
|
} else {
|
||||||
teleportBackFromSpawn();
|
teleportBackFromSpawn(player, limbo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,18 +136,15 @@ public class ProcessSyncPlayerLogin implements Process {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
|
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
|
||||||
restoreInventory();
|
restoreInventory(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN) && plugin.tablistHider != null) {
|
if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN) && plugin.tablistHider != null) {
|
||||||
plugin.tablistHider.sendTablist(player);
|
plugin.tablistHider.sendTablist(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup no longer used temporary data
|
// Clean up no longer used temporary data
|
||||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
limboCache.deleteLimboPlayer(name);
|
||||||
if (playerCache.doesCacheExist(player)) {
|
|
||||||
playerCache.removeCache(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can now display the join message (if delayed)
|
// We can now display the join message (if delayed)
|
||||||
@ -183,7 +160,7 @@ public class ProcessSyncPlayerLogin implements Process {
|
|||||||
AuthMePlayerListener.joinMessage.remove(name);
|
AuthMePlayerListener.joinMessage.remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
restoreSpeedEffects();
|
restoreSpeedEffects(player);
|
||||||
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||||
}
|
}
|
||||||
@ -192,7 +169,7 @@ public class ProcessSyncPlayerLogin implements Process {
|
|||||||
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player));
|
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player));
|
||||||
player.saveData();
|
player.saveData();
|
||||||
if (service.getProperty(HooksSettings.BUNGEECORD)) {
|
if (service.getProperty(HooksSettings.BUNGEECORD)) {
|
||||||
sendBungeeMessage();
|
sendBungeeMessage(player);
|
||||||
}
|
}
|
||||||
// Login is done, display welcome message
|
// Login is done, display welcome message
|
||||||
if (service.getProperty(RegistrationSettings.USE_WELCOME_MESSAGE)) {
|
if (service.getProperty(RegistrationSettings.USE_WELCOME_MESSAGE)) {
|
||||||
@ -208,12 +185,16 @@ public class ProcessSyncPlayerLogin implements Process {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Login is now finished; we can force all commands
|
// Login is now finished; we can force all commands
|
||||||
forceCommands();
|
forceCommands(player);
|
||||||
|
|
||||||
sendTo();
|
sendTo(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendTo() {
|
private void restoreOpState(Player player, LimboPlayer limboPlayer) {
|
||||||
|
player.setOp(limboPlayer.isOperator());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendTo(Player player) {
|
||||||
if (!service.getProperty(HooksSettings.BUNGEECORD_SERVER).isEmpty()) {
|
if (!service.getProperty(HooksSettings.BUNGEECORD_SERVER).isEmpty()) {
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
out.writeUTF("Connect");
|
out.writeUTF("Connect");
|
||||||
@ -221,4 +202,14 @@ public class ProcessSyncPlayerLogin implements Process {
|
|||||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendBungeeMessage(Player player) {
|
||||||
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
|
out.writeUTF("Forward");
|
||||||
|
out.writeUTF("ALL");
|
||||||
|
out.writeUTF("AuthMe");
|
||||||
|
out.writeUTF("login;" + player.getName());
|
||||||
|
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,16 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.process.NewProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
|
import fr.xephi.authme.process.SyncProcessManager;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import fr.xephi.authme.util.Utils.GroupType;
|
import fr.xephi.authme.util.Utils.GroupType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class AsynchronousLogout implements NewProcess {
|
public class AsynchronousLogout implements AsynchronousProcess {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AuthMe plugin;
|
private AuthMe plugin;
|
||||||
@ -31,21 +32,23 @@ public class AsynchronousLogout implements NewProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private LimboCache limboCache;
|
private LimboCache limboCache;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SyncProcessManager syncProcessManager;
|
||||||
|
|
||||||
AsynchronousLogout() { }
|
AsynchronousLogout() { }
|
||||||
|
|
||||||
public void logout(Player player) {
|
public void logout(final Player player) {
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
if (!playerCache.isAuthenticated(name)) {
|
if (!playerCache.isAuthenticated(name)) {
|
||||||
service.send(player, MessageKey.NOT_LOGGED_IN);
|
service.send(player, MessageKey.NOT_LOGGED_IN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Player p = player;
|
PlayerAuth auth = playerCache.getAuth(name);
|
||||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
|
||||||
database.updateSession(auth);
|
database.updateSession(auth);
|
||||||
auth.setQuitLocX(p.getLocation().getX());
|
auth.setQuitLocX(player.getLocation().getX());
|
||||||
auth.setQuitLocY(p.getLocation().getY());
|
auth.setQuitLocY(player.getLocation().getY());
|
||||||
auth.setQuitLocZ(p.getLocation().getZ());
|
auth.setQuitLocZ(player.getLocation().getZ());
|
||||||
auth.setWorld(p.getWorld().getName());
|
auth.setWorld(player.getWorld().getName());
|
||||||
database.updateQuitLoc(auth);
|
database.updateQuitLoc(auth);
|
||||||
|
|
||||||
playerCache.removePlayer(name);
|
playerCache.removePlayer(name);
|
||||||
@ -53,7 +56,7 @@ public class AsynchronousLogout implements NewProcess {
|
|||||||
service.scheduleSyncDelayedTask(new Runnable() {
|
service.scheduleSyncDelayedTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Utils.teleportToSpawn(p);
|
Utils.teleportToSpawn(player);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (limboCache.hasLimboPlayer(name)) {
|
if (limboCache.hasLimboPlayer(name)) {
|
||||||
@ -61,6 +64,6 @@ public class AsynchronousLogout implements NewProcess {
|
|||||||
}
|
}
|
||||||
limboCache.addLimboPlayer(player);
|
limboCache.addLimboPlayer(player);
|
||||||
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
|
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
|
||||||
service.scheduleSyncDelayedTask(new ProcessSynchronousPlayerLogout(p, plugin, service));
|
syncProcessManager.processSyncPlayerLogout(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.events.LogoutEvent;
|
import fr.xephi.authme.events.LogoutEvent;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.process.Process;
|
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
|
import fr.xephi.authme.process.SynchronousProcess;
|
||||||
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.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
@ -20,47 +20,42 @@ import org.bukkit.potion.PotionEffect;
|
|||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
import javax.inject.Inject;
|
||||||
*/
|
|
||||||
public class ProcessSynchronousPlayerLogout implements Process {
|
|
||||||
|
|
||||||
private final Player player;
|
import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
|
||||||
private final AuthMe plugin;
|
|
||||||
private final String name;
|
|
||||||
private final ProcessService service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for ProcessSynchronousPlayerLogout.
|
|
||||||
*
|
|
||||||
* @param player Player
|
|
||||||
* @param plugin AuthMe
|
|
||||||
* @param service The process service
|
|
||||||
*/
|
|
||||||
public ProcessSynchronousPlayerLogout(Player player, AuthMe plugin, ProcessService service) {
|
|
||||||
this.player = player;
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.name = player.getName().toLowerCase();
|
|
||||||
this.service = service;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void sendBungeeMessage() {
|
public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AuthMe plugin;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ProcessService service;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private LimboCache limboCache;
|
||||||
|
|
||||||
|
ProcessSynchronousPlayerLogout() { }
|
||||||
|
|
||||||
|
private void sendBungeeMessage(Player player) {
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
out.writeUTF("Forward");
|
out.writeUTF("Forward");
|
||||||
out.writeUTF("ALL");
|
out.writeUTF("ALL");
|
||||||
out.writeUTF("AuthMe");
|
out.writeUTF("AuthMe");
|
||||||
out.writeUTF("logout;" + name);
|
out.writeUTF("logout;" + player.getName());
|
||||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void restoreSpeedEffect() {
|
private void restoreSpeedEffect(Player player) {
|
||||||
if (Settings.isRemoveSpeedEnabled) {
|
if (Settings.isRemoveSpeedEnabled) {
|
||||||
player.setWalkSpeed(0.0F);
|
player.setWalkSpeed(0.0F);
|
||||||
player.setFlySpeed(0.0F);
|
player.setFlySpeed(0.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void processSyncLogout(Player player) {
|
||||||
public void run() {
|
final String name = player.getName().toLowerCase();
|
||||||
if (plugin.sessions.containsKey(name)) {
|
if (plugin.sessions.containsKey(name)) {
|
||||||
plugin.sessions.get(name).cancel();
|
plugin.sessions.get(name).cancel();
|
||||||
plugin.sessions.remove(name);
|
plugin.sessions.remove(name);
|
||||||
@ -68,15 +63,15 @@ public class ProcessSynchronousPlayerLogout implements Process {
|
|||||||
if (Settings.protectInventoryBeforeLogInEnabled) {
|
if (Settings.protectInventoryBeforeLogInEnabled) {
|
||||||
plugin.inventoryProtector.sendBlankInventoryPacket(player);
|
plugin.inventoryProtector.sendBlankInventoryPacket(player);
|
||||||
}
|
}
|
||||||
int timeOut = service.getProperty(RestrictionSettings.TIMEOUT) * 20;
|
int timeOut = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
|
||||||
int interval = service.getProperty(RegistrationSettings.MESSAGE_INTERVAL);
|
int interval = service.getProperty(RegistrationSettings.MESSAGE_INTERVAL);
|
||||||
if (timeOut != 0) {
|
if (timeOut != 0) {
|
||||||
BukkitTask id = service.runTaskLater(new TimeoutTask(plugin, name, player), timeOut);
|
BukkitTask id = service.runTaskLater(new TimeoutTask(plugin, name, player), timeOut);
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTask(id);
|
limboCache.getLimboPlayer(name).setTimeoutTask(id);
|
||||||
}
|
}
|
||||||
BukkitTask msgT = service.runTask(new MessageTask(service.getBukkitService(), plugin.getMessages(),
|
BukkitTask msgT = service.runTask(new MessageTask(service.getBukkitService(), plugin.getMessages(),
|
||||||
name, MessageKey.LOGIN_MESSAGE, interval));
|
name, MessageKey.LOGIN_MESSAGE, interval));
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTask(msgT);
|
limboCache.getLimboPlayer(name).setMessageTask(msgT);
|
||||||
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
||||||
player.getVehicle().eject();
|
player.getVehicle().eject();
|
||||||
}
|
}
|
||||||
@ -84,11 +79,11 @@ public class ProcessSynchronousPlayerLogout implements Process {
|
|||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2));
|
||||||
}
|
}
|
||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
restoreSpeedEffect();
|
restoreSpeedEffect(player);
|
||||||
// Player is now logout... Time to fire event !
|
// Player is now logout... Time to fire event !
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
|
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
|
||||||
if (Settings.bungee) {
|
if (Settings.bungee) {
|
||||||
sendBungeeMessage();
|
sendBungeeMessage(player);
|
||||||
}
|
}
|
||||||
service.send(player, MessageKey.LOGOUT_SUCCESS);
|
service.send(player, MessageKey.LOGOUT_SUCCESS);
|
||||||
ConsoleLogger.info(player.getName() + " logged out");
|
ConsoleLogger.info(player.getName() + " logged out");
|
||||||
|
@ -7,8 +7,9 @@ import fr.xephi.authme.cache.limbo.LimboCache;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.datasource.CacheDataSource;
|
import fr.xephi.authme.datasource.CacheDataSource;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.process.NewProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
|
import fr.xephi.authme.process.SyncProcessManager;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
@ -19,7 +20,9 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class AsynchronousQuit implements NewProcess {
|
import static fr.xephi.authme.util.BukkitService.TICKS_PER_MINUTE;
|
||||||
|
|
||||||
|
public class AsynchronousQuit implements AsynchronousProcess {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AuthMe plugin;
|
private AuthMe plugin;
|
||||||
@ -36,6 +39,9 @@ public class AsynchronousQuit implements NewProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private LimboCache limboCache;
|
private LimboCache limboCache;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SyncProcessManager syncProcessManager;
|
||||||
|
|
||||||
AsynchronousQuit() { }
|
AsynchronousQuit() { }
|
||||||
|
|
||||||
|
|
||||||
@ -86,7 +92,7 @@ public class AsynchronousQuit implements NewProcess {
|
|||||||
postLogout(name);
|
postLogout(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, Settings.getSessionTimeout * 20 * 60);
|
}, Settings.getSessionTimeout * TICKS_PER_MINUTE);
|
||||||
|
|
||||||
plugin.sessions.put(name, task);
|
plugin.sessions.put(name, task);
|
||||||
} else {
|
} else {
|
||||||
@ -100,7 +106,7 @@ public class AsynchronousQuit implements NewProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.isEnabled()) {
|
if (plugin.isEnabled()) {
|
||||||
service.scheduleSyncDelayedTask(new ProcessSyncronousPlayerQuit(plugin, player, isOp, needToChange));
|
syncProcessManager.processSyncPlayerQuit(player, isOp, needToChange);
|
||||||
}
|
}
|
||||||
// remove player from cache
|
// remove player from cache
|
||||||
if (database instanceof CacheDataSource) {
|
if (database instanceof CacheDataSource) {
|
||||||
|
@ -1,40 +1,12 @@
|
|||||||
package fr.xephi.authme.process.quit;
|
package fr.xephi.authme.process.quit;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.process.SynchronousProcess;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class ProcessSyncronousPlayerQuit implements Runnable {
|
|
||||||
|
|
||||||
protected final AuthMe plugin;
|
public class ProcessSyncronousPlayerQuit implements SynchronousProcess {
|
||||||
protected final Player player;
|
|
||||||
protected final boolean isOp;
|
|
||||||
protected final boolean needToChange;
|
|
||||||
|
|
||||||
/**
|
public void processSyncQuit(Player player, boolean isOp, boolean needToChange) {
|
||||||
* Constructor for ProcessSyncronousPlayerQuit.
|
|
||||||
*
|
|
||||||
* @param plugin AuthMe
|
|
||||||
* @param player Player
|
|
||||||
* @param isOp boolean
|
|
||||||
* @param needToChange boolean
|
|
||||||
*/
|
|
||||||
public ProcessSyncronousPlayerQuit(AuthMe plugin, Player player
|
|
||||||
, boolean isOp, boolean needToChange) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.player = player;
|
|
||||||
this.isOp = isOp;
|
|
||||||
this.needToChange = needToChange;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method run.
|
|
||||||
*
|
|
||||||
* @see java.lang.Runnable#run()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (needToChange) {
|
if (needToChange) {
|
||||||
player.setOp(isOp);
|
player.setOp(isOp);
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,11 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||||
import fr.xephi.authme.process.NewProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
|
import fr.xephi.authme.process.SyncProcessManager;
|
||||||
import fr.xephi.authme.security.HashAlgorithm;
|
import fr.xephi.authme.security.HashAlgorithm;
|
||||||
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
import fr.xephi.authme.security.crypts.TwoFactor;
|
import fr.xephi.authme.security.crypts.TwoFactor;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
@ -24,7 +26,7 @@ import org.bukkit.entity.Player;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AsyncRegister implements NewProcess {
|
public class AsyncRegister implements AsynchronousProcess {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AuthMe plugin;
|
private AuthMe plugin;
|
||||||
@ -35,9 +37,15 @@ public class AsyncRegister implements NewProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PasswordSecurity passwordSecurity;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ProcessService service;
|
private ProcessService service;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SyncProcessManager syncProcessManager;
|
||||||
|
|
||||||
AsyncRegister() { }
|
AsyncRegister() { }
|
||||||
|
|
||||||
private boolean preRegisterCheck(Player player, String password) {
|
private boolean preRegisterCheck(Player player, String password) {
|
||||||
@ -104,7 +112,7 @@ public class AsyncRegister implements NewProcess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final HashedPassword hashedPassword = service.computeHash(password, name);
|
final HashedPassword hashedPassword = passwordSecurity.computeHash(password, name);
|
||||||
final String ip = Utils.getPlayerIp(player);
|
final String ip = Utils.getPlayerIp(player);
|
||||||
PlayerAuth auth = PlayerAuth.builder()
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(name)
|
.name(name)
|
||||||
@ -122,15 +130,13 @@ public class AsyncRegister implements NewProcess {
|
|||||||
database.updateEmail(auth);
|
database.updateEmail(auth);
|
||||||
database.updateSession(auth);
|
database.updateSession(auth);
|
||||||
plugin.mail.main(auth, password);
|
plugin.mail.main(auth, password);
|
||||||
ProcessSyncEmailRegister sync = new ProcessSyncEmailRegister(player, service);
|
syncProcessManager.processSyncEmailRegister(player);
|
||||||
service.scheduleSyncDelayedTask(sync);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void passwordRegister(Player player, String password, boolean autoLogin) {
|
private void passwordRegister(Player player, String password, boolean autoLogin) {
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
final String ip = Utils.getPlayerIp(player);
|
final String ip = Utils.getPlayerIp(player);
|
||||||
final HashedPassword hashedPassword = service.computeHash(password, name);
|
final HashedPassword hashedPassword = passwordSecurity.computeHash(password, name);
|
||||||
PlayerAuth auth = PlayerAuth.builder()
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(name)
|
.name(name)
|
||||||
.realName(player.getName())
|
.realName(player.getName())
|
||||||
@ -150,9 +156,7 @@ public class AsyncRegister implements NewProcess {
|
|||||||
// TODO: check this...
|
// TODO: check this...
|
||||||
plugin.getManagement().performLogin(player, "dontneed", true);
|
plugin.getManagement().performLogin(player, "dontneed", true);
|
||||||
}
|
}
|
||||||
|
syncProcessManager.processSyncPasswordRegister(player);
|
||||||
ProcessSyncPasswordRegister sync = new ProcessSyncPasswordRegister(player, plugin, service);
|
|
||||||
service.scheduleSyncDelayedTask(sync);
|
|
||||||
|
|
||||||
//give the user the secret code to setup their app code generation
|
//give the user the secret code to setup their app code generation
|
||||||
if (service.getProperty(SecuritySettings.PASSWORD_HASH) == HashAlgorithm.TWO_FACTOR) {
|
if (service.getProperty(SecuritySettings.PASSWORD_HASH) == HashAlgorithm.TWO_FACTOR) {
|
||||||
|
@ -4,8 +4,8 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.process.Process;
|
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
|
import fr.xephi.authme.process.SynchronousProcess;
|
||||||
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.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
@ -16,34 +16,29 @@ import fr.xephi.authme.util.Utils;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
import javax.inject.Inject;
|
||||||
*/
|
|
||||||
public class ProcessSyncEmailRegister implements Process {
|
|
||||||
|
|
||||||
private final Player player;
|
import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
|
||||||
private final String name;
|
|
||||||
private final ProcessService service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for ProcessSyncEmailRegister.
|
|
||||||
*
|
|
||||||
* @param player The player to process an email registration for
|
|
||||||
* @param service The process service
|
|
||||||
*/
|
|
||||||
public ProcessSyncEmailRegister(Player player, ProcessService service) {
|
|
||||||
this.player = player;
|
|
||||||
this.name = player.getName().toLowerCase();
|
|
||||||
this.service = service;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public class ProcessSyncEmailRegister implements SynchronousProcess {
|
||||||
public void run() {
|
|
||||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
@Inject
|
||||||
|
private ProcessService service;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private LimboCache limboCache;
|
||||||
|
|
||||||
|
public ProcessSyncEmailRegister() { }
|
||||||
|
|
||||||
|
public void processEmailRegister(Player player) {
|
||||||
|
final String name = player.getName().toLowerCase();
|
||||||
|
LimboPlayer limbo = limboCache.getLimboPlayer(name);
|
||||||
if (!Settings.getRegisteredGroup.isEmpty()) {
|
if (!Settings.getRegisteredGroup.isEmpty()) {
|
||||||
Utils.setGroup(player, Utils.GroupType.REGISTERED);
|
Utils.setGroup(player, Utils.GroupType.REGISTERED);
|
||||||
}
|
}
|
||||||
service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
|
service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
|
||||||
int time = service.getProperty(RestrictionSettings.TIMEOUT) * 20;
|
int time = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
|
||||||
int msgInterval = service.getProperty(RegistrationSettings.MESSAGE_INTERVAL);
|
int msgInterval = service.getProperty(RegistrationSettings.MESSAGE_INTERVAL);
|
||||||
|
|
||||||
if (limbo != null) {
|
if (limbo != null) {
|
||||||
|
@ -9,7 +9,7 @@ import fr.xephi.authme.cache.limbo.LimboPlayer;
|
|||||||
import fr.xephi.authme.events.LoginEvent;
|
import fr.xephi.authme.events.LoginEvent;
|
||||||
import fr.xephi.authme.events.RestoreInventoryEvent;
|
import fr.xephi.authme.events.RestoreInventoryEvent;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.process.Process;
|
import fr.xephi.authme.process.SynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||||
@ -25,35 +25,33 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static fr.xephi.authme.settings.properties.RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN;
|
import static fr.xephi.authme.settings.properties.RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN;
|
||||||
import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
|
import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class ProcessSyncPasswordRegister implements Process {
|
public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
||||||
|
|
||||||
private final Player player;
|
@Inject
|
||||||
private final String name;
|
private AuthMe plugin;
|
||||||
private final AuthMe plugin;
|
|
||||||
private final ProcessService service;
|
|
||||||
|
|
||||||
public ProcessSyncPasswordRegister(Player player, AuthMe plugin, ProcessService service) {
|
@Inject
|
||||||
this.player = player;
|
private ProcessService service;
|
||||||
this.name = player.getName().toLowerCase();
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.service = service;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendBungeeMessage() {
|
ProcessSyncPasswordRegister() { }
|
||||||
|
|
||||||
|
private void sendBungeeMessage(Player player) {
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
out.writeUTF("Forward");
|
out.writeUTF("Forward");
|
||||||
out.writeUTF("ALL");
|
out.writeUTF("ALL");
|
||||||
out.writeUTF("AuthMe");
|
out.writeUTF("AuthMe");
|
||||||
out.writeUTF("register;" + name);
|
out.writeUTF("register;" + player.getName());
|
||||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void forceCommands() {
|
private void forceCommands(Player player) {
|
||||||
for (String command : service.getProperty(RegistrationSettings.FORCE_REGISTER_COMMANDS)) {
|
for (String command : service.getProperty(RegistrationSettings.FORCE_REGISTER_COMMANDS)) {
|
||||||
player.performCommand(command.replace("%p", player.getName()));
|
player.performCommand(command.replace("%p", player.getName()));
|
||||||
}
|
}
|
||||||
@ -69,6 +67,7 @@ public class ProcessSyncPasswordRegister implements Process {
|
|||||||
* @param player the player
|
* @param player the player
|
||||||
*/
|
*/
|
||||||
private void requestLogin(Player player) {
|
private void requestLogin(Player player) {
|
||||||
|
final String name = player.getName().toLowerCase();
|
||||||
Utils.teleportToSpawn(player);
|
Utils.teleportToSpawn(player);
|
||||||
LimboCache cache = LimboCache.getInstance();
|
LimboCache cache = LimboCache.getInstance();
|
||||||
cache.updateLimboPlayer(player);
|
cache.updateLimboPlayer(player);
|
||||||
@ -87,8 +86,8 @@ public class ProcessSyncPasswordRegister implements Process {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void processPasswordRegister(Player player) {
|
||||||
public void run() {
|
final String name = player.getName().toLowerCase();
|
||||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||||
if (limbo != null) {
|
if (limbo != null) {
|
||||||
if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN) && plugin.tablistHider != null) {
|
if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN) && plugin.tablistHider != null) {
|
||||||
@ -137,7 +136,7 @@ public class ProcessSyncPasswordRegister implements Process {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register is now finished; we can force all commands
|
// Register is now finished; we can force all commands
|
||||||
forceCommands();
|
forceCommands(player);
|
||||||
|
|
||||||
// Request login after registration
|
// Request login after registration
|
||||||
if (service.getProperty(RegistrationSettings.FORCE_LOGIN_AFTER_REGISTER)) {
|
if (service.getProperty(RegistrationSettings.FORCE_LOGIN_AFTER_REGISTER)) {
|
||||||
@ -146,13 +145,13 @@ public class ProcessSyncPasswordRegister implements Process {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (service.getProperty(HooksSettings.BUNGEECORD)) {
|
if (service.getProperty(HooksSettings.BUNGEECORD)) {
|
||||||
sendBungeeMessage();
|
sendBungeeMessage(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendTo();
|
sendTo(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendTo() {
|
private void sendTo(Player player) {
|
||||||
if (!service.getProperty(HooksSettings.BUNGEECORD_SERVER).isEmpty()) {
|
if (!service.getProperty(HooksSettings.BUNGEECORD_SERVER).isEmpty()) {
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
out.writeUTF("Connect");
|
out.writeUTF("Connect");
|
||||||
|
@ -8,7 +8,7 @@ import fr.xephi.authme.cache.limbo.LimboCache;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.process.NewProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
@ -27,7 +27,7 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
|
import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
|
||||||
|
|
||||||
public class AsynchronousUnregister implements NewProcess {
|
public class AsynchronousUnregister implements AsynchronousProcess {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AuthMe plugin;
|
private AuthMe plugin;
|
||||||
|
@ -5,8 +5,6 @@ import fr.xephi.authme.datasource.DataSource;
|
|||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.hooks.PluginHooks;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
|
||||||
import fr.xephi.authme.settings.NewSetting;
|
import fr.xephi.authme.settings.NewSetting;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
@ -40,8 +38,6 @@ public class ProcessServiceTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private Messages messages;
|
private Messages messages;
|
||||||
@Mock
|
@Mock
|
||||||
private PasswordSecurity passwordSecurity;
|
|
||||||
@Mock
|
|
||||||
private AuthMe authMe;
|
private AuthMe authMe;
|
||||||
@Mock
|
@Mock
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
@ -140,22 +136,6 @@ public class ProcessServiceTest {
|
|||||||
assertThat(result, equalTo(authMe));
|
assertThat(result, equalTo(authMe));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldComputeHash() {
|
|
||||||
// given
|
|
||||||
String password = "test123";
|
|
||||||
String username = "Username";
|
|
||||||
HashedPassword hashedPassword = new HashedPassword("hashedResult", "salt12342");
|
|
||||||
given(passwordSecurity.computeHash(password, username)).willReturn(hashedPassword);
|
|
||||||
|
|
||||||
// when
|
|
||||||
HashedPassword result = processService.computeHash(password, username);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result, equalTo(hashedPassword));
|
|
||||||
verify(passwordSecurity).computeHash(password, username);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldValidatePassword() {
|
public void shouldValidatePassword() {
|
||||||
// given
|
// given
|
||||||
|
Loading…
Reference in New Issue
Block a user