Fix a couple race conditions (Fixes #698 and #697)

This commit is contained in:
games647 2016-05-08 20:44:18 +02:00
parent 23da023d53
commit ee08087871
3 changed files with 12 additions and 5 deletions

View File

@ -83,9 +83,9 @@ public class LimboCache {
public void deleteLimboPlayer(String name) {
checkNotNull(name);
name = name.toLowerCase();
if (cache.containsKey(name)) {
LimboPlayer cachedPlayer = cache.remove(name);
if (cachedPlayer != null) {
cache.get(name).clearTasks();
cache.remove(name);
}
}

View File

@ -175,7 +175,7 @@ public class AuthMePlayerListener implements Listener {
return;
}
/*
/*
* Limit player X and Z movements to 1 block
* Deny player Y+ movements (allows falling)
*/

View File

@ -5,6 +5,7 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
import fr.xephi.authme.events.ProtectInventoryEvent;
@ -208,7 +209,10 @@ public class AsynchronousJoin implements Process {
int msgInterval = service.getProperty(RegistrationSettings.MESSAGE_INTERVAL);
if (registrationTimeout > 0) {
BukkitTask id = service.runTaskLater(new TimeoutTask(plugin, name, player), registrationTimeout);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTask(id);
LimboPlayer limboPlayer = LimboCache.getInstance().getLimboPlayer(name);
if (limboPlayer != null) {
limboPlayer.setTimeoutTask(id);
}
}
MessageKey msg;
@ -222,7 +226,10 @@ public class AsynchronousJoin implements Process {
if (msgInterval > 0 && LimboCache.getInstance().getLimboPlayer(name) != null) {
BukkitTask msgTask = service.runTask(new MessageTask(service.getBukkitService(), plugin.getMessages(),
name, msg, msgInterval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTask(msgTask);
LimboPlayer limboPlayer = LimboCache.getInstance().getLimboPlayer(name);
if (limboPlayer != null) {
limboPlayer.setMessageTask(msgTask);
}
}
}