Change message & timeout task to run synchronously.
This commit is contained in:
@@ -3,6 +3,7 @@ package fr.xephi.authme.task;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@@ -24,32 +25,31 @@ public class MessageTask implements Runnable {
|
||||
* @param strings String[]
|
||||
* @param interval int
|
||||
*/
|
||||
public MessageTask(AuthMe plugin, String name, String[] strings,
|
||||
int interval) {
|
||||
public MessageTask(AuthMe plugin, String name, String[] strings, int interval) {
|
||||
this.plugin = plugin;
|
||||
this.name = name;
|
||||
this.msg = strings;
|
||||
this.interval = interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
public MessageTask(AuthMe plugin, String name, MessageKey messageKey, int interval) {
|
||||
this(plugin, name, plugin.getMessages().retrieve(messageKey), interval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
if (player.getName().toLowerCase().equals(name)) {
|
||||
if (player.getName().equalsIgnoreCase(name)) {
|
||||
for (String ms : msg) {
|
||||
player.sendMessage(ms);
|
||||
}
|
||||
BukkitTask late = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, this, interval * 20);
|
||||
BukkitTask nextTask = plugin.getServer().getScheduler().runTaskLater(plugin, this, interval * 20);
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(late);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nextTask);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user