mirror of
https://e.coding.net/circlecloud/AuthMe.git
synced 2025-11-24 21:26:20 +00:00
@@ -17,76 +17,81 @@ import cn.citycraft.AuthMe.settings.Settings;
|
|||||||
|
|
||||||
public class AsyncronousQuit {
|
public class AsyncronousQuit {
|
||||||
|
|
||||||
private boolean isFlying = false;
|
private boolean isFlying = false;
|
||||||
private boolean isKick = false;
|
private boolean isKick = false;
|
||||||
private boolean isOp = false;
|
private boolean isOp = false;
|
||||||
private String name;
|
private final String name;
|
||||||
private boolean needToChange = false;
|
private boolean needToChange = false;
|
||||||
protected DataSource database;
|
protected DataSource database;
|
||||||
protected Player player;
|
protected Player player;
|
||||||
protected AuthMe plugin;
|
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.player = p;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.database = database;
|
this.database = database;
|
||||||
this.name = p.getName().toLowerCase();
|
this.name = p.getName().toLowerCase();
|
||||||
this.isKick = isKick;
|
this.isKick = isKick;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process() {
|
public void process() {
|
||||||
if (player == null)
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
|
}
|
||||||
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 (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||||
if (Settings.isSaveQuitLocationEnabled && database.isAuthAvailable(name)) {
|
if (Settings.isSaveQuitLocationEnabled && database.isAuthAvailable(name)) {
|
||||||
Location loc = player.getLocation();
|
final Location loc = player.getLocation();
|
||||||
PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName(), player.getName());
|
final PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName(), player.getName());
|
||||||
database.updateQuitLoc(auth);
|
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);
|
database.updateSession(auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
final LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||||
if (limbo.getGroup() != null && !limbo.getGroup().equals(""))
|
if (limbo.getGroup() != null && !"".equals(limbo.getGroup())) {
|
||||||
Utils.addNormal(player, limbo.getGroup());
|
Utils.addNormal(player, limbo.getGroup());
|
||||||
needToChange = true;
|
}
|
||||||
isOp = limbo.getOperator();
|
needToChange = true;
|
||||||
isFlying = limbo.isFlying();
|
isOp = limbo.getOperator();
|
||||||
if (limbo.getTimeoutTaskId() != null)
|
isFlying = limbo.isFlying();
|
||||||
limbo.getTimeoutTaskId().cancel();
|
if (limbo.getTimeoutTaskId() != null) {
|
||||||
if (limbo.getMessageTaskId() != null)
|
limbo.getTimeoutTaskId().cancel();
|
||||||
limbo.getMessageTaskId().cancel();
|
}
|
||||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
if (limbo.getMessageTaskId() != null) {
|
||||||
}
|
limbo.getMessageTaskId().cancel();
|
||||||
if (Settings.isSessionsEnabled && !isKick) {
|
}
|
||||||
if (Settings.getSessionTimeout != 0) {
|
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||||
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
}
|
||||||
|
if (Settings.isSessionsEnabled && !isKick) {
|
||||||
|
if (Settings.getSessionTimeout != 0) {
|
||||||
|
final BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PlayerCache.getInstance().removePlayer(name);
|
PlayerCache.getInstance().removePlayer(name);
|
||||||
if (database.isLogged(name))
|
if (database.isLogged(name)) {
|
||||||
database.setUnlogged(name);
|
database.setUnlogged(name);
|
||||||
plugin.sessions.remove(name);
|
}
|
||||||
}
|
plugin.sessions.remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
}, Settings.getSessionTimeout * 20 * 60);
|
}, Settings.getSessionTimeout * 20 * 60);
|
||||||
plugin.sessions.put(name, task);
|
plugin.sessions.put(name, task);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PlayerCache.getInstance().removePlayer(name);
|
PlayerCache.getInstance().removePlayer(name);
|
||||||
database.setUnlogged(name);
|
database.setUnlogged(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthMePlayerListener.gameMode.remove(name);
|
AuthMePlayerListener.gameMode.remove(name);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, isFlying, needToChange));
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, isFlying, needToChange));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user