LoginSystem/src/main/java/fr/xephi/authme/task/TimeoutTask.java
ljacqu 690a8d67a3 Abstract Messages into two layers; move to new 'output' package
- Abstract Messages into two layers: the top layer 'Messages' is how Messages can be retrieved and sent as before. In the background, package-private, MessagesManager actually does the file read and worries about I/O while Messages takes care of higher-level things (such as joining two lines or checking the current language).
2015-12-01 21:45:02 +01:00

63 lines
1.4 KiB
Java

package fr.xephi.authme.task;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
*/
public class TimeoutTask implements Runnable {
private final AuthMe plugin;
private final String name;
private final Messages m;
private final Player player;
/**
* Constructor for TimeoutTask.
*
* @param plugin AuthMe
* @param name String
* @param player Player
*/
public TimeoutTask(AuthMe plugin, String name, Player player) {
this.m = plugin.getMessages();
this.plugin = plugin;
this.name = name;
this.player = player;
}
/**
* Method getName.
*
* @return String
*/
public String getName() {
return name;
}
/**
* Method run.
*
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
if (PlayerCache.getInstance().isAuthenticated(name)) {
return;
}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (player.isOnline()) {
player.kickPlayer(m.retrieveSingle(MessageKey.LOGIN_TIMEOUT_ERROR));
}
}
});
}
}