Fix npe after register.

This commit is contained in:
DNx5
2015-12-01 01:29:56 +07:00
parent 4af4d424ee
commit 029214c080
4 changed files with 55 additions and 30 deletions
+7 -3
View File
@@ -117,7 +117,10 @@ public class LimboCache {
* @param name String
*/
public void deleteLimboPlayer(String name) {
cache.remove(name);
if(cache.containsKey(name)) {
cache.get(name).clearTask();
cache.remove(name);
}
}
/**
@@ -148,8 +151,9 @@ public class LimboCache {
* @param player Player
*/
public void updateLimboPlayer(Player player) {
if (this.hasLimboPlayer(player.getName().toLowerCase())) {
this.deleteLimboPlayer(player.getName().toLowerCase());
String name = player.getName().toLowerCase();
if (hasLimboPlayer(name)) {
deleteLimboPlayer(name);
}
addLimboPlayer(player);
}
+19 -2
View File
@@ -108,8 +108,9 @@ public class LimboPlayer {
* @param i BukkitTask
*/
public void setTimeoutTaskId(BukkitTask i) {
if (this.timeoutTaskId != null)
if (this.timeoutTaskId != null) {
this.timeoutTaskId.cancel();
}
this.timeoutTaskId = i;
}
@@ -128,11 +129,27 @@ public class LimboPlayer {
* @param messageTaskId BukkitTask
*/
public void setMessageTaskId(BukkitTask messageTaskId) {
if (this.messageTaskId != null)
if (this.messageTaskId != null) {
this.messageTaskId.cancel();
}
this.messageTaskId = messageTaskId;
}
/**
* Method clearTask.
*
*/
public void clearTask() {
if (messageTaskId != null) {
messageTaskId.cancel();
}
messageTaskId = null;
if (timeoutTaskId != null) {
timeoutTaskId.cancel();
}
timeoutTaskId = null;
}
/**
* Method isFlying.
*