mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-08 03:29:41 +01:00
Fix and performances improvements
This commit is contained in:
parent
761b1feadb
commit
f4f1f76e25
@ -1,5 +1,6 @@
|
|||||||
package fr.xephi.authme.cache.limbo;
|
package fr.xephi.authme.cache.limbo;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -83,6 +84,10 @@ public class LimboPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setTimeoutTaskId(BukkitTask i) {
|
public void setTimeoutTaskId(BukkitTask i) {
|
||||||
|
if (this.timeoutTaskId != null) {
|
||||||
|
if (Bukkit.getScheduler().isCurrentlyRunning(this.timeoutTaskId.getTaskId()) || Bukkit.getScheduler().isQueued(this.timeoutTaskId.getTaskId()))
|
||||||
|
Bukkit.getScheduler().cancelTask(this.timeoutTaskId.getTaskId());
|
||||||
|
}
|
||||||
this.timeoutTaskId = i;
|
this.timeoutTaskId = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +96,10 @@ public class LimboPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMessageTaskId(BukkitTask messageTaskId) {
|
public void setMessageTaskId(BukkitTask messageTaskId) {
|
||||||
|
if (this.messageTaskId != null) {
|
||||||
|
if (Bukkit.getScheduler().isCurrentlyRunning(this.messageTaskId.getTaskId()) || Bukkit.getScheduler().isQueued(this.messageTaskId.getTaskId()))
|
||||||
|
Bukkit.getScheduler().cancelTask(this.messageTaskId.getTaskId());
|
||||||
|
}
|
||||||
this.messageTaskId = messageTaskId;
|
this.messageTaskId = messageTaskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +268,8 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (args[0].equalsIgnoreCase("register") || args[0].equalsIgnoreCase("reg")) {
|
} else
|
||||||
|
if (args[0].equalsIgnoreCase("register") || args[0].equalsIgnoreCase("reg")) {
|
||||||
if (args.length != 3) {
|
if (args.length != 3) {
|
||||||
sender.sendMessage("Usage: /authme register playername password");
|
sender.sendMessage("Usage: /authme register playername password");
|
||||||
return true;
|
return true;
|
||||||
@ -394,7 +395,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;
|
||||||
@ -460,10 +462,10 @@ 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.runTaskLater(plugin, new TimeoutTask(plugin, name), delay);
|
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), delay);
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||||
}
|
}
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.runTask(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)));
|
||||||
if (Settings.applyBlindEffect)
|
if (Settings.applyBlindEffect)
|
||||||
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
|
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
|
||||||
m.send(target, "unregistered");
|
m.send(target, "unregistered");
|
||||||
|
@ -2,8 +2,6 @@ package fr.xephi.authme.commands;
|
|||||||
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
import me.muizers.Notifications.Notification;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -29,6 +27,7 @@ import fr.xephi.authme.settings.Messages;
|
|||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
|
import me.muizers.Notifications.Notification;
|
||||||
|
|
||||||
public class UnregisterCommand implements CommandExecutor {
|
public class UnregisterCommand implements CommandExecutor {
|
||||||
|
|
||||||
@ -93,10 +92,10 @@ 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.runTaskLater(plugin, new TimeoutTask(plugin, name), delay);
|
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), delay);
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||||
}
|
}
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.runTask(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)));
|
||||||
m.send(player, "unregistered");
|
m.send(player, "unregistered");
|
||||||
ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
|
ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
|
||||||
if (plugin.notifications != null) {
|
if (plugin.notifications != null) {
|
||||||
|
@ -14,7 +14,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -86,7 +85,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
String msg = event.getMessage();
|
String msg = event.getMessage();
|
||||||
// WorldEdit GUI Shit
|
|
||||||
if (msg.equalsIgnoreCase("/worldedit cui"))
|
if (msg.equalsIgnoreCase("/worldedit cui"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -403,7 +401,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||||
Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
@ -447,18 +445,31 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
if (Settings.isSessionsEnabled)
|
if (Settings.isSessionsEnabled)
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||||
if (!Settings.sessionExpireOnIpChange)
|
if (!Settings.sessionExpireOnIpChange)
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Check if forceSingleSession is set to true, so kick player that has
|
// Check if forceSingleSession is set to true, so kick player that has
|
||||||
// joined with same nick of online player
|
// joined with same nick of online player
|
||||||
if (player.isOnline() && Settings.isForceSingleSessionEnabled) {
|
if (player.isOnline() && Settings.isForceSingleSessionEnabled) {
|
||||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
|
||||||
event.setKickMessage(m.send("same_nick")[0]);
|
event.setKickMessage(m.send("same_nick")[0]);
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
||||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||||
utils.addNormal(player, limbo.getGroup());
|
Utils.getInstance().addNormal(player, limbo.getGroup());
|
||||||
LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase());
|
LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,27 +580,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void placePlayerSafely(Player player, Location spawnLoc) {
|
|
||||||
if (!Settings.noTeleport)
|
|
||||||
return;
|
|
||||||
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
|
|
||||||
return;
|
|
||||||
Block b = player.getLocation().getBlock();
|
|
||||||
if (b.getType() == Material.PORTAL || b.getType() == Material.ENDER_PORTAL || b.getType() == Material.LAVA || b.getType() == Material.STATIONARY_LAVA) {
|
|
||||||
m.send(player, "unsafe_spawn");
|
|
||||||
if (spawnLoc.getWorld() != null)
|
|
||||||
player.teleport(spawnLoc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Block c = player.getLocation().add(0D, 1D, 0D).getBlock();
|
|
||||||
if (c.getType() == Material.PORTAL || c.getType() == Material.ENDER_PORTAL || c.getType() == Material.LAVA || c.getType() == Material.STATIONARY_LAVA) {
|
|
||||||
m.send(player, "unsafe_spawn");
|
|
||||||
if (spawnLoc.getWorld() != null)
|
|
||||||
player.teleport(spawnLoc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
if (event.getPlayer() == null) {
|
if (event.getPlayer() == null) {
|
||||||
@ -616,7 +606,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if ((Settings.isForceSingleSessionEnabled) && (event.getReason().contains("You logged in from another location"))) {
|
if ((!Settings.isForceSingleSessionEnabled) && (event.getReason().contains("You logged in from another location"))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,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.runTaskLater(plugin, new TimeoutTask(plugin, name), time);
|
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), 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);
|
||||||
@ -302,11 +302,12 @@ public class AsyncronousJoin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, msg, msgInterval));
|
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, msg, msgInterval));
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void placePlayerSafely(final Player player, final Location spawnLoc) {
|
private void placePlayerSafely(final Player player,
|
||||||
|
final Location spawnLoc) {
|
||||||
Location loc = null;
|
Location loc = null;
|
||||||
if (spawnLoc == null)
|
if (spawnLoc == null)
|
||||||
return;
|
return;
|
||||||
|
@ -3,8 +3,6 @@ package fr.xephi.authme.process.login;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import me.muizers.Notifications.Notification;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
@ -21,6 +19,7 @@ import fr.xephi.authme.security.RandomString;
|
|||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.settings.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
|
import me.muizers.Notifications.Notification;
|
||||||
|
|
||||||
public class AsyncronousLogin {
|
public class AsyncronousLogin {
|
||||||
|
|
||||||
@ -64,7 +63,8 @@ public class AsyncronousLogin {
|
|||||||
player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(name)).replace("<theCaptcha>", plugin.cap.get(name)));
|
player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(name)).replace("<theCaptcha>", plugin.cap.get(name)));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
|
} else
|
||||||
|
if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
|
||||||
try {
|
try {
|
||||||
plugin.captcha.remove(name);
|
plugin.captcha.remove(name);
|
||||||
plugin.cap.remove(name);
|
plugin.cap.remove(name);
|
||||||
@ -94,7 +94,7 @@ public class AsyncronousLogin {
|
|||||||
} else {
|
} else {
|
||||||
msg = m.send("reg_msg");
|
msg = m.send("reg_msg");
|
||||||
}
|
}
|
||||||
BukkitTask msgT = Bukkit.getScheduler().runTask(plugin, new MessageTask(plugin, name, msg, Settings.getWarnMessageInterval));
|
BukkitTask msgT = Bukkit.getScheduler().runTaskAsynchronously(plugin, new MessageTask(plugin, name, msg, Settings.getWarnMessageInterval));
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package fr.xephi.authme.process.logout;
|
package fr.xephi.authme.process.logout;
|
||||||
|
|
||||||
import me.muizers.Notifications.Notification;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
@ -17,6 +15,7 @@ import fr.xephi.authme.settings.Messages;
|
|||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
|
import me.muizers.Notifications.Notification;
|
||||||
|
|
||||||
public class ProcessSyncronousPlayerLogout implements Runnable {
|
public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||||
|
|
||||||
@ -37,10 +36,10 @@ 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.runTaskLater(plugin, new TimeoutTask(plugin, name), delay);
|
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), delay);
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||||
}
|
}
|
||||||
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||||
try {
|
try {
|
||||||
if (player.isInsideVehicle())
|
if (player.isInsideVehicle())
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package fr.xephi.authme.process.register;
|
package fr.xephi.authme.process.register;
|
||||||
|
|
||||||
import me.muizers.Notifications.Notification;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
@ -14,6 +12,7 @@ import fr.xephi.authme.settings.Messages;
|
|||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
|
import me.muizers.Notifications.Notification;
|
||||||
|
|
||||||
public class ProcessSyncronousEmailRegister implements Runnable {
|
public class ProcessSyncronousEmailRegister implements Runnable {
|
||||||
|
|
||||||
@ -38,12 +37,12 @@ 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().runTaskLater(plugin, new TimeoutTask(plugin, name), time);
|
BukkitTask id = Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), time);
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId().cancel();
|
LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId().cancel();
|
||||||
BukkitTask nwMsg = Bukkit.getScheduler().runTask(plugin, new MessageTask(plugin, name, m.send("login_msg"), msgInterval));
|
BukkitTask nwMsg = Bukkit.getScheduler().runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), msgInterval));
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nwMsg);
|
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nwMsg);
|
||||||
player.saveData();
|
player.saveData();
|
||||||
if (!Settings.noConsoleSpam)
|
if (!Settings.noConsoleSpam)
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package fr.xephi.authme.process.register;
|
package fr.xephi.authme.process.register;
|
||||||
|
|
||||||
import me.muizers.Notifications.Notification;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -22,6 +20,7 @@ import fr.xephi.authme.settings.Messages;
|
|||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
|
import me.muizers.Notifications.Notification;
|
||||||
|
|
||||||
public class ProcessSyncronousPasswordRegister implements Runnable {
|
public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||||
|
|
||||||
@ -67,10 +66,10 @@ 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.runTaskLater(plugin, new TimeoutTask(plugin, name), delay);
|
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name), delay);
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||||
}
|
}
|
||||||
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||||
try {
|
try {
|
||||||
plugin.pllog.removePlayer(name);
|
plugin.pllog.removePlayer(name);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package fr.xephi.authme.task;
|
package fr.xephi.authme.task;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
@ -33,11 +32,11 @@ public class MessageTask implements Runnable {
|
|||||||
for (String ms : msg) {
|
for (String ms : msg) {
|
||||||
player.sendMessage(ms);
|
player.sendMessage(ms);
|
||||||
}
|
}
|
||||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
BukkitTask late = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, this, interval * 20);
|
||||||
BukkitTask late = sched.runTaskLater(plugin, this, interval * 20);
|
|
||||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(late);
|
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(late);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package fr.xephi.authme.task;
|
package fr.xephi.authme.task;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ public class TimeoutTask implements Runnable {
|
|||||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
for (final Player player : plugin.getServer().getOnlinePlayers()) {
|
||||||
if (player.getName().toLowerCase().equals(name)) {
|
if (player.getName().toLowerCase().equals(name)) {
|
||||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||||
LimboPlayer inv = LimboCache.getInstance().getLimboPlayer(name);
|
LimboPlayer inv = LimboCache.getInstance().getLimboPlayer(name);
|
||||||
@ -44,14 +45,27 @@ public class TimeoutTask implements Runnable {
|
|||||||
playerCache.removeCache(player);
|
playerCache.removeCache(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GameMode gm = AuthMePlayerListener.gameMode.get(name);
|
final GameMode gm = AuthMePlayerListener.gameMode.get(name);
|
||||||
if (gm != null)
|
if (gm != null) {
|
||||||
{
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
player.setGameMode(gm);
|
player.setGameMode(gm);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
ConsoleLogger.info("Set " + player.getName() + " to gamemode: " + gm.name());
|
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]);
|
player.kickPlayer(m.send("timeout")[0]);
|
||||||
break;
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user