1
0
mirror of https://e.coding.net/circlecloud/AuthMe.git synced 2025-11-24 21:26:20 +00:00

fix: 玩家退出检测修复NPE

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
2016-07-01 15:24:30 +08:00
parent 57646f6ed2
commit 82c33abafb

View File

@@ -20,13 +20,13 @@ public class AsyncronousQuit {
private boolean isFlying = false;
private boolean isKick = false;
private boolean isOp = false;
private String name;
private final String name;
private boolean needToChange = false;
protected DataSource database;
protected Player player;
protected AuthMe plugin;
public AsyncronousQuit(Player p, AuthMe plugin, DataSource database, boolean isKick) {
public AsyncronousQuit(final Player p, final AuthMe plugin, final DataSource database, final boolean isKick) {
this.player = p;
this.plugin = plugin;
this.database = database;
@@ -35,46 +35,51 @@ public class AsyncronousQuit {
}
public void process() {
if (player == null)
if (player == null) {
return;
}
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
return;
}
String ip = plugin.getIP(player);
final String ip = plugin.getIP(player);
if (PlayerCache.getInstance().isAuthenticated(name)) {
if (Settings.isSaveQuitLocationEnabled && database.isAuthAvailable(name)) {
Location loc = player.getLocation();
PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName(), player.getName());
final Location loc = player.getLocation();
final PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName(), player.getName());
database.updateQuitLoc(auth);
}
PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis(), player.getName());
final PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis(), player.getName());
database.updateSession(auth);
}
if (LimboCache.getInstance().hasLimboPlayer(name)) {
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
if (limbo.getGroup() != null && !limbo.getGroup().equals(""))
final LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
if (limbo.getGroup() != null && !"".equals(limbo.getGroup())) {
Utils.addNormal(player, limbo.getGroup());
}
needToChange = true;
isOp = limbo.getOperator();
isFlying = limbo.isFlying();
if (limbo.getTimeoutTaskId() != null)
if (limbo.getTimeoutTaskId() != null) {
limbo.getTimeoutTaskId().cancel();
if (limbo.getMessageTaskId() != null)
}
if (limbo.getMessageTaskId() != null) {
limbo.getMessageTaskId().cancel();
}
LimboCache.getInstance().deleteLimboPlayer(name);
}
if (Settings.isSessionsEnabled && !isKick) {
if (Settings.getSessionTimeout != 0) {
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
final BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
PlayerCache.getInstance().removePlayer(name);
if (database.isLogged(name))
if (database.isLogged(name)) {
database.setUnlogged(name);
}
plugin.sessions.remove(name);
}