Merge pull request #112 from AuthMe-Team/db-improve
This commit is contained in:
commit
12691a12f1
@ -64,7 +64,6 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -76,6 +75,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -491,11 +491,41 @@ public class AuthMe extends JavaPlugin {
|
|||||||
if (newSettings != null) {
|
if (newSettings != null) {
|
||||||
new PerformBackup(plugin, newSettings).doBackup(PerformBackup.BackupCause.STOP);
|
new PerformBackup(plugin, newSettings).doBackup(PerformBackup.BackupCause.STOP);
|
||||||
}
|
}
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
List<Integer> pendingTasks = new ArrayList<>();
|
||||||
|
for (BukkitTask pendingTask : getServer().getScheduler().getPendingTasks()) {
|
||||||
|
if (pendingTask.getOwner().equals(plugin) && !pendingTask.isSync()) {
|
||||||
|
pendingTasks.add(pendingTask.getTaskId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ConsoleLogger.info("Waiting for " + pendingTasks.size() + " tasks to finish");
|
||||||
|
int progress = 0;
|
||||||
|
for (int taskId : pendingTasks) {
|
||||||
|
int maxTries = 5;
|
||||||
|
while (getServer().getScheduler().isCurrentlyRunning(taskId)) {
|
||||||
|
if (maxTries <= 0) {
|
||||||
|
ConsoleLogger.info("Async task " + taskId + " times out after to many tries");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
|
maxTries--;
|
||||||
|
}
|
||||||
|
|
||||||
|
progress++;
|
||||||
|
ConsoleLogger.info("Progress: " + progress + " / " + pendingTasks.size());
|
||||||
|
}
|
||||||
|
if (database != null) {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, "AuthMe-DataSource#close").start();
|
||||||
|
|
||||||
// Close the database
|
// Close the database
|
||||||
if (database != null) {
|
|
||||||
database.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disabled correctly
|
// Disabled correctly
|
||||||
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " disabled!");
|
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " disabled!");
|
||||||
@ -515,6 +545,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
* Sets up the data source.
|
* Sets up the data source.
|
||||||
*
|
*
|
||||||
* @param settings The settings instance
|
* @param settings The settings instance
|
||||||
|
*
|
||||||
* @see AuthMe#database
|
* @see AuthMe#database
|
||||||
*/
|
*/
|
||||||
public void setupDatabase(NewSetting settings) throws ClassNotFoundException, SQLException {
|
public void setupDatabase(NewSetting settings) throws ClassNotFoundException, SQLException {
|
||||||
@ -650,6 +681,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
ConsoleLogger.showError("WARNING! The protectInventory feature requires ProtocolLib! Disabling it...");
|
ConsoleLogger.showError("WARNING! The protectInventory feature requires ProtocolLib! Disabling it...");
|
||||||
Settings.protectInventoryBeforeLogInEnabled = false;
|
Settings.protectInventoryBeforeLogInEnabled = false;
|
||||||
newSettings.setProperty(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN, false);
|
newSettings.setProperty(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN, false);
|
||||||
|
newSettings.save();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -745,42 +777,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
return Spawn.getInstance().getSpawnLocation(player);
|
return Spawn.getInstance().getSpawnLocation(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the default spawn point of a world
|
|
||||||
private Location getDefaultSpawn(World world) {
|
|
||||||
return world.getSpawnLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the multiverse spawn point of a world
|
|
||||||
private Location getMultiverseSpawn(World world) {
|
|
||||||
if (multiverse != null && Settings.multiverse) {
|
|
||||||
try {
|
|
||||||
return multiverse.getMVWorldManager().getMVWorld(world).getSpawnLocation();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the essentials spawn point
|
|
||||||
private Location getEssentialsSpawn() {
|
|
||||||
if (essentialsSpawn != null) {
|
|
||||||
return essentialsSpawn;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the AuthMe spawn point
|
|
||||||
private Location getAuthMeSpawn(Player player) {
|
|
||||||
if ((!database.isAuthAvailable(player.getName().toLowerCase()) || !player.hasPlayedBefore())
|
|
||||||
&& (Spawn.getInstance().getFirstSpawn() != null)) {
|
|
||||||
return Spawn.getInstance().getFirstSpawn();
|
|
||||||
} else if (Spawn.getInstance().getSpawn() != null) {
|
|
||||||
return Spawn.getInstance().getSpawn();
|
|
||||||
}
|
|
||||||
return player.getWorld().getSpawnLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scheduleRecallEmailTask() {
|
private void scheduleRecallEmailTask() {
|
||||||
if (!newSettings.getProperty(RECALL_PLAYERS)) {
|
if (!newSettings.getProperty(RECALL_PLAYERS)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import com.google.gson.JsonDeserializationContext;
|
|||||||
import com.google.gson.JsonDeserializer;
|
import com.google.gson.JsonDeserializer;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.google.gson.JsonSerializationContext;
|
import com.google.gson.JsonSerializationContext;
|
||||||
import com.google.gson.JsonSerializer;
|
import com.google.gson.JsonSerializer;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
@ -41,14 +40,8 @@ public class JsonCache {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String path;
|
String name = player.getName().toLowerCase();
|
||||||
try {
|
File file = new File(cacheDir, name + File.separator + "cache.json");
|
||||||
path = player.getUniqueId().toString();
|
|
||||||
} catch (Exception | Error e) {
|
|
||||||
path = player.getName().toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
File file = new File(cacheDir, path + File.separator + "cache.json");
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -61,19 +54,13 @@ public class JsonCache {
|
|||||||
Files.touch(file);
|
Files.touch(file);
|
||||||
Files.write(data, file, Charsets.UTF_8);
|
Files.write(data, file, Charsets.UTF_8);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
ConsoleLogger.writeStackTrace(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerData readCache(Player player) {
|
public PlayerData readCache(Player player) {
|
||||||
String path;
|
String name = player.getName().toLowerCase();
|
||||||
try {
|
File file = new File(cacheDir, name + File.separator + "cache.json");
|
||||||
path = player.getUniqueId().toString();
|
|
||||||
} catch (Exception | Error e) {
|
|
||||||
path = player.getName().toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
File file = new File(cacheDir, path + File.separator + "cache.json");
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -81,20 +68,15 @@ public class JsonCache {
|
|||||||
try {
|
try {
|
||||||
String str = Files.toString(file, Charsets.UTF_8);
|
String str = Files.toString(file, Charsets.UTF_8);
|
||||||
return gson.fromJson(str, PlayerData.class);
|
return gson.fromJson(str, PlayerData.class);
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
ConsoleLogger.writeStackTrace(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCache(Player player) {
|
public void removeCache(Player player) {
|
||||||
String path;
|
String name = player.getName().toLowerCase();
|
||||||
try {
|
File file = new File(cacheDir, name);
|
||||||
path = player.getUniqueId().toString();
|
|
||||||
} catch (Exception | Error e) {
|
|
||||||
path = player.getName().toLowerCase();
|
|
||||||
}
|
|
||||||
File file = new File(cacheDir, path);
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
purgeDirectory(file);
|
purgeDirectory(file);
|
||||||
if (!file.delete()) {
|
if (!file.delete()) {
|
||||||
@ -104,19 +86,15 @@ public class JsonCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean doesCacheExist(Player player) {
|
public boolean doesCacheExist(Player player) {
|
||||||
String path;
|
String name = player.getName().toLowerCase();
|
||||||
try {
|
File file = new File(cacheDir, name + File.separator + "cache.json");
|
||||||
path = player.getUniqueId().toString();
|
|
||||||
} catch (Exception | Error e) {
|
|
||||||
path = player.getName().toLowerCase();
|
|
||||||
}
|
|
||||||
File file = new File(cacheDir, path + File.separator + "cache.json");
|
|
||||||
return file.exists();
|
return file.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PlayerDataDeserializer implements JsonDeserializer<PlayerData> {
|
private class PlayerDataDeserializer implements JsonDeserializer<PlayerData> {
|
||||||
@Override
|
@Override
|
||||||
public PlayerData deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
|
public PlayerData deserialize(JsonElement jsonElement, Type type,
|
||||||
|
JsonDeserializationContext context) {
|
||||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||||
if (jsonObject == null) {
|
if (jsonObject == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -143,7 +121,7 @@ public class JsonCache {
|
|||||||
private class PlayerDataSerializer implements JsonSerializer<PlayerData> {
|
private class PlayerDataSerializer implements JsonSerializer<PlayerData> {
|
||||||
@Override
|
@Override
|
||||||
public JsonElement serialize(PlayerData playerData, Type type,
|
public JsonElement serialize(PlayerData playerData, Type type,
|
||||||
JsonSerializationContext jsonSerializationContext) {
|
JsonSerializationContext context) {
|
||||||
JsonObject jsonObject = new JsonObject();
|
JsonObject jsonObject = new JsonObject();
|
||||||
jsonObject.addProperty("group", playerData.getGroup());
|
jsonObject.addProperty("group", playerData.getGroup());
|
||||||
jsonObject.addProperty("operator", playerData.getOperator());
|
jsonObject.addProperty("operator", playerData.getOperator());
|
||||||
|
|||||||
@ -1,14 +1,5 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
@ -20,6 +11,14 @@ 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 fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admin command to unregister a player.
|
* Admin command to unregister a player.
|
||||||
@ -55,19 +54,20 @@ public class UnregisterAdminCommand implements ExecutableCommand {
|
|||||||
if (target != null && target.isOnline()) {
|
if (target != null && target.isOnline()) {
|
||||||
Utils.teleportToSpawn(target);
|
Utils.teleportToSpawn(target);
|
||||||
LimboCache.getInstance().addLimboPlayer(target);
|
LimboCache.getInstance().addLimboPlayer(target);
|
||||||
int delay = Settings.getRegistrationTimeout * 20;
|
int timeOut = Settings.getRegistrationTimeout * 20;
|
||||||
int interval = Settings.getWarnMessageInterval;
|
int interval = Settings.getWarnMessageInterval;
|
||||||
BukkitScheduler scheduler = sender.getServer().getScheduler();
|
BukkitScheduler scheduler = sender.getServer().getScheduler();
|
||||||
if (delay != 0) {
|
if (timeOut != 0) {
|
||||||
BukkitTask id = scheduler.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, playerNameLowerCase, target), delay);
|
BukkitTask id = scheduler.runTaskLater(plugin, new TimeoutTask(plugin, playerNameLowerCase, target), timeOut);
|
||||||
LimboCache.getInstance().getLimboPlayer(playerNameLowerCase).setTimeoutTaskId(id);
|
LimboCache.getInstance().getLimboPlayer(playerNameLowerCase).setTimeoutTaskId(id);
|
||||||
}
|
}
|
||||||
LimboCache.getInstance().getLimboPlayer(playerNameLowerCase).setMessageTaskId(
|
LimboCache.getInstance().getLimboPlayer(playerNameLowerCase).setMessageTaskId(
|
||||||
scheduler.runTaskAsynchronously(plugin,
|
scheduler.runTask(
|
||||||
new MessageTask(plugin, playerNameLowerCase, commandService.retrieveMessage(MessageKey.REGISTER_MESSAGE), interval)));
|
plugin, new MessageTask(plugin, playerNameLowerCase, MessageKey.REGISTER_MESSAGE, interval)
|
||||||
|
)
|
||||||
|
);
|
||||||
if (Settings.applyBlindEffect) {
|
if (Settings.applyBlindEffect) {
|
||||||
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,
|
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2));
|
||||||
Settings.getRegistrationTimeout * 20, 2));
|
|
||||||
}
|
}
|
||||||
commandService.send(target, MessageKey.UNREGISTERED_SUCCESS);
|
commandService.send(target, MessageKey.UNREGISTERED_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,19 @@ import com.google.common.base.Optional;
|
|||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.RemovalListener;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.common.cache.RemovalNotification;
|
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
|
import com.google.common.util.concurrent.MoreExecutors;
|
||||||
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,6 +25,7 @@ public class CacheDataSource implements DataSource {
|
|||||||
|
|
||||||
private final DataSource source;
|
private final DataSource source;
|
||||||
private final LoadingCache<String, Optional<PlayerAuth>> cachedAuths;
|
private final LoadingCache<String, Optional<PlayerAuth>> cachedAuths;
|
||||||
|
private final ListeningExecutorService executorService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CacheDataSource.
|
* Constructor for CacheDataSource.
|
||||||
@ -27,25 +33,35 @@ public class CacheDataSource implements DataSource {
|
|||||||
* @param src DataSource
|
* @param src DataSource
|
||||||
*/
|
*/
|
||||||
public CacheDataSource(DataSource src) {
|
public CacheDataSource(DataSource src) {
|
||||||
this.source = src;
|
source = src;
|
||||||
this.cachedAuths = CacheBuilder.newBuilder()
|
executorService = MoreExecutors.listeningDecorator(
|
||||||
.expireAfterWrite(8, TimeUnit.MINUTES)
|
Executors.newCachedThreadPool(new ThreadFactoryBuilder()
|
||||||
.removalListener(new RemovalListener<String, Optional<PlayerAuth>>() {
|
.setDaemon(true)
|
||||||
|
.setNameFormat("AuthMe-CacheLoader")
|
||||||
|
.build())
|
||||||
|
);
|
||||||
|
cachedAuths = CacheBuilder.newBuilder()
|
||||||
|
.refreshAfterWrite(8, TimeUnit.MINUTES)
|
||||||
|
.build(new CacheLoader<String, Optional<PlayerAuth>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onRemoval(RemovalNotification<String, Optional<PlayerAuth>> removalNotification) {
|
public Optional<PlayerAuth> load(String key) {
|
||||||
String name = removalNotification.getKey();
|
return Optional.fromNullable(source.getAuth(key));
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
|
||||||
cachedAuths.getUnchecked(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.build(
|
@Override
|
||||||
new CacheLoader<String, Optional<PlayerAuth>>() {
|
public ListenableFuture<Optional<PlayerAuth>> reload(final String key, Optional<PlayerAuth> oldValue) {
|
||||||
@Override
|
return executorService.submit(new Callable<Optional<PlayerAuth>>() {
|
||||||
public Optional<PlayerAuth> load(String key) {
|
@Override
|
||||||
return Optional.fromNullable(source.getAuth(key));
|
public Optional<PlayerAuth> call() {
|
||||||
}
|
return load(key);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoadingCache<String, Optional<PlayerAuth>> getCachedAuths() {
|
||||||
|
return cachedAuths;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -137,6 +153,13 @@ public class CacheDataSource implements DataSource {
|
|||||||
@Override
|
@Override
|
||||||
public synchronized void close() {
|
public synchronized void close() {
|
||||||
source.close();
|
source.close();
|
||||||
|
cachedAuths.invalidateAll();
|
||||||
|
executorService.shutdown();
|
||||||
|
try {
|
||||||
|
executorService.awaitTermination(5, TimeUnit.SECONDS);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
ConsoleLogger.writeStackTrace(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -206,20 +206,20 @@ public class AsynchronousJoin {
|
|||||||
|
|
||||||
int msgInterval = Settings.getWarnMessageInterval;
|
int msgInterval = Settings.getWarnMessageInterval;
|
||||||
if (timeOut > 0) {
|
if (timeOut > 0) {
|
||||||
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), timeOut);
|
BukkitTask id = sched.runTaskLater(plugin, new TimeoutTask(plugin, name, player), timeOut);
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] msg;
|
MessageKey msg;
|
||||||
if (isAuthAvailable) {
|
if (isAuthAvailable) {
|
||||||
msg = m.retrieve(MessageKey.LOGIN_MESSAGE);
|
msg = MessageKey.LOGIN_MESSAGE;
|
||||||
} else {
|
} else {
|
||||||
msg = Settings.emailRegistration
|
msg = Settings.emailRegistration
|
||||||
? m.retrieve(MessageKey.REGISTER_EMAIL_MESSAGE)
|
? MessageKey.REGISTER_EMAIL_MESSAGE
|
||||||
: m.retrieve(MessageKey.REGISTER_MESSAGE);
|
: MessageKey.REGISTER_MESSAGE;
|
||||||
}
|
}
|
||||||
if (msgInterval > 0 && LimboCache.getInstance().getLimboPlayer(name) != null) {
|
if (msgInterval > 0 && LimboCache.getInstance().getLimboPlayer(name) != null) {
|
||||||
BukkitTask msgTask = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, msg, msgInterval));
|
BukkitTask msgTask = sched.runTask(plugin, new MessageTask(plugin, name, msg, msgInterval));
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgTask);
|
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,7 +105,7 @@ public class AsynchronousLogin {
|
|||||||
} else {
|
} else {
|
||||||
msg = m.retrieve(MessageKey.REGISTER_MESSAGE);
|
msg = m.retrieve(MessageKey.REGISTER_MESSAGE);
|
||||||
}
|
}
|
||||||
BukkitTask msgT = Bukkit.getScheduler().runTaskAsynchronously(plugin,
|
BukkitTask msgT = Bukkit.getScheduler().runTask(plugin,
|
||||||
new MessageTask(plugin, name, msg, settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL)));
|
new MessageTask(plugin, name, msg, settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL)));
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,21 +74,24 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
|||||||
int interval = Settings.getWarnMessageInterval;
|
int interval = Settings.getWarnMessageInterval;
|
||||||
BukkitScheduler sched = player.getServer().getScheduler();
|
BukkitScheduler sched = player.getServer().getScheduler();
|
||||||
if (timeOut != 0) {
|
if (timeOut != 0) {
|
||||||
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), timeOut);
|
BukkitTask id = sched.runTaskLater(plugin, new TimeoutTask(plugin, name, player), timeOut);
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||||
}
|
}
|
||||||
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.retrieve(MessageKey.LOGIN_MESSAGE), interval));
|
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, MessageKey.LOGIN_MESSAGE, interval));
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||||
if (player.isInsideVehicle() && player.getVehicle() != null)
|
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
||||||
player.getVehicle().eject();
|
player.getVehicle().eject();
|
||||||
if (Settings.applyBlindEffect)
|
}
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
|
if (Settings.applyBlindEffect) {
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2));
|
||||||
|
}
|
||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
restoreSpeedEffect();
|
restoreSpeedEffect();
|
||||||
// Player is now logout... Time to fire event !
|
// Player is now logout... Time to fire event !
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
|
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
|
||||||
if (Settings.bungee)
|
if (Settings.bungee) {
|
||||||
sendBungeeMessage();
|
sendBungeeMessage();
|
||||||
|
}
|
||||||
m.send(player, MessageKey.LOGOUT_SUCCESS);
|
m.send(player, MessageKey.LOGOUT_SUCCESS);
|
||||||
ConsoleLogger.info(player.getName() + " logged out");
|
ConsoleLogger.info(player.getName() + " logged out");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,34 +5,26 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
|
import fr.xephi.authme.datasource.CacheDataSource;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class AsynchronousQuit {
|
public class AsynchronousQuit {
|
||||||
|
|
||||||
protected final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
protected final DataSource database;
|
private final DataSource database;
|
||||||
protected final Player player;
|
private final Player player;
|
||||||
private final String name;
|
private final String name;
|
||||||
private boolean isOp = false;
|
private boolean isOp = false;
|
||||||
private boolean needToChange = false;
|
private boolean needToChange = false;
|
||||||
private boolean isKick = false;
|
private boolean isKick = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for AsynchronousQuit.
|
|
||||||
*
|
|
||||||
* @param p Player
|
|
||||||
* @param plugin AuthMe
|
|
||||||
* @param database DataSource
|
|
||||||
* @param isKick boolean
|
|
||||||
*/
|
|
||||||
public AsynchronousQuit(Player p, AuthMe plugin, DataSource database,
|
public AsynchronousQuit(Player p, AuthMe plugin, DataSource database,
|
||||||
boolean isKick) {
|
boolean isKick) {
|
||||||
this.player = p;
|
this.player = p;
|
||||||
@ -43,9 +35,7 @@ public class AsynchronousQuit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void process() {
|
public void process() {
|
||||||
if (player == null)
|
if (player == null || Utils.isUnrestricted(player)) {
|
||||||
return;
|
|
||||||
if (Utils.isUnrestricted(player)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +44,9 @@ public class AsynchronousQuit {
|
|||||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||||
if (Settings.isSaveQuitLocationEnabled) {
|
if (Settings.isSaveQuitLocationEnabled) {
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName(), player.getName());
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
|
.name(name).location(loc)
|
||||||
|
.realName(player.getName()).build();
|
||||||
database.updateQuitLoc(auth);
|
database.updateQuitLoc(auth);
|
||||||
}
|
}
|
||||||
PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis(), player.getName());
|
PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis(), player.getName());
|
||||||
@ -63,14 +55,11 @@ public class AsynchronousQuit {
|
|||||||
|
|
||||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||||
if (limbo != null) {
|
if (limbo != null) {
|
||||||
if (limbo.getGroup() != null && !limbo.getGroup().isEmpty())
|
if (!StringUtils.isEmpty(limbo.getGroup())) {
|
||||||
Utils.addNormal(player, limbo.getGroup());
|
Utils.addNormal(player, limbo.getGroup());
|
||||||
|
}
|
||||||
needToChange = true;
|
needToChange = true;
|
||||||
isOp = limbo.getOperator();
|
isOp = limbo.getOperator();
|
||||||
if (limbo.getTimeoutTaskId() != null)
|
|
||||||
limbo.getTimeoutTaskId().cancel();
|
|
||||||
if (limbo.getMessageTaskId() != null)
|
|
||||||
limbo.getMessageTaskId().cancel();
|
|
||||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||||
}
|
}
|
||||||
if (Settings.isSessionsEnabled && !isKick) {
|
if (Settings.isSessionsEnabled && !isKick) {
|
||||||
@ -100,12 +89,15 @@ public class AsynchronousQuit {
|
|||||||
if (plugin.isEnabled()) {
|
if (plugin.isEnabled()) {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, needToChange));
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, needToChange));
|
||||||
}
|
}
|
||||||
|
// remove player from cache
|
||||||
|
if (database instanceof CacheDataSource) {
|
||||||
|
((CacheDataSource) database).getCachedAuths().invalidate(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void postLogout() {
|
private void postLogout() {
|
||||||
PlayerCache.getInstance().removePlayer(name);
|
PlayerCache.getInstance().removePlayer(name);
|
||||||
if (database.isLogged(name))
|
database.setUnlogged(name);
|
||||||
database.setUnlogged(name);
|
|
||||||
plugin.sessions.remove(name);
|
plugin.sessions.remove(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,14 +52,13 @@ public class ProcessSyncEmailRegister implements Runnable {
|
|||||||
int msgInterval = Settings.getWarnMessageInterval;
|
int msgInterval = Settings.getWarnMessageInterval;
|
||||||
|
|
||||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||||
if (time != 0 && limbo != null) {
|
|
||||||
limbo.getTimeoutTaskId().cancel();
|
|
||||||
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), time);
|
|
||||||
limbo.setTimeoutTaskId(id);
|
|
||||||
}
|
|
||||||
if (limbo != null) {
|
if (limbo != null) {
|
||||||
limbo.getMessageTaskId().cancel();
|
if (time != 0) {
|
||||||
BukkitTask nwMsg = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.retrieve(MessageKey.LOGIN_MESSAGE), msgInterval));
|
BukkitTask id = sched.runTaskLater(plugin, new TimeoutTask(plugin, name, player), time);
|
||||||
|
limbo.setTimeoutTaskId(id);
|
||||||
|
}
|
||||||
|
BukkitTask nwMsg = sched.runTask(plugin, new MessageTask(plugin, name, m.retrieve(MessageKey.LOGIN_MESSAGE), msgInterval));
|
||||||
limbo.setMessageTaskId(nwMsg);
|
limbo.setMessageTaskId(nwMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,7 @@
|
|||||||
package fr.xephi.authme.process.register;
|
package fr.xephi.authme.process.register;
|
||||||
|
|
||||||
import fr.xephi.authme.settings.NewSetting;
|
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
@ -19,10 +10,17 @@ import fr.xephi.authme.events.LoginEvent;
|
|||||||
import fr.xephi.authme.events.RestoreInventoryEvent;
|
import fr.xephi.authme.events.RestoreInventoryEvent;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
|
import fr.xephi.authme.settings.NewSetting;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
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 fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@ -37,8 +35,8 @@ public class ProcessSyncPasswordRegister implements Runnable {
|
|||||||
/**
|
/**
|
||||||
* Constructor for ProcessSyncPasswordRegister.
|
* Constructor for ProcessSyncPasswordRegister.
|
||||||
*
|
*
|
||||||
* @param player Player
|
* @param player Player
|
||||||
* @param plugin AuthMe
|
* @param plugin AuthMe
|
||||||
* @param settings The plugin settings
|
* @param settings The plugin settings
|
||||||
*/
|
*/
|
||||||
public ProcessSyncPasswordRegister(Player player, AuthMe plugin, NewSetting settings) {
|
public ProcessSyncPasswordRegister(Player player, AuthMe plugin, NewSetting settings) {
|
||||||
@ -77,11 +75,10 @@ public class ProcessSyncPasswordRegister implements Runnable {
|
|||||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||||
BukkitTask task;
|
BukkitTask task;
|
||||||
if (delay != 0) {
|
if (delay != 0) {
|
||||||
task = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay);
|
task = sched.runTaskLater(plugin, new TimeoutTask(plugin, name, player), delay);
|
||||||
cache.getLimboPlayer(name).setTimeoutTaskId(task);
|
cache.getLimboPlayer(name).setTimeoutTaskId(task);
|
||||||
}
|
}
|
||||||
task = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name,
|
task = sched.runTask(plugin, new MessageTask(plugin, name, MessageKey.LOGIN_MESSAGE, interval));
|
||||||
m.retrieve(MessageKey.LOGIN_MESSAGE), interval));
|
|
||||||
cache.getLimboPlayer(name).setMessageTaskId(task);
|
cache.getLimboPlayer(name).setMessageTaskId(task);
|
||||||
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
||||||
player.getVehicle().eject();
|
player.getVehicle().eject();
|
||||||
|
|||||||
@ -73,12 +73,11 @@ public class AsynchronousUnregister {
|
|||||||
int interval = Settings.getWarnMessageInterval;
|
int interval = Settings.getWarnMessageInterval;
|
||||||
BukkitScheduler scheduler = plugin.getServer().getScheduler();
|
BukkitScheduler scheduler = plugin.getServer().getScheduler();
|
||||||
if (timeOut != 0) {
|
if (timeOut != 0) {
|
||||||
BukkitTask id = scheduler.runTaskLaterAsynchronously(plugin,
|
BukkitTask id = scheduler.runTaskLater(plugin, new TimeoutTask(plugin, name, player), timeOut);
|
||||||
new TimeoutTask(plugin, name, player), timeOut);
|
|
||||||
limboPlayer.setTimeoutTaskId(id);
|
limboPlayer.setTimeoutTaskId(id);
|
||||||
}
|
}
|
||||||
limboPlayer.setMessageTaskId(scheduler.runTaskAsynchronously(plugin,
|
limboPlayer.setMessageTaskId(scheduler.runTask(plugin,
|
||||||
new MessageTask(plugin, name, m.retrieve(MessageKey.REGISTER_MESSAGE), interval)));
|
new MessageTask(plugin, name, MessageKey.REGISTER_MESSAGE, interval)));
|
||||||
m.send(player, MessageKey.UNREGISTERED_SUCCESS);
|
m.send(player, MessageKey.UNREGISTERED_SUCCESS);
|
||||||
ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
|
ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package fr.xephi.authme.task;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
@ -24,32 +25,31 @@ public class MessageTask implements Runnable {
|
|||||||
* @param strings String[]
|
* @param strings String[]
|
||||||
* @param interval int
|
* @param interval int
|
||||||
*/
|
*/
|
||||||
public MessageTask(AuthMe plugin, String name, String[] strings,
|
public MessageTask(AuthMe plugin, String name, String[] strings, int interval) {
|
||||||
int interval) {
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.msg = strings;
|
this.msg = strings;
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public MessageTask(AuthMe plugin, String name, MessageKey messageKey, int interval) {
|
||||||
* Method run.
|
this(plugin, name, plugin.getMessages().retrieve(messageKey), interval);
|
||||||
*
|
}
|
||||||
* @see java.lang.Runnable#run()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (Player player : Utils.getOnlinePlayers()) {
|
for (Player player : Utils.getOnlinePlayers()) {
|
||||||
if (player.getName().toLowerCase().equals(name)) {
|
if (player.getName().equalsIgnoreCase(name)) {
|
||||||
for (String ms : msg) {
|
for (String ms : msg) {
|
||||||
player.sendMessage(ms);
|
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)) {
|
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(late);
|
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nextTask);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,10 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class TimeoutTask implements Runnable {
|
public class TimeoutTask implements Runnable {
|
||||||
|
|
||||||
private final AuthMe plugin;
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final Messages m;
|
private final Messages m;
|
||||||
private final Player player;
|
private final Player player;
|
||||||
@ -25,38 +21,14 @@ public class TimeoutTask implements Runnable {
|
|||||||
*/
|
*/
|
||||||
public TimeoutTask(AuthMe plugin, String name, Player player) {
|
public TimeoutTask(AuthMe plugin, String name, Player player) {
|
||||||
this.m = plugin.getMessages();
|
this.m = plugin.getMessages();
|
||||||
this.plugin = plugin;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getName.
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method run.
|
|
||||||
*
|
|
||||||
* @see java.lang.Runnable#run()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
if (!PlayerCache.getInstance().isAuthenticated(name)) {
|
||||||
return;
|
player.kickPlayer(m.retrieveSingle(MessageKey.LOGIN_TIMEOUT_ERROR));
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (player.isOnline()) {
|
|
||||||
player.kickPlayer(m.retrieveSingle(MessageKey.LOGIN_TIMEOUT_ERROR));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user