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

View File

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

View File

@ -62,15 +62,6 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
ProcessSyncPlayerLogin() { } 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) { private void restoreInventory(Player player) {
RestoreInventoryEvent event = new RestoreInventoryEvent(player); RestoreInventoryEvent event = new RestoreInventoryEvent(player);
pluginManager.callEvent(event); pluginManager.callEvent(event);
@ -102,8 +93,13 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
service.setGroup(player, AuthGroupType.LOGGED_IN); service.setGroup(player, AuthGroupType.LOGGED_IN);
// Restore can-fly state // Restore can-fly state
player.setAllowFlight(limbo.isCanFly()); 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); teleportationService.teleportOnLogin(player, auth, limbo);
@ -136,7 +132,6 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
AuthMePlayerListener.joinMessage.remove(name); AuthMePlayerListener.joinMessage.remove(name);
} }
restoreSpeedEffects(player);
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) { if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
player.removePotionEffect(PotionEffectType.BLINDNESS); 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.cache.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.AsynchronousProcess; import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.process.ProcessService; import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SyncProcessManager; import fr.xephi.authme.process.SyncProcessManager;
@ -59,11 +58,7 @@ public class AsynchronousLogout implements AsynchronousProcess {
Utils.teleportToSpawn(player); Utils.teleportToSpawn(player);
} }
}); });
if (limboCache.hasLimboPlayer(name)) { limboCache.updateLimboPlayer(player);
limboCache.deleteLimboPlayer(player);
}
limboCache.addLimboPlayer(player);
service.setGroup(player, AuthGroupType.NOT_LOGGED_IN);
syncProcessManager.processSyncPlayerLogout(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.events.LogoutEvent;
import fr.xephi.authme.listener.protocollib.ProtocolLibService; import fr.xephi.authme.listener.protocollib.ProtocolLibService;
import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.ProcessService; import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SynchronousProcess; import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.HooksSettings;
@ -56,14 +57,6 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray()); 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) { public void processSyncLogout(Player player) {
final String name = player.getName().toLowerCase(); final String name = player.getName().toLowerCase();
if (sessionManager.hasSession(name)) { if (sessionManager.hasSession(name)) {
@ -83,8 +76,16 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) { if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2)); player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
} }
service.setGroup(player, AuthGroupType.NOT_LOGGED_IN);
player.setOp(false); 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 ! // Player is now logout... Time to fire event !
bukkitService.callEvent(new LogoutEvent(player)); bukkitService.callEvent(new LogoutEvent(player));
if (service.getProperty(HooksSettings.BUNGEECORD)) { if (service.getProperty(HooksSettings.BUNGEECORD)) {