Fix Inventory Loss + Timeout timings

This commit is contained in:
Xephi59 2015-07-15 18:21:06 +02:00
parent 0fbf57cf1a
commit e9308bb231
7 changed files with 26 additions and 49 deletions

View File

@ -176,7 +176,7 @@ public class AdminCommand implements CommandExecutor {
return true;
}
if (auth == null) {
m.send(sender, "user_unknown");
m.send(sender, "user_unknown");
return true;
}
long lastLogin = auth.getLastLogin();
@ -362,9 +362,9 @@ public class AdminCommand implements CommandExecutor {
if (sender instanceof Player) {
if (Spawn.getInstance().setSpawn(((Player) sender).getLocation())) {
sender.sendMessage("[AuthMe] Correctly defined new spawn point");
} else {
} else {
sender.sendMessage("[AuthMe] SetSpawn has failed, please retry");
}
}
} else {
sender.sendMessage("[AuthMe] Please use that command in game");
}
@ -427,7 +427,8 @@ public class AdminCommand implements CommandExecutor {
ConsoleLogger.showError(ex.getMessage());
}
return true;
} else if (args[0].equalsIgnoreCase("changepassword") || args[0].equalsIgnoreCase("cp")) {
} else
if (args[0].equalsIgnoreCase("changepassword") || args[0].equalsIgnoreCase("cp")) {
if (args.length != 3) {
sender.sendMessage("Usage: /authme changepassword <playername> <newpassword>");
return true;
@ -512,7 +513,7 @@ public class AdminCommand implements CommandExecutor {
int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = sender.getServer().getScheduler();
if (delay != 0) {
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), delay);
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, target), delay);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("reg_msg"), interval)));
@ -528,7 +529,8 @@ public class AdminCommand implements CommandExecutor {
m.send(sender, "unregistered");
ConsoleLogger.info(args[1] + " unregistered");
return true;
} else if (args[0].equalsIgnoreCase("purgelastpos") || args[0].equalsIgnoreCase("resetposition")) {
} else
if (args[0].equalsIgnoreCase("purgelastpos") || args[0].equalsIgnoreCase("resetposition")) {
if (args.length != 2) {
sender.sendMessage("Usage: /authme purgelastpos <playername>");
return true;
@ -581,9 +583,9 @@ public class AdminCommand implements CommandExecutor {
sender.sendMessage("Usage: /authme getip <onlineplayername>");
return true;
}
sender.sendMessage(player.getName() + "'s actual IP is : " + player.getAddress().getAddress().getHostAddress() + ":" + player.getAddress().getPort());
sender.sendMessage(player.getName() + "'s real IP is : " + plugin.getIP(player));
return true;
sender.sendMessage(player.getName() + "'s actual IP is : " + player.getAddress().getAddress().getHostAddress() + ":" + player.getAddress().getPort());
sender.sendMessage(player.getName() + "'s real IP is : " + plugin.getIP(player));
return true;
} else if (args[0].equalsIgnoreCase("forcelogin")) {
if (args.length < 2) {
sender.sendMessage("Usage: /authme forcelogin <playername>");

View File

@ -88,7 +88,7 @@ public class UnregisterCommand implements CommandExecutor {
int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = sender.getServer().getScheduler();
if (delay != 0) {
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), delay);
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("reg_msg"), interval)));

View File

@ -200,7 +200,7 @@ public class AsyncronousJoin {
int time = Settings.getRegistrationTimeout * 20;
int msgInterval = Settings.getWarnMessageInterval;
if (time != 0) {
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), time);
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), time);
if (!LimboCache.getInstance().hasLimboPlayer(name))
LimboCache.getInstance().addLimboPlayer(player);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);

View File

@ -38,7 +38,7 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = player.getServer().getScheduler();
if (delay != 0) {
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), delay);
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));

View File

@ -36,7 +36,7 @@ public class ProcessSyncronousEmailRegister implements Runnable {
int msgInterval = Settings.getWarnMessageInterval;
if (time != 0) {
LimboCache.getInstance().getLimboPlayer(name).getTimeoutTaskId().cancel();
BukkitTask id = Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), time);
BukkitTask id = Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), time);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}

View File

@ -67,7 +67,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = plugin.getServer().getScheduler();
if (delay != 0) {
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), delay);
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));

View File

@ -5,11 +5,8 @@ import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.backup.FileCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.settings.Messages;
@ -19,10 +16,12 @@ public class TimeoutTask implements Runnable {
private String name;
private Messages m = Messages.getInstance();
private FileCache playerCache;
private Player player;
public TimeoutTask(AuthMe plugin, String name) {
public TimeoutTask(AuthMe plugin, String name, Player player) {
this.plugin = plugin;
this.name = name;
this.player = player;
this.playerCache = new FileCache(plugin);
}
@ -35,38 +34,14 @@ public class TimeoutTask implements Runnable {
if (PlayerCache.getInstance().isAuthenticated(name))
return;
for (final Player player : plugin.getServer().getOnlinePlayers()) {
if (player.getName().toLowerCase().equals(name)) {
if (LimboCache.getInstance().hasLimboPlayer(name)) {
LimboPlayer inv = LimboCache.getInstance().getLimboPlayer(name);
inv.getMessageTaskId().cancel();
inv.getTimeoutTaskId().cancel();
if (playerCache.doesCacheExist(player)) {
playerCache.removeCache(player);
}
}
final GameMode gm = AuthMePlayerListener.gameMode.get(name);
if (gm != null) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
final GameMode gm = AuthMePlayerListener.gameMode.get(name);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
player.setGameMode(gm);
}
});
ConsoleLogger.info("Set " + player.getName() + " to gamemode: " + gm.name());
}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (player.isOnline())
player.kickPlayer(m.send("timeout")[0]);
}
});
return;
@Override
public void run() {
if (player.isOnline())
player.kickPlayer(m.send("timeout")[0]);
}
}
});
}
}