Fix player always teleport to spawn on join.
This commit is contained in:
@@ -8,8 +8,7 @@ import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.process.ProcessService;
|
||||
import fr.xephi.authme.process.SyncProcessManager;
|
||||
import fr.xephi.authme.util.BukkitService;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -31,10 +30,8 @@ public class AsynchronousLogout implements AsynchronousProcess {
|
||||
@Inject
|
||||
private SyncProcessManager syncProcessManager;
|
||||
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
|
||||
AsynchronousLogout() { }
|
||||
AsynchronousLogout() {
|
||||
}
|
||||
|
||||
public void logout(final Player player) {
|
||||
final String name = player.getName().toLowerCase();
|
||||
@@ -42,23 +39,20 @@ public class AsynchronousLogout implements AsynchronousProcess {
|
||||
service.send(player, MessageKey.NOT_LOGGED_IN);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerAuth auth = playerCache.getAuth(name);
|
||||
database.updateSession(auth);
|
||||
auth.setQuitLocX(player.getLocation().getX());
|
||||
auth.setQuitLocY(player.getLocation().getY());
|
||||
auth.setQuitLocZ(player.getLocation().getZ());
|
||||
auth.setWorld(player.getWorld().getName());
|
||||
database.updateQuitLoc(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());
|
||||
database.updateQuitLoc(auth);
|
||||
}
|
||||
|
||||
limboCache.updateLimboPlayer(player);
|
||||
playerCache.removePlayer(name);
|
||||
database.setUnlogged(name);
|
||||
bukkitService.scheduleSyncDelayedTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utils.teleportToSpawn(player);
|
||||
}
|
||||
});
|
||||
limboCache.updateLimboPlayer(player);
|
||||
syncProcessManager.processSyncPlayerLogout(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,22 +69,7 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
|
||||
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||
limboPlayerTaskManager.registerMessageTask(name, true);
|
||||
|
||||
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
||||
player.getVehicle().eject();
|
||||
}
|
||||
final int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
|
||||
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
|
||||
}
|
||||
|
||||
service.setGroup(player, AuthGroupType.NOT_LOGGED_IN);
|
||||
player.setOp(false);
|
||||
// Remove speed
|
||||
if (!service.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT)
|
||||
&& service.getProperty(RestrictionSettings.REMOVE_SPEED)) {
|
||||
player.setFlySpeed(0.0f);
|
||||
player.setWalkSpeed(0.0f);
|
||||
}
|
||||
applyLogoutEffect(player);
|
||||
|
||||
// Player is now logout... Time to fire event !
|
||||
bukkitService.callEvent(new LogoutEvent(player));
|
||||
@@ -95,4 +80,28 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
|
||||
ConsoleLogger.info(player.getName() + " logged out");
|
||||
}
|
||||
|
||||
private void applyLogoutEffect(Player player) {
|
||||
// dismount player
|
||||
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
||||
player.getVehicle().eject();
|
||||
}
|
||||
|
||||
// Apply Blindness effect
|
||||
final int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
|
||||
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
|
||||
}
|
||||
|
||||
// Set player's data to unauthenticated
|
||||
service.setGroup(player, AuthGroupType.NOT_LOGGED_IN);
|
||||
player.setOp(false);
|
||||
player.setAllowFlight(false);
|
||||
// Remove speed
|
||||
if (!service.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT)
|
||||
&& service.getProperty(RestrictionSettings.REMOVE_SPEED)) {
|
||||
player.setFlySpeed(0.0f);
|
||||
player.setWalkSpeed(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user