mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-24 01:27:35 +01:00
Fix registered players being teleported to first spawn, fix player losing his speed
This commit is contained in:
parent
2867ebaddd
commit
ea6603a6dc
@ -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
|
||||
|
@ -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,15 +46,14 @@ public class SpawnLoader implements Reloadable {
|
||||
* @param dataSource The plugin auth database instance
|
||||
*/
|
||||
@Inject
|
||||
public SpawnLoader(@DataFolder File pluginFolder, NewSetting settings, PluginHooks pluginHooks,
|
||||
DataSource dataSource) {
|
||||
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
|
||||
FileUtils.copyFileFromResource(spawnFile, "spawn.yml");
|
||||
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();
|
||||
}
|
||||
spawnLoc = getSpawn();
|
||||
break;
|
||||
}
|
||||
if (spawnLoc != null) {
|
||||
|
@ -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,15 +82,18 @@ 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;
|
||||
}
|
||||
|
||||
performTeleportation(player, new FirstSpawnTeleportEvent(player, firstSpawn));
|
||||
if (!player.hasPlayedBefore() || !dataSource.isAuthAvailable(player.getName())) {
|
||||
performTeleportation(player, new FirstSpawnTeleportEvent(player, firstSpawn));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user