Use injection in and for LimboCache, migrate some legacy settings, remove setGroup from Utils

- New injector method allows to retrieve services if they've already been instantiated -> useful for onDisable() which might be run after aborted initialization
- Deprecate various methods that need to be removed
This commit is contained in:
ljacqu
2016-06-12 16:14:06 +02:00
parent 347d7bcf46
commit d6e1fd5ceb
19 changed files with 226 additions and 198 deletions
@@ -8,6 +8,7 @@ import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.security.PasswordSecurity;
@@ -18,7 +19,6 @@ import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.Utils;
import fr.xephi.authme.util.Utils.GroupType;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@@ -62,12 +62,12 @@ public class AsynchronousUnregister implements AsynchronousProcess {
return;
}
int timeOut = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
if (Settings.isForcedRegistrationEnabled) {
if (service.getProperty(RegistrationSettings.FORCE)) {
Utils.teleportToSpawn(player);
player.saveData();
playerCache.removePlayer(player.getName().toLowerCase());
if (!Settings.getRegisteredGroup.isEmpty()) {
Utils.setGroup(player, GroupType.UNREGISTERED);
service.setGroup(player, AuthGroupType.UNREGISTERED);
}
limboCache.addLimboPlayer(player);
LimboPlayer limboPlayer = limboCache.getLimboPlayer(name);
@@ -83,7 +83,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
return;
}
if (!Settings.unRegisteredGroup.isEmpty()) {
Utils.setGroup(player, Utils.GroupType.UNREGISTERED);
service.setGroup(player, AuthGroupType.UNREGISTERED);
}
playerCache.removePlayer(name);