- Add restore method in LimboCache
* Apply it to process that have use of it - Fix fly & walk speed not get restored
This commit is contained in:
@@ -2,12 +2,8 @@ package fr.xephi.authme.process.quit;
|
||||
|
||||
import fr.xephi.authme.cache.backup.PlayerDataStorage;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.PlayerData;
|
||||
import fr.xephi.authme.process.ProcessService;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -25,27 +21,12 @@ public class ProcessSyncronousPlayerQuit implements SynchronousProcess {
|
||||
private LimboCache limboCache;
|
||||
|
||||
public void processSyncQuit(Player player) {
|
||||
PlayerData limbo = limboCache.getPlayerData(player.getName().toLowerCase());
|
||||
if (limbo != null) { // it mean player is not authenticated
|
||||
// Only delete if we don't need player's last location
|
||||
if (service.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)) {
|
||||
limboCache.removePlayerData(player);
|
||||
} else {
|
||||
// Restore data if its about to delete PlayerData
|
||||
if (!StringUtils.isEmpty(limbo.getGroup())) {
|
||||
Utils.addNormal(player, limbo.getGroup());
|
||||
}
|
||||
player.setOp(limbo.isOperator());
|
||||
player.setAllowFlight(limbo.isCanFly());
|
||||
player.setWalkSpeed(limbo.getWalkSpeed());
|
||||
limboCache.deletePlayerData(player);
|
||||
}
|
||||
if (limboCache.hasPlayerData(player.getName().toLowerCase())) { // it mean player is not authenticated
|
||||
limboCache.removeFromCache(player);
|
||||
} else {
|
||||
// Write player's location, so we could retrieve it later on player next join
|
||||
if (service.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)) {
|
||||
if (!playerDataStorage.hasData(player)) {
|
||||
playerDataStorage.saveData(player);
|
||||
}
|
||||
// Save player's data, so we could retrieve it later on player next join
|
||||
if (!playerDataStorage.hasData(player)) {
|
||||
playerDataStorage.saveData(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user