diff --git a/AdvancedCore/pom.xml b/AdvancedCore/pom.xml index e073ae966..cce80595d 100644 --- a/AdvancedCore/pom.xml +++ b/AdvancedCore/pom.xml @@ -189,6 +189,10 @@ dmulloy2-repo https://repo.dmulloy2.net/repository/public/ + + nickuc-repo + https://repo.nickuc.com/maven-releases/ + @@ -313,6 +317,12 @@ 5.18.0 test + + com.nickuc.login + api + 10.4 + provided + @@ -491,4 +501,4 @@ - \ No newline at end of file + diff --git a/AdvancedCore/src/main/java/com/bencodez/advancedcore/AdvancedCorePlugin.java b/AdvancedCore/src/main/java/com/bencodez/advancedcore/AdvancedCorePlugin.java index 1051c7d08..2754af7af 100644 --- a/AdvancedCore/src/main/java/com/bencodez/advancedcore/AdvancedCorePlugin.java +++ b/AdvancedCore/src/main/java/com/bencodez/advancedcore/AdvancedCorePlugin.java @@ -21,6 +21,7 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import com.bencodez.advancedcore.listeners.*; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandMap; @@ -56,12 +57,6 @@ import com.bencodez.advancedcore.command.CommandLoader; import com.bencodez.advancedcore.command.executor.ValueRequestInputCommand; import com.bencodez.advancedcore.data.ServerData; -import com.bencodez.advancedcore.listeners.AuthMeLogin; -import com.bencodez.advancedcore.listeners.LoginSecurityLogin; -import com.bencodez.advancedcore.listeners.PlayerJoinEvent; -import com.bencodez.advancedcore.listeners.PlayerShowListener; -import com.bencodez.advancedcore.listeners.PluginUpdateVersionEvent; -import com.bencodez.advancedcore.listeners.WorldChangeEvent; import com.bencodez.advancedcore.logger.Logger; import com.bencodez.simpleapi.command.TabCompleteHandle; import com.bencodez.simpleapi.command.TabCompleteHandler; @@ -105,6 +100,9 @@ public static void setInstance(AdvancedCorePlugin plugin) { @Getter private boolean authMeLoaded = false; + @Getter + private boolean nLoginLoaded = false; + @Getter private boolean loginSecurityLoaded = false; @@ -583,6 +581,12 @@ public void log(String log) { authMeLoaded = true; Bukkit.getPluginManager().registerEvents(new AuthMeLogin(this), this); } + + if (Bukkit.getPluginManager().getPlugin("nLogin") != null) { + nLoginLoaded = true; + Bukkit.getPluginManager().registerEvents(new NLoginAuthenticate(this), this); + } + if (Bukkit.getPluginManager().getPlugin("LoginSecurity") != null) { loginSecurityLoaded = true; Bukkit.getPluginManager().registerEvents(new LoginSecurityLogin(this), this); diff --git a/AdvancedCore/src/main/java/com/bencodez/advancedcore/listeners/NLoginAuthenticate.java b/AdvancedCore/src/main/java/com/bencodez/advancedcore/listeners/NLoginAuthenticate.java new file mode 100644 index 000000000..63c08b934 --- /dev/null +++ b/AdvancedCore/src/main/java/com/bencodez/advancedcore/listeners/NLoginAuthenticate.java @@ -0,0 +1,31 @@ +package com.bencodez.advancedcore.listeners; + +import com.bencodez.advancedcore.AdvancedCorePlugin; +import com.bencodez.advancedcore.api.misc.PlayerManager; +import com.nickuc.login.api.event.bukkit.auth.AuthenticateEvent; +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class NLoginAuthenticate implements Listener { + private AdvancedCorePlugin plugin; + + public NLoginAuthenticate(AdvancedCorePlugin plugin) { + this.plugin = plugin; + } + + @EventHandler + public void nLoginLogin(AuthenticateEvent event) { + + plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, () -> { + if (event.getPlayer() != null) { + if (plugin.getOptions().isWaitUntilLoggedIn()) { + plugin.debug("nLogin Login: " + event.getPlayer().getName() + " (" + + PlayerManager.getInstance().getUUID(event.getPlayer().getName()) + ")"); + AdvancedCoreLoginEvent login = new AdvancedCoreLoginEvent(event.getPlayer()); + Bukkit.getPluginManager().callEvent(login); + } + } + }, 2); + } +} diff --git a/AdvancedCore/src/main/java/com/bencodez/advancedcore/listeners/PlayerJoinEvent.java b/AdvancedCore/src/main/java/com/bencodez/advancedcore/listeners/PlayerJoinEvent.java index 68fc7ab8d..11ed0b7b2 100644 --- a/AdvancedCore/src/main/java/com/bencodez/advancedcore/listeners/PlayerJoinEvent.java +++ b/AdvancedCore/src/main/java/com/bencodez/advancedcore/listeners/PlayerJoinEvent.java @@ -88,7 +88,7 @@ public void run() { try { if (plugin != null && plugin.isEnabled()) { TabCompleteHandler.getInstance().onLogin(); - if ((plugin.isAuthMeLoaded() || plugin.isLoginSecurityLoaded()) + if ((plugin.isAuthMeLoaded() || plugin.isLoginSecurityLoaded() || plugin.isNLoginLoaded()) && plugin.getOptions().isWaitUntilLoggedIn()) { return; } diff --git a/AdvancedCore/src/main/java/com/bencodez/advancedcore/listeners/PlayerShowListener.java b/AdvancedCore/src/main/java/com/bencodez/advancedcore/listeners/PlayerShowListener.java index 07c3b356e..590065a85 100644 --- a/AdvancedCore/src/main/java/com/bencodez/advancedcore/listeners/PlayerShowListener.java +++ b/AdvancedCore/src/main/java/com/bencodez/advancedcore/listeners/PlayerShowListener.java @@ -36,7 +36,7 @@ public void onJoin(PlayerShowEvent event) { @Override public void run() { if (plugin != null && plugin.isEnabled()) { - if (plugin.isAuthMeLoaded() && plugin.getOptions().isWaitUntilLoggedIn()) { + if ((plugin.isAuthMeLoaded() || plugin.isNLoginLoaded()) && plugin.getOptions().isWaitUntilLoggedIn()) { return; }