Migrate to @Inject

This commit is contained in:
HaHaWTH 2023-11-11 10:00:27 +08:00
parent ecbc11cf0b
commit fcc34c28aa
2 changed files with 14 additions and 7 deletions

View File

@ -231,9 +231,9 @@ public class AuthMe extends JavaPlugin {
if (settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_UNDERGROUND) || settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_PORTAL)) {
getServer().getPluginManager().registerEvents(new LoginLocationFixListener((Plugin) this), this);
}
if (settings.getProperty(SecuritySettings.FORCE_LOGIN_BEDROCK) && settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && getServer().getPluginManager().getPlugin("floodgate") != null) {
getServer().getPluginManager().registerEvents(new BedrockAutoLoginListener((Plugin) this), this);
}
// if (settings.getProperty(SecuritySettings.FORCE_LOGIN_BEDROCK) && settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && getServer().getPluginManager().getPlugin("floodgate") != null) {
// getServer().getPluginManager().registerEvents(new BedrockAutoLoginListener((Plugin) this), this);
// }
// if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && getServer().getPluginManager().getPlugin("ProtocolLib") != null) {
// getServer().getPluginManager().registerEvents(new GuiCaptchaHandler((Plugin) this), this);
// logger.info("(Beta)GUICaptcha is enabled successfully!");
@ -344,6 +344,9 @@ public class AuthMe extends JavaPlugin {
} else if (settings.getProperty(SecuritySettings.GUI_CAPTCHA) && getServer().getPluginManager().getPlugin("ProtocolLib") == null) {
logger.warning("ProtocolLib is not loaded, can't enable GUI Captcha.");
}
if (settings.getProperty(SecuritySettings.FORCE_LOGIN_BEDROCK) && settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && getServer().getPluginManager().getPlugin("floodgate") != null) {
pluginManager.registerEvents(injector.getSingleton(BedrockAutoLoginListener.class), this);
}
// Try to register 1.8+ player listeners

View File

@ -3,6 +3,7 @@ package fr.xephi.authme.listener;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.api.v3.AuthMeApi;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.bukkit.entity.Player;
@ -10,18 +11,21 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.Plugin;
import javax.inject.Inject;
import java.util.UUID;
import static org.bukkit.Bukkit.getServer;
public class BedrockAutoLoginListener implements Listener {
private final AuthMeApi authmeApi = AuthMeApi.getInstance();
private final Plugin plugin;
@Inject
private BukkitService bukkitService;
@Inject
private AuthMe plugin;
public BedrockAutoLoginListener(Plugin plugin) {
this.plugin = plugin;
public BedrockAutoLoginListener() {
}
private boolean isBedrockPlayer(UUID uuid) {