mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-24 17:47:38 +01:00
#838 Fix force spawn on join setting
- Add call to teleport service after login and logout
This commit is contained in:
parent
491853e0c8
commit
c9c4e69e1b
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user