diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java index 36113575..707030c9 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java @@ -1,5 +1,7 @@ package com.github.games647.fastlogin.bungee; +import com.github.games647.fastlogin.bungee.hooks.BungeeAuthHook; +import com.github.games647.fastlogin.bungee.hooks.BungeeAuthPlugin; import com.google.common.collect.Sets; import java.util.Set; @@ -13,6 +15,7 @@ import net.md_5.bungee.api.plugin.Plugin; public class FastLoginBungee extends Plugin { private final Set enabledPremium = Sets.newConcurrentHashSet(); + private BungeeAuthPlugin bungeeAuthPlugin; @Override public void onEnable() { @@ -21,6 +24,8 @@ public class FastLoginBungee extends Plugin { //this is required to listen to messages from the server getProxy().registerChannel(getDescription().getName()); + + registerHook(); } /** @@ -31,4 +36,21 @@ public class FastLoginBungee extends Plugin { public Set getEnabledPremium() { return enabledPremium; } + + /** + * Get the auth plugin hook for BungeeCord + * + * @return the auth hook for BungeeCord. null if none found + */ + public BungeeAuthPlugin getBungeeAuthPlugin() { + return bungeeAuthPlugin; + } + + private void registerHook() { + Plugin plugin = getProxy().getPluginManager().getPlugin("BungeeAuth"); + if (plugin != null) { + bungeeAuthPlugin = new BungeeAuthHook(); + getLogger().info("Hooked into BungeeAuth"); + } + } } diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/PlayerConnectionListener.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/PlayerConnectionListener.java index a61e3223..da18457e 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/PlayerConnectionListener.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/PlayerConnectionListener.java @@ -1,5 +1,6 @@ package com.github.games647.fastlogin.bungee; +import com.github.games647.fastlogin.bungee.hooks.BungeeAuthPlugin; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; @@ -62,6 +63,11 @@ public class PlayerConnectionListener implements Listener { dataOutput.writeLong(proxyId.getLeastSignificantBits()); server.sendData(plugin.getDescription().getName(), dataOutput.toByteArray()); + + BungeeAuthPlugin authPlugin = plugin.getBungeeAuthPlugin(); + if (authPlugin != null) { + authPlugin.forceLogin(player); + } } } diff --git a/bungee/src/main/resources/bungee.yml b/bungee/src/main/resources/bungee.yml index 2d441d11..132467ef 100644 --- a/bungee/src/main/resources/bungee.yml +++ b/bungee/src/main/resources/bungee.yml @@ -8,5 +8,9 @@ main: ${project.groupId}.${project.artifactId}.${project.name} version: ${project.version} author: games647, http://github.com/games647/FastLogin/graphs/contributors +softdepends: + # BungeeCord auth plugins + - BungeeAuth + description: | ${project.description} \ No newline at end of file