Fix registered players being teleported to first spawn, fix player losing his speed

This commit is contained in:
ljacqu 2016-07-04 21:38:23 +02:00
parent 2867ebaddd
commit ea6603a6dc
3 changed files with 14 additions and 25 deletions

View File

@ -2,8 +2,6 @@ package fr.xephi.authme.process.quit;
import fr.xephi.authme.cache.backup.PlayerDataStorage;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.permission.AuthGroupHandler;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SynchronousProcess;
import org.bukkit.entity.Player;
@ -15,17 +13,12 @@ public class ProcessSyncronousPlayerQuit implements SynchronousProcess {
@Inject
private PlayerDataStorage playerDataStorage;
@Inject
private ProcessService service;
@Inject
private LimboCache limboCache;
@Inject
private AuthGroupHandler authGroupHandler;
public void processSyncQuit(Player player) {
if (limboCache.hasPlayerData(player.getName().toLowerCase())) { // it mean player is not authenticated
if (limboCache.hasPlayerData(player.getName())) { // it mean player is not authenticated
limboCache.restoreData(player);
limboCache.removeFromCache(player);
} else {
// Save player's data, so we could retrieve it later on player next join

View File

@ -1,7 +1,6 @@
package fr.xephi.authme.settings;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.hooks.PluginHooks;
import fr.xephi.authme.initialization.DataFolder;
@ -34,7 +33,6 @@ public class SpawnLoader implements Reloadable {
private final File authMeConfigurationFile;
private final NewSetting settings;
private final PluginHooks pluginHooks;
private final DataSource dataSource;
private FileConfiguration authMeConfiguration;
private String[] spawnPriority;
private Location essentialsSpawn;
@ -48,7 +46,7 @@ public class SpawnLoader implements Reloadable {
* @param dataSource The plugin auth database instance
*/
@Inject
public SpawnLoader(@DataFolder File pluginFolder, NewSetting settings, PluginHooks pluginHooks,
SpawnLoader(@DataFolder File pluginFolder, NewSetting settings, PluginHooks pluginHooks,
DataSource dataSource) {
File spawnFile = new File(pluginFolder, "spawn.yml");
// TODO ljacqu 20160312: Check if resource could be copied and handle the case if not
@ -56,7 +54,6 @@ public class SpawnLoader implements Reloadable {
this.authMeConfigurationFile = new File(pluginFolder, "spawn.yml");
this.settings = settings;
this.pluginHooks = pluginHooks;
this.dataSource = dataSource;
reload();
}
@ -170,15 +167,7 @@ public class SpawnLoader implements Reloadable {
spawnLoc = essentialsSpawn;
break;
case "authme":
String playerNameLower = player.getName().toLowerCase();
if (PlayerCache.getInstance().isAuthenticated(playerNameLower)) {
spawnLoc = getSpawn();
} else if (getFirstSpawn() != null && (!player.hasPlayedBefore() ||
!dataSource.isAuthAvailable(playerNameLower))) {
spawnLoc = getFirstSpawn();
} else {
spawnLoc = getSpawn();
}
break;
}
if (spawnLoc != null) {

View File

@ -3,6 +3,7 @@ package fr.xephi.authme.util;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.PlayerData;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.AbstractTeleportEvent;
import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
@ -39,6 +40,9 @@ public class TeleportationService implements Reloadable {
@Inject
private PlayerCache playerCache;
@Inject
private DataSource dataSource;
private Set<String> spawnOnLoginWorlds;
TeleportationService() {
@ -78,16 +82,19 @@ public class TeleportationService implements Reloadable {
* @param player the player to process
*/
public void teleportNewPlayerToFirstSpawn(final Player player) {
if (settings.getProperty(RestrictionSettings.NO_TELEPORT) || player.hasPlayedBefore()) {
if (settings.getProperty(RestrictionSettings.NO_TELEPORT)) {
return;
}
Location firstSpawn = spawnLoader.getFirstSpawn();
if (firstSpawn == null) {
return;
}
if (!player.hasPlayedBefore() || !dataSource.isAuthAvailable(player.getName())) {
performTeleportation(player, new FirstSpawnTeleportEvent(player, firstSpawn));
}
}
/**
* Teleports the player according to the settings after having successfully logged in.