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
@@ -5,12 +5,12 @@ import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
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.process.SyncProcessManager;
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 javax.inject.Inject;
@@ -63,7 +63,7 @@ public class AsynchronousLogout implements AsynchronousProcess {
limboCache.deleteLimboPlayer(name);
}
limboCache.addLimboPlayer(player);
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
service.setGroup(player, AuthGroupType.NOT_LOGGED_IN);
syncProcessManager.processSyncPlayerLogout(player);
}
}
@@ -10,13 +10,12 @@ import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask;
import fr.xephi.authme.util.BukkitService;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@@ -53,7 +52,7 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
}
private void restoreSpeedEffect(Player player) {
if (Settings.isRemoveSpeedEnabled) {
if (service.getProperty(RestrictionSettings.REMOVE_SPEED)) {
player.setWalkSpeed(0.0F);
player.setFlySpeed(0.0F);
}
@@ -86,8 +85,8 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
player.setOp(false);
restoreSpeedEffect(player);
// Player is now logout... Time to fire event !
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
if (Settings.bungee) {
bukkitService.callEvent(new LogoutEvent(player));
if (service.getProperty(HooksSettings.BUNGEECORD)) {
sendBungeeMessage(player);
}
service.send(player, MessageKey.LOGOUT_SUCCESS);