Move Bungee interactions to new service class

This commit is contained in:
Gnat008
2016-07-11 15:05:38 -04:00
parent 4f68589b76
commit 351431d1d8
5 changed files with 135 additions and 93 deletions
@@ -1,7 +1,5 @@
package fr.xephi.authme.process.changepassword;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
@@ -12,7 +10,7 @@ import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.service.BungeeService;
import fr.xephi.authme.util.BukkitService;
import org.bukkit.entity.Player;
@@ -23,6 +21,9 @@ public class AsyncChangePassword implements AsynchronousProcess {
@Inject
private AuthMe plugin;
@Inject
private BungeeService bungeeService;
@Inject
private DataSource dataSource;
@@ -56,21 +57,9 @@ public class AsyncChangePassword implements AsynchronousProcess {
playerCache.updatePlayer(auth);
processService.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS);
ConsoleLogger.info(player.getName() + " changed his password");
if (processService.getProperty(HooksSettings.BUNGEECORD)) {
final String hash = hashedPassword.getHash();
final String salt = hashedPassword.getSalt();
bukkitService.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Forward");
out.writeUTF("ALL");
out.writeUTF("AuthMe");
out.writeUTF("changepassword;" + name + ";" + hash + ";" + salt);
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}
});
}
// Send a Bungee message for the password change
bungeeService.sendPasswordChanged(player, hashedPassword);
} else {
processService.send(player, MessageKey.WRONG_PASSWORD);
}