diff --git a/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java b/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java index 9bc57e20..cdbe0c00 100644 --- a/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java +++ b/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java @@ -85,6 +85,13 @@ public class PlayerAuth { return groupId; } + public void setQuitLocation(Location location) { + x = location.getBlockX(); + y = location.getBlockY(); + z = location.getBlockZ(); + world = location.getWorld().getName(); + } + public double getQuitLocX() { return x; } diff --git a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java index 6bdc6723..4f27f80b 100644 --- a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java +++ b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java @@ -5,7 +5,6 @@ import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.settings.NewSetting; import fr.xephi.authme.settings.SpawnLoader; import fr.xephi.authme.settings.properties.PluginSettings; -import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.util.StringUtils; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -84,9 +83,6 @@ public class LimboCache { player.setWalkSpeed(data.getWalkSpeed()); player.setFlySpeed(data.getFlySpeed()); restoreGroup(player, data.getGroup()); - if (!settings.getProperty(RestrictionSettings.NO_TELEPORT)) { - player.teleport(data.getLocation()); - } data.clearTasks(); } } diff --git a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java index 2d2f938c..0795ac16 100644 --- a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java @@ -3,7 +3,10 @@ package fr.xephi.authme.process.login; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; import fr.xephi.authme.AuthMe; +import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.limbo.LimboCache; +import fr.xephi.authme.cache.limbo.PlayerData; +import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.events.LoginEvent; import fr.xephi.authme.events.RestoreInventoryEvent; import fr.xephi.authme.listener.AuthMePlayerListener; @@ -12,6 +15,7 @@ import fr.xephi.authme.process.SynchronousProcess; import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.util.TeleportationService; import org.apache.commons.lang.reflect.MethodUtils; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; @@ -44,6 +48,12 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess { @Inject private PluginManager pluginManager; + @Inject + private TeleportationService teleportationService; + + @Inject + private DataSource dataSource; + ProcessSyncPlayerLogin() { } @@ -67,13 +77,15 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess { public void processPlayerLogin(Player player) { final String name = player.getName().toLowerCase(); + + final PlayerData limbo = limboCache.getPlayerData(name); // Limbo contains the State of the Player before /login - if (limboCache.hasPlayerData(name)) { + if (limbo != null) { limboCache.restoreData(player); limboCache.deletePlayerData(player); // do we really need to use location from database for now? // because LimboCache#restoreData teleport player to last location. - //teleportationService.teleportOnLogin(player, auth, limbo); + if (RESTORE_COLLISIONS && !service.getProperty(KEEP_COLLISIONS_DISABLED)) { player.setCollidable(true); } @@ -83,6 +95,9 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess { } } + final PlayerAuth auth = dataSource.getAuth(name); + teleportationService.teleportOnLogin(player, auth, limbo); + // We can now display the join message (if delayed) String jm = AuthMePlayerListener.joinMessage.get(name); if (jm != null) { diff --git a/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java b/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java index 209ec480..34a5b493 100644 --- a/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java +++ b/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java @@ -43,10 +43,7 @@ public class AsynchronousLogout implements AsynchronousProcess { PlayerAuth auth = playerCache.getAuth(name); database.updateSession(auth); if (service.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) { - auth.setQuitLocX(player.getLocation().getX()); - auth.setQuitLocY(player.getLocation().getY()); - auth.setQuitLocZ(player.getLocation().getZ()); - auth.setWorld(player.getWorld().getName()); + auth.setQuitLocation(player.getLocation()); database.updateQuitLoc(auth); } diff --git a/src/main/java/fr/xephi/authme/process/logout/ProcessSynchronousPlayerLogout.java b/src/main/java/fr/xephi/authme/process/logout/ProcessSynchronousPlayerLogout.java index 9db73b0d..9069577f 100644 --- a/src/main/java/fr/xephi/authme/process/logout/ProcessSynchronousPlayerLogout.java +++ b/src/main/java/fr/xephi/authme/process/logout/ProcessSynchronousPlayerLogout.java @@ -16,6 +16,7 @@ import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.task.PlayerDataTaskManager; import fr.xephi.authme.util.BukkitService; +import fr.xephi.authme.util.TeleportationService; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -45,6 +46,9 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess { @Inject private SessionManager sessionManager; + @Inject + private TeleportationService teleportationService; + ProcessSynchronousPlayerLogout() { } @@ -84,6 +88,7 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess { private void applyLogoutEffect(Player player) { // dismount player player.leaveVehicle(); + teleportationService.teleportOnJoin(player); // Apply Blindness effect final int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;