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

@ -427,7 +427,8 @@ public class AdminCommand implements CommandExecutor {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.showError(ex.getMessage());
} }
return true; 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) { if (args.length != 3) {
sender.sendMessage("Usage: /authme changepassword <playername> <newpassword>"); sender.sendMessage("Usage: /authme changepassword <playername> <newpassword>");
return true; return true;
@ -512,7 +513,7 @@ public class AdminCommand implements CommandExecutor {
int interval = Settings.getWarnMessageInterval; int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = sender.getServer().getScheduler(); BukkitScheduler sched = sender.getServer().getScheduler();
if (delay != 0) { 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).setTimeoutTaskId(id);
} }
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("reg_msg"), interval))); 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"); m.send(sender, "unregistered");
ConsoleLogger.info(args[1] + " unregistered"); ConsoleLogger.info(args[1] + " unregistered");
return true; 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) { if (args.length != 2) {
sender.sendMessage("Usage: /authme purgelastpos <playername>"); sender.sendMessage("Usage: /authme purgelastpos <playername>");
return true; return true;

View File

@ -88,7 +88,7 @@ public class UnregisterCommand implements CommandExecutor {
int interval = Settings.getWarnMessageInterval; int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = sender.getServer().getScheduler(); BukkitScheduler sched = sender.getServer().getScheduler();
if (delay != 0) { 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).setTimeoutTaskId(id);
} }
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("reg_msg"), interval))); 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 time = Settings.getRegistrationTimeout * 20;
int msgInterval = Settings.getWarnMessageInterval; int msgInterval = Settings.getWarnMessageInterval;
if (time != 0) { 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)) if (!LimboCache.getInstance().hasLimboPlayer(name))
LimboCache.getInstance().addLimboPlayer(player); LimboCache.getInstance().addLimboPlayer(player);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id); LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);

View File

@ -38,7 +38,7 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
int interval = Settings.getWarnMessageInterval; int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = player.getServer().getScheduler(); BukkitScheduler sched = player.getServer().getScheduler();
if (delay != 0) { 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).setTimeoutTaskId(id);
} }
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval)); 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; int msgInterval = Settings.getWarnMessageInterval;
if (time != 0) { if (time != 0) {
LimboCache.getInstance().getLimboPlayer(name).getTimeoutTaskId().cancel(); 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); LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
} }

View File

@ -67,7 +67,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
int interval = Settings.getWarnMessageInterval; int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = plugin.getServer().getScheduler(); BukkitScheduler sched = plugin.getServer().getScheduler();
if (delay != 0) { 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).setTimeoutTaskId(id);
} }
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval)); 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 org.bukkit.entity.Player;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.backup.FileCache; 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.listener.AuthMePlayerListener;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
@ -19,10 +16,12 @@ public class TimeoutTask implements Runnable {
private String name; private String name;
private Messages m = Messages.getInstance(); private Messages m = Messages.getInstance();
private FileCache playerCache; private FileCache playerCache;
private Player player;
public TimeoutTask(AuthMe plugin, String name) { public TimeoutTask(AuthMe plugin, String name, Player player) {
this.plugin = plugin; this.plugin = plugin;
this.name = name; this.name = name;
this.player = player;
this.playerCache = new FileCache(plugin); this.playerCache = new FileCache(plugin);
} }
@ -35,28 +34,7 @@ public class TimeoutTask implements Runnable {
if (PlayerCache.getInstance().isAuthenticated(name)) if (PlayerCache.getInstance().isAuthenticated(name))
return; 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); final GameMode gm = AuthMePlayerListener.gameMode.get(name);
if (gm != null) {
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() { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override @Override
@ -65,8 +43,5 @@ public class TimeoutTask implements Runnable {
player.kickPlayer(m.send("timeout")[0]); player.kickPlayer(m.send("timeout")[0]);
} }
}); });
return;
}
}
} }
} }