#1218 Add onLogout to commands.yml
This commit is contained in:
@@ -18,6 +18,9 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Async process called when a player quits the server.
|
||||
*/
|
||||
public class AsynchronousQuit implements AsynchronousProcess {
|
||||
|
||||
@Inject
|
||||
@@ -47,14 +50,19 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
||||
AsynchronousQuit() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Processes that the given player has quit the server.
|
||||
*
|
||||
* @param player the player who left
|
||||
*/
|
||||
public void processQuit(Player player) {
|
||||
if (player == null || validationService.isUnrestricted(player.getName())) {
|
||||
return;
|
||||
}
|
||||
final String name = player.getName().toLowerCase();
|
||||
final boolean wasLoggedIn = playerCache.isAuthenticated(name);
|
||||
|
||||
if (playerCache.isAuthenticated(name)) {
|
||||
if (wasLoggedIn) {
|
||||
if (service.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
|
||||
Location loc = spawnLoader.getPlayerLocationOrSpawn(player);
|
||||
PlayerAuth auth = PlayerAuth.builder()
|
||||
@@ -82,7 +90,7 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
||||
database.setUnlogged(name);
|
||||
|
||||
if (plugin.isEnabled()) {
|
||||
syncProcessManager.processSyncPlayerQuit(player);
|
||||
syncProcessManager.processSyncPlayerQuit(player, wasLoggedIn);
|
||||
}
|
||||
// remove player from cache
|
||||
if (database instanceof CacheDataSource) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package fr.xephi.authme.process.quit;
|
||||
|
||||
import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
import fr.xephi.authme.settings.commandconfig.CommandManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
||||
public class ProcessSyncPlayerQuit implements SynchronousProcess {
|
||||
|
||||
@Inject
|
||||
private LimboService limboService;
|
||||
|
||||
@Inject
|
||||
private CommandManager commandManager;
|
||||
|
||||
/**
|
||||
* Processes a player having quit.
|
||||
*
|
||||
* @param player the player that left
|
||||
* @param wasLoggedIn true if the player was logged in when leaving, false otherwise
|
||||
*/
|
||||
public void processSyncQuit(Player player, boolean wasLoggedIn) {
|
||||
if (wasLoggedIn) {
|
||||
commandManager.runCommandsOnLogout(player);
|
||||
} else {
|
||||
limboService.restoreData(player);
|
||||
}
|
||||
player.leaveVehicle();
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package fr.xephi.authme.process.quit;
|
||||
|
||||
import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
||||
public class ProcessSyncronousPlayerQuit implements SynchronousProcess {
|
||||
|
||||
@Inject
|
||||
private LimboService limboService;
|
||||
|
||||
public void processSyncQuit(Player player) {
|
||||
limboService.restoreData(player);
|
||||
player.leaveVehicle();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user