#432 Create custom dependency injector
This commit is contained in:
@@ -3,6 +3,7 @@ package fr.xephi.authme.process;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.hooks.PluginHooks;
|
||||
import fr.xephi.authme.process.email.AsyncAddEmail;
|
||||
import fr.xephi.authme.process.email.AsyncChangeEmail;
|
||||
import fr.xephi.authme.process.join.AsynchronousJoin;
|
||||
@@ -14,23 +15,26 @@ import fr.xephi.authme.process.unregister.AsynchronousUnregister;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class Management {
|
||||
|
||||
private final AuthMe plugin;
|
||||
private final BukkitScheduler sched;
|
||||
private final ProcessService processService;
|
||||
private final DataSource dataSource;
|
||||
private final PlayerCache playerCache;
|
||||
@Inject
|
||||
private AuthMe plugin;
|
||||
@Inject
|
||||
private BukkitScheduler sched;
|
||||
@Inject
|
||||
private ProcessService processService;
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
@Inject
|
||||
private PlayerCache playerCache;
|
||||
@Inject
|
||||
private PluginHooks pluginHooks;
|
||||
|
||||
public Management(AuthMe plugin, ProcessService processService, DataSource dataSource, PlayerCache playerCache) {
|
||||
this.plugin = plugin;
|
||||
this.sched = this.plugin.getServer().getScheduler();
|
||||
this.processService = processService;
|
||||
this.dataSource = dataSource;
|
||||
this.playerCache = playerCache;
|
||||
}
|
||||
Management() { }
|
||||
|
||||
public void performLogin(final Player player, final String password, final boolean forceLogin) {
|
||||
runTask(new AsynchronousLogin(player, password, forceLogin, plugin, dataSource, processService));
|
||||
@@ -49,7 +53,7 @@ public class Management {
|
||||
}
|
||||
|
||||
public void performJoin(final Player player) {
|
||||
runTask(new AsynchronousJoin(player, plugin, dataSource, playerCache, processService));
|
||||
runTask(new AsynchronousJoin(player, plugin, dataSource, playerCache, pluginHooks, processService));
|
||||
}
|
||||
|
||||
public void performQuit(final Player player, final boolean isKick) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
@@ -24,29 +25,24 @@ import java.util.Collection;
|
||||
*/
|
||||
public class ProcessService {
|
||||
|
||||
private final NewSetting settings;
|
||||
private final Messages messages;
|
||||
private final AuthMe authMe;
|
||||
private final DataSource dataSource;
|
||||
private final PasswordSecurity passwordSecurity;
|
||||
private final PluginHooks pluginHooks;
|
||||
private final SpawnLoader spawnLoader;
|
||||
private final ValidationService validationService;
|
||||
private final BukkitService bukkitService;
|
||||
|
||||
public ProcessService(NewSetting settings, Messages messages, AuthMe authMe, DataSource dataSource,
|
||||
PasswordSecurity passwordSecurity, PluginHooks pluginHooks, SpawnLoader spawnLoader,
|
||||
ValidationService validationService, BukkitService bukkitService) {
|
||||
this.settings = settings;
|
||||
this.messages = messages;
|
||||
this.authMe = authMe;
|
||||
this.dataSource = dataSource;
|
||||
this.passwordSecurity = passwordSecurity;
|
||||
this.pluginHooks = pluginHooks;
|
||||
this.spawnLoader = spawnLoader;
|
||||
this.validationService = validationService;
|
||||
this.bukkitService = bukkitService;
|
||||
}
|
||||
@Inject
|
||||
private NewSetting settings;
|
||||
@Inject
|
||||
private Messages messages;
|
||||
@Inject
|
||||
private AuthMe authMe;
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
@Inject
|
||||
private PasswordSecurity passwordSecurity;
|
||||
@Inject
|
||||
private PluginHooks pluginHooks;
|
||||
@Inject
|
||||
private SpawnLoader spawnLoader;
|
||||
@Inject
|
||||
private ValidationService validationService;
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
|
||||
/**
|
||||
* Retrieve a property's value.
|
||||
|
||||
@@ -9,6 +9,7 @@ import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
||||
import fr.xephi.authme.events.ProtectInventoryEvent;
|
||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||
import fr.xephi.authme.hooks.PluginHooks;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||
@@ -45,18 +46,20 @@ public class AsynchronousJoin implements Process {
|
||||
private final String name;
|
||||
private final ProcessService service;
|
||||
private final PlayerCache playerCache;
|
||||
private final PluginHooks pluginHooks;
|
||||
|
||||
private final boolean disableCollisions = MethodUtils
|
||||
.getAccessibleMethod(LivingEntity.class, "setCollidable", new Class[]{}) != null;
|
||||
|
||||
public AsynchronousJoin(Player player, AuthMe plugin, DataSource database, PlayerCache playerCache,
|
||||
ProcessService service) {
|
||||
PluginHooks pluginHooks, ProcessService service) {
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
this.database = database;
|
||||
this.name = player.getName().toLowerCase();
|
||||
this.service = service;
|
||||
this.playerCache = playerCache;
|
||||
this.pluginHooks = pluginHooks;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -190,7 +193,7 @@ public class AsynchronousJoin implements Process {
|
||||
player.setWalkSpeed(0.0f);
|
||||
}
|
||||
player.setNoDamageTicks(registrationTimeout);
|
||||
if (plugin.getPluginHooks().isEssentialsAvailable() && service.getProperty(HooksSettings.USE_ESSENTIALS_MOTD)) {
|
||||
if (pluginHooks.isEssentialsAvailable() && service.getProperty(HooksSettings.USE_ESSENTIALS_MOTD)) {
|
||||
player.performCommand("motd");
|
||||
}
|
||||
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||
|
||||
Reference in New Issue
Block a user