- Fix fly speed not get restored after login.

- Attempt to fix #592
This commit is contained in:
DNx5 2016-06-29 00:34:31 +07:00
parent 145747505f
commit 45d8e24350
5 changed files with 53 additions and 47 deletions

View File

@ -293,16 +293,16 @@ public class AuthMe extends JavaPlugin {
// Some statically injected things
initializer.register(PlayerCache.class, PlayerCache.getInstance());
messages = initializer.get(Messages.class);
permsMan = initializer.get(PermissionsManager.class);
bukkitService = initializer.get(BukkitService.class);
pluginHooks = initializer.get(PluginHooks.class);
messages = initializer.get(Messages.class);
permsMan = initializer.get(PermissionsManager.class);
bukkitService = initializer.get(BukkitService.class);
pluginHooks = initializer.get(PluginHooks.class);
passwordSecurity = initializer.get(PasswordSecurity.class);
spawnLoader = initializer.get(SpawnLoader.class);
commandHandler = initializer.get(CommandHandler.class);
api = initializer.get(NewAPI.class);
management = initializer.get(Management.class);
geoLiteApi = initializer.get(GeoLiteAPI.class);
spawnLoader = initializer.get(SpawnLoader.class);
commandHandler = initializer.get(CommandHandler.class);
api = initializer.get(NewAPI.class);
management = initializer.get(Management.class);
geoLiteApi = initializer.get(GeoLiteAPI.class);
initializer.get(API.class);
}
@ -341,7 +341,7 @@ public class AuthMe extends JavaPlugin {
// Register event listeners
pluginManager.registerEvents(initializer.get(AuthMePlayerListener.class), this);
pluginManager.registerEvents(initializer.get(AuthMeBlockListener.class), this);
pluginManager.registerEvents(initializer.get(AuthMeBlockListener.class), this);
pluginManager.registerEvents(initializer.get(AuthMeEntityListener.class), this);
pluginManager.registerEvents(initializer.get(AuthMeServerListener.class), this);
@ -568,16 +568,9 @@ public class AuthMe extends JavaPlugin {
return;
}
String name = player.getName().toLowerCase();
if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead() && Settings.isSaveQuitLocationEnabled) {
final PlayerAuth auth = PlayerAuth.builder()
.name(player.getName().toLowerCase())
.realName(player.getName())
.location(player.getLocation()).build();
database.updateQuitLoc(auth);
}
if (limboCache.hasLimboPlayer(name)) {
LimboPlayer limbo = limboCache.getLimboPlayer(name);
if (!Settings.noTeleport) {
if (!newSettings.getProperty(RestrictionSettings.NO_TELEPORT)) {
player.teleport(limbo.getLoc());
}
Utils.addNormal(player, limbo.getGroup());
@ -587,6 +580,21 @@ public class AuthMe extends JavaPlugin {
limbo.clearTasks();
limboCache.deleteLimboPlayer(player);
}
if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) {
if (Settings.isSaveQuitLocationEnabled) {
final PlayerAuth auth = PlayerAuth.builder()
.name(player.getName().toLowerCase())
.realName(player.getName())
.location(player.getLocation()).build();
database.updateQuitLoc(auth);
}
if (newSettings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)
&& !newSettings.getProperty(RestrictionSettings.NO_TELEPORT)) {
limboCache.getJsonCache().writeCache(player);
player.teleport(spawnLoader.getSpawnLocation(player));
}
}
PlayerCache.getInstance().removePlayer(name);
}
@ -638,7 +646,6 @@ public class AuthMe extends JavaPlugin {
}
/**
* Handle Bukkit commands.
*
@ -678,6 +685,7 @@ public class AuthMe extends JavaPlugin {
/**
* @return permission manager
*
* @deprecated should be used in API classes only (temporarily)
*/
@Deprecated
@ -687,6 +695,7 @@ public class AuthMe extends JavaPlugin {
/**
* @return process manager
*
* @deprecated should be used in API classes only (temporarily)
*/
@Deprecated
@ -696,6 +705,7 @@ public class AuthMe extends JavaPlugin {
/**
* @return the datasource
*
* @deprecated should be used in API classes only (temporarily)
*/
@Deprecated
@ -705,6 +715,7 @@ public class AuthMe extends JavaPlugin {
/**
* @return password manager
*
* @deprecated should be used in API classes only (temporarily)
*/
@Deprecated
@ -714,6 +725,7 @@ public class AuthMe extends JavaPlugin {
/**
* @return plugin hooks
*
* @deprecated should be used in API classes only (temporarily)
*/
@Deprecated

View File

@ -30,6 +30,10 @@ public class LimboCache {
this.spawnLoader = spawnLoader;
}
public JsonCache getJsonCache() {
return jsonCache;
}
/**
* Add a limbo player.
*
@ -110,5 +114,4 @@ public class LimboCache {
deleteLimboPlayer(player);
addLimboPlayer(player);
}
}

View File

@ -62,15 +62,6 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
ProcessSyncPlayerLogin() { }
private void restoreSpeedEffects(Player player) {
if (!service.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT)
&& service.getProperty(RestrictionSettings.REMOVE_SPEED)) {
player.setWalkSpeed(0.2F);
player.setFlySpeed(0.1F);
}
}
private void restoreInventory(Player player) {
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
pluginManager.callEvent(event);
@ -102,8 +93,13 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
service.setGroup(player, AuthGroupType.LOGGED_IN);
// Restore can-fly state
player.setAllowFlight(limbo.isCanFly());
// Restore walk speed
player.setWalkSpeed(limbo.getWalkSpeed());
// Restore speed
if (!service.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT)
&& service.getProperty(RestrictionSettings.REMOVE_SPEED)) {
player.setWalkSpeed(limbo.getWalkSpeed());
player.setFlySpeed(0.2F);
}
teleportationService.teleportOnLogin(player, auth, limbo);
@ -136,7 +132,6 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
AuthMePlayerListener.joinMessage.remove(name);
}
restoreSpeedEffects(player);
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
player.removePotionEffect(PotionEffectType.BLINDNESS);
}

View File

@ -5,7 +5,6 @@ import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SyncProcessManager;
@ -59,11 +58,7 @@ public class AsynchronousLogout implements AsynchronousProcess {
Utils.teleportToSpawn(player);
}
});
if (limboCache.hasLimboPlayer(name)) {
limboCache.deleteLimboPlayer(player);
}
limboCache.addLimboPlayer(player);
service.setGroup(player, AuthGroupType.NOT_LOGGED_IN);
limboCache.updateLimboPlayer(player);
syncProcessManager.processSyncPlayerLogout(player);
}
}

View File

@ -8,6 +8,7 @@ import fr.xephi.authme.cache.SessionManager;
import fr.xephi.authme.events.LogoutEvent;
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.settings.properties.HooksSettings;
@ -56,14 +57,6 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}
private void restoreSpeedEffect(Player player) {
if (!service.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT)
&& service.getProperty(RestrictionSettings.REMOVE_SPEED)) {
player.setFlySpeed(0.0f);
player.setWalkSpeed(0.0f);
}
}
public void processSyncLogout(Player player) {
final String name = player.getName().toLowerCase();
if (sessionManager.hasSession(name)) {
@ -83,8 +76,16 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
}
service.setGroup(player, AuthGroupType.NOT_LOGGED_IN);
player.setOp(false);
restoreSpeedEffect(player);
// Remove speed
if (!service.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT)
&& service.getProperty(RestrictionSettings.REMOVE_SPEED)) {
player.setFlySpeed(0.0f);
player.setWalkSpeed(0.0f);
}
// Player is now logout... Time to fire event !
bukkitService.callEvent(new LogoutEvent(player));
if (service.getProperty(HooksSettings.BUNGEECORD)) {