#838 Fix force spawn on join setting

- Add call to teleport service after login and logout
This commit is contained in:
ljacqu 2016-07-10 13:04:35 +02:00
parent 491853e0c8
commit c9c4e69e1b
5 changed files with 30 additions and 10 deletions

View File

@ -85,6 +85,13 @@ public class PlayerAuth {
return groupId; return groupId;
} }
public void setQuitLocation(Location location) {
x = location.getBlockX();
y = location.getBlockY();
z = location.getBlockZ();
world = location.getWorld().getName();
}
public double getQuitLocX() { public double getQuitLocX() {
return x; return x;
} }

View File

@ -5,7 +5,6 @@ import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.NewSetting; import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.SpawnLoader; import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.StringUtils; import fr.xephi.authme.util.StringUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -84,9 +83,6 @@ public class LimboCache {
player.setWalkSpeed(data.getWalkSpeed()); player.setWalkSpeed(data.getWalkSpeed());
player.setFlySpeed(data.getFlySpeed()); player.setFlySpeed(data.getFlySpeed());
restoreGroup(player, data.getGroup()); restoreGroup(player, data.getGroup());
if (!settings.getProperty(RestrictionSettings.NO_TELEPORT)) {
player.teleport(data.getLocation());
}
data.clearTasks(); data.clearTasks();
} }
} }

View File

@ -3,7 +3,10 @@ package fr.xephi.authme.process.login;
import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import fr.xephi.authme.AuthMe; 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.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.LoginEvent;
import fr.xephi.authme.events.RestoreInventoryEvent; import fr.xephi.authme.events.RestoreInventoryEvent;
import fr.xephi.authme.listener.AuthMePlayerListener; 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.HooksSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.util.BukkitService; import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.TeleportationService;
import org.apache.commons.lang.reflect.MethodUtils; import org.apache.commons.lang.reflect.MethodUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -44,6 +48,12 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
@Inject @Inject
private PluginManager pluginManager; private PluginManager pluginManager;
@Inject
private TeleportationService teleportationService;
@Inject
private DataSource dataSource;
ProcessSyncPlayerLogin() { ProcessSyncPlayerLogin() {
} }
@ -67,13 +77,15 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
public void processPlayerLogin(Player player) { public void processPlayerLogin(Player player) {
final String name = player.getName().toLowerCase(); final String name = player.getName().toLowerCase();
final PlayerData limbo = limboCache.getPlayerData(name);
// Limbo contains the State of the Player before /login // Limbo contains the State of the Player before /login
if (limboCache.hasPlayerData(name)) { if (limbo != null) {
limboCache.restoreData(player); limboCache.restoreData(player);
limboCache.deletePlayerData(player); limboCache.deletePlayerData(player);
// do we really need to use location from database for now? // do we really need to use location from database for now?
// because LimboCache#restoreData teleport player to last location. // because LimboCache#restoreData teleport player to last location.
//teleportationService.teleportOnLogin(player, auth, limbo);
if (RESTORE_COLLISIONS && !service.getProperty(KEEP_COLLISIONS_DISABLED)) { if (RESTORE_COLLISIONS && !service.getProperty(KEEP_COLLISIONS_DISABLED)) {
player.setCollidable(true); 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) // We can now display the join message (if delayed)
String jm = AuthMePlayerListener.joinMessage.get(name); String jm = AuthMePlayerListener.joinMessage.get(name);
if (jm != null) { if (jm != null) {

View File

@ -43,10 +43,7 @@ public class AsynchronousLogout implements AsynchronousProcess {
PlayerAuth auth = playerCache.getAuth(name); PlayerAuth auth = playerCache.getAuth(name);
database.updateSession(auth); database.updateSession(auth);
if (service.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) { if (service.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
auth.setQuitLocX(player.getLocation().getX()); auth.setQuitLocation(player.getLocation());
auth.setQuitLocY(player.getLocation().getY());
auth.setQuitLocZ(player.getLocation().getZ());
auth.setWorld(player.getWorld().getName());
database.updateQuitLoc(auth); database.updateQuitLoc(auth);
} }

View File

@ -16,6 +16,7 @@ import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.PlayerDataTaskManager; import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.util.BukkitService; import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.TeleportationService;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@ -45,6 +46,9 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
@Inject @Inject
private SessionManager sessionManager; private SessionManager sessionManager;
@Inject
private TeleportationService teleportationService;
ProcessSynchronousPlayerLogout() { ProcessSynchronousPlayerLogout() {
} }
@ -84,6 +88,7 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
private void applyLogoutEffect(Player player) { private void applyLogoutEffect(Player player) {
// dismount player // dismount player
player.leaveVehicle(); player.leaveVehicle();
teleportationService.teleportOnJoin(player);
// Apply Blindness effect // Apply Blindness effect
final int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND; final int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;