Potential NPE

This commit is contained in:
Xephi59 2015-08-20 18:39:40 +02:00
parent 3f85a1e5c2
commit 9d950b9b4a

View File

@ -21,7 +21,7 @@ public class AsyncronousQuit {
protected AuthMe plugin; protected AuthMe plugin;
protected DataSource database; protected DataSource database;
protected Player p; protected Player player;
protected Utils utils = Utils.getInstance(); protected Utils utils = Utils.getInstance();
private String name; private String name;
private ItemStack[] armor = null; private ItemStack[] armor = null;
@ -33,7 +33,7 @@ public class AsyncronousQuit {
public AsyncronousQuit(Player p, AuthMe plugin, DataSource database, public AsyncronousQuit(Player p, AuthMe plugin, DataSource database,
boolean isKick) { boolean isKick) {
this.p = p; this.player = p;
this.plugin = plugin; this.plugin = plugin;
this.database = database; this.database = database;
this.name = p.getName().toLowerCase(); this.name = p.getName().toLowerCase();
@ -41,7 +41,8 @@ public class AsyncronousQuit {
} }
public void process() { public void process() {
final Player player = p; if (player == null)
return;
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) { if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return; return;
} }
@ -64,7 +65,8 @@ public class AsyncronousQuit {
inv = limbo.getInventory(); inv = limbo.getInventory();
armor = limbo.getArmour(); armor = limbo.getArmour();
} }
utils.addNormal(player, limbo.getGroup()); if (limbo.getGroup() != null && !limbo.getGroup().equals(""))
utils.addNormal(player, limbo.getGroup());
needToChange = true; needToChange = true;
isOp = limbo.getOperator(); isOp = limbo.getOperator();
isFlying = limbo.isFlying(); isFlying = limbo.isFlying();
@ -94,6 +96,7 @@ public class AsyncronousQuit {
database.setUnlogged(name); database.setUnlogged(name);
} }
AuthMePlayerListener.gameMode.remove(name); AuthMePlayerListener.gameMode.remove(name);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, inv, armor, isOp, isFlying, needToChange)); final Player p = player;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, p, inv, armor, isOp, isFlying, needToChange));
} }
} }