Skip to content

Commit fcc34c2

Browse files
committed
Migrate to @Inject
1 parent ecbc11c commit fcc34c2

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/main/java/fr/xephi/authme/AuthMe.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ private void register3rdPartyListeners() {
231231
if (settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_UNDERGROUND) || settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_PORTAL)) {
232232
getServer().getPluginManager().registerEvents(new LoginLocationFixListener((Plugin) this), this);
233233
}
234-
if (settings.getProperty(SecuritySettings.FORCE_LOGIN_BEDROCK) && settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && getServer().getPluginManager().getPlugin("floodgate") != null) {
235-
getServer().getPluginManager().registerEvents(new BedrockAutoLoginListener((Plugin) this), this);
236-
}
234+
// if (settings.getProperty(SecuritySettings.FORCE_LOGIN_BEDROCK) && settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && getServer().getPluginManager().getPlugin("floodgate") != null) {
235+
// getServer().getPluginManager().registerEvents(new BedrockAutoLoginListener((Plugin) this), this);
236+
// }
237237
// if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && getServer().getPluginManager().getPlugin("ProtocolLib") != null) {
238238
// getServer().getPluginManager().registerEvents(new GuiCaptchaHandler((Plugin) this), this);
239239
// logger.info("(Beta)GUICaptcha is enabled successfully!");
@@ -344,6 +344,9 @@ void registerEventListeners(Injector injector) {
344344
} else if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && getServer().getPluginManager().getPlugin("ProtocolLib") == null) {
345345
logger.warning("ProtocolLib is not loaded, can't enable GUI Captcha.");
346346
}
347+
if (settings.getProperty(SecuritySettings.FORCE_LOGIN_BEDROCK) && settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && getServer().getPluginManager().getPlugin("floodgate") != null) {
348+
pluginManager.registerEvents(injector.getSingleton(BedrockAutoLoginListener.class), this);
349+
}
347350

348351

349352
// Try to register 1.8+ player listeners

src/main/java/fr/xephi/authme/listener/BedrockAutoLoginListener.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,29 @@
33

44
import fr.xephi.authme.AuthMe;
55
import fr.xephi.authme.api.v3.AuthMeApi;
6+
import fr.xephi.authme.service.BukkitService;
67
import fr.xephi.authme.settings.properties.HooksSettings;
78
import fr.xephi.authme.settings.properties.SecuritySettings;
89
import org.bukkit.entity.Player;
910
import org.bukkit.event.EventHandler;
1011
import org.bukkit.event.EventPriority;
1112
import org.bukkit.event.Listener;
1213
import org.bukkit.event.player.PlayerJoinEvent;
13-
import org.bukkit.plugin.Plugin;
1414

15+
import javax.inject.Inject;
1516
import java.util.UUID;
1617

1718
import static org.bukkit.Bukkit.getServer;
1819

1920
public class BedrockAutoLoginListener implements Listener {
2021
private final AuthMeApi authmeApi = AuthMeApi.getInstance();
21-
private final Plugin plugin;
22+
@Inject
23+
private BukkitService bukkitService;
24+
@Inject
25+
private AuthMe plugin;
2226

23-
public BedrockAutoLoginListener(Plugin plugin) {
24-
this.plugin = plugin;
27+
28+
public BedrockAutoLoginListener() {
2529
}
2630

2731
private boolean isBedrockPlayer(UUID uuid) {

0 commit comments

Comments
 (0)