mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-30 14:13: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.backup.PlayerDataStorage;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
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 fr.xephi.authme.process.SynchronousProcess;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -15,17 +13,12 @@ public class ProcessSyncronousPlayerQuit implements SynchronousProcess {
|
|||||||
@Inject
|
@Inject
|
||||||
private PlayerDataStorage playerDataStorage;
|
private PlayerDataStorage playerDataStorage;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ProcessService service;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private LimboCache limboCache;
|
private LimboCache limboCache;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private AuthGroupHandler authGroupHandler;
|
|
||||||
|
|
||||||
public void processSyncQuit(Player player) {
|
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);
|
limboCache.removeFromCache(player);
|
||||||
} else {
|
} else {
|
||||||
// Save player's data, so we could retrieve it later on player next join
|
// Save player's data, so we could retrieve it later on player next join
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package fr.xephi.authme.settings;
|
package fr.xephi.authme.settings;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.hooks.PluginHooks;
|
||||||
import fr.xephi.authme.initialization.DataFolder;
|
import fr.xephi.authme.initialization.DataFolder;
|
||||||
@ -34,7 +33,6 @@ public class SpawnLoader implements Reloadable {
|
|||||||
private final File authMeConfigurationFile;
|
private final File authMeConfigurationFile;
|
||||||
private final NewSetting settings;
|
private final NewSetting settings;
|
||||||
private final PluginHooks pluginHooks;
|
private final PluginHooks pluginHooks;
|
||||||
private final DataSource dataSource;
|
|
||||||
private FileConfiguration authMeConfiguration;
|
private FileConfiguration authMeConfiguration;
|
||||||
private String[] spawnPriority;
|
private String[] spawnPriority;
|
||||||
private Location essentialsSpawn;
|
private Location essentialsSpawn;
|
||||||
@ -48,7 +46,7 @@ public class SpawnLoader implements Reloadable {
|
|||||||
* @param dataSource The plugin auth database instance
|
* @param dataSource The plugin auth database instance
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public SpawnLoader(@DataFolder File pluginFolder, NewSetting settings, PluginHooks pluginHooks,
|
SpawnLoader(@DataFolder File pluginFolder, NewSetting settings, PluginHooks pluginHooks,
|
||||||
DataSource dataSource) {
|
DataSource dataSource) {
|
||||||
File spawnFile = new File(pluginFolder, "spawn.yml");
|
File spawnFile = new File(pluginFolder, "spawn.yml");
|
||||||
// TODO ljacqu 20160312: Check if resource could be copied and handle the case if not
|
// 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.authMeConfigurationFile = new File(pluginFolder, "spawn.yml");
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.pluginHooks = pluginHooks;
|
this.pluginHooks = pluginHooks;
|
||||||
this.dataSource = dataSource;
|
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,15 +167,7 @@ public class SpawnLoader implements Reloadable {
|
|||||||
spawnLoc = essentialsSpawn;
|
spawnLoc = essentialsSpawn;
|
||||||
break;
|
break;
|
||||||
case "authme":
|
case "authme":
|
||||||
String playerNameLower = player.getName().toLowerCase();
|
|
||||||
if (PlayerCache.getInstance().isAuthenticated(playerNameLower)) {
|
|
||||||
spawnLoc = getSpawn();
|
spawnLoc = getSpawn();
|
||||||
} else if (getFirstSpawn() != null && (!player.hasPlayedBefore() ||
|
|
||||||
!dataSource.isAuthAvailable(playerNameLower))) {
|
|
||||||
spawnLoc = getFirstSpawn();
|
|
||||||
} else {
|
|
||||||
spawnLoc = getSpawn();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (spawnLoc != null) {
|
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.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.limbo.PlayerData;
|
import fr.xephi.authme.cache.limbo.PlayerData;
|
||||||
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.events.AbstractTeleportEvent;
|
import fr.xephi.authme.events.AbstractTeleportEvent;
|
||||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||||
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
||||||
@ -39,6 +40,9 @@ public class TeleportationService implements Reloadable {
|
|||||||
@Inject
|
@Inject
|
||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private DataSource dataSource;
|
||||||
|
|
||||||
private Set<String> spawnOnLoginWorlds;
|
private Set<String> spawnOnLoginWorlds;
|
||||||
|
|
||||||
TeleportationService() {
|
TeleportationService() {
|
||||||
@ -78,16 +82,19 @@ public class TeleportationService implements Reloadable {
|
|||||||
* @param player the player to process
|
* @param player the player to process
|
||||||
*/
|
*/
|
||||||
public void teleportNewPlayerToFirstSpawn(final Player player) {
|
public void teleportNewPlayerToFirstSpawn(final Player player) {
|
||||||
if (settings.getProperty(RestrictionSettings.NO_TELEPORT) || player.hasPlayedBefore()) {
|
if (settings.getProperty(RestrictionSettings.NO_TELEPORT)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location firstSpawn = spawnLoader.getFirstSpawn();
|
Location firstSpawn = spawnLoader.getFirstSpawn();
|
||||||
if (firstSpawn == null) {
|
if (firstSpawn == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!player.hasPlayedBefore() || !dataSource.isAuthAvailable(player.getName())) {
|
||||||
performTeleportation(player, new FirstSpawnTeleportEvent(player, firstSpawn));
|
performTeleportation(player, new FirstSpawnTeleportEvent(player, firstSpawn));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Teleports the player according to the settings after having successfully logged in.
|
* Teleports the player according to the settings after having successfully logged in.
|
||||||
|
Loading…
Reference in New Issue
Block a user