+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.github.games647.fastlogin.bungee.hook;
+
+import com.github.games647.fastlogin.bungee.FastLoginBungee;
+import com.github.games647.fastlogin.core.hooks.AuthPlugin;
+import net.md_5.bungee.api.connection.ProxiedPlayer;
+import red.mohist.sodionauth.bungee.implementation.BungeePlayer;
+import red.mohist.sodionauth.core.SodionAuthApi;
+import red.mohist.sodionauth.core.exception.AuthenticatedException;
+
+import java.util.concurrent.ExecutionException;
+
+/**
+ * GitHub: https://github.com/Mohist-Community/SodionAuth
+ *
+ * Project page: https://gitea.e-loli.com/SodionAuth/SodionAuth
+ *
+ * Bukkit: Unknown
+ *
+ * Spigot: https://www.spigotmc.org/resources/sodionauth.76944/
+ */
+public class SodionAuthHook implements AuthPlugin {
+
+ private final FastLoginBungee plugin;
+
+ public SodionAuthHook(FastLoginBungee plugin) {
+ this.plugin = plugin;
+ }
+
+ @Override
+ public boolean forceLogin(ProxiedPlayer player) {
+ try {
+ SodionAuthApi.login(new BungeePlayer(player));
+ } catch (AuthenticatedException e) {
+ plugin.getLog().warn(ALREADY_AUTHENTICATED, player);
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean forceRegister(ProxiedPlayer player, String password) {
+ try{
+ return SodionAuthApi.register(new BungeePlayer(player), password);
+ } catch (UnsupportedOperationException e){
+ plugin.getLog().warn("Currently SodionAuth is not accepting forceRegister, " +
+ "It may be caused by unsupported AuthBackend");
+ return false;
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+ public boolean isRegistered(String playerName) {
+ return SodionAuthApi.isRegistered(playerName);
+ }
+}
From 8837a1b70e4ab7c7f0eb5baa6e390bbb3f2f7323 Mon Sep 17 00:00:00 2001
From: InkerBot <2924657226@qq.com>
Date: Tue, 6 Apr 2021 21:27:25 +0800
Subject: [PATCH 03/10] Bump SodionAuth version and fix errors.
---
bukkit/pom.xml | 2 +-
.../games647/fastlogin/bukkit/hook/SodionAuthHook.java | 3 ---
bungee/pom.xml | 2 +-
.../games647/fastlogin/bungee/hook/SodionAuthHook.java | 5 ++---
4 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/bukkit/pom.xml b/bukkit/pom.xml
index 6fd656b5..97492b7c 100644
--- a/bukkit/pom.xml
+++ b/bukkit/pom.xml
@@ -272,7 +272,7 @@
com.github.Mohist-Community.SodionAuth
SodionAuth-Bukkit
- 3a71c7f936
+ 2bdfdc854b
com.github.Mohist-Community.SodionAuth
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/SodionAuthHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/SodionAuthHook.java
index 2c75c75f..9a22ed30 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/SodionAuthHook.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/SodionAuthHook.java
@@ -70,9 +70,6 @@ public class SodionAuthHook implements AuthPlugin {
plugin.getLog().warn("Currently SodionAuth is not accepting forceRegister, " +
"It may be caused by unsupported AuthBackend");
return false;
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- return false;
}
}
diff --git a/bungee/pom.xml b/bungee/pom.xml
index 410da12e..5d5d842d 100644
--- a/bungee/pom.xml
+++ b/bungee/pom.xml
@@ -150,7 +150,7 @@
com.github.Mohist-Community.SodionAuth
SodionAuth-Bungee
- 3a71c7f936
+ 2bdfdc854b
com.github.Mohist-Community.SodionAuth
diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/SodionAuthHook.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/SodionAuthHook.java
index 298fbbf9..f22d3619 100644
--- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/SodionAuthHook.java
+++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/SodionAuthHook.java
@@ -70,11 +70,10 @@ public class SodionAuthHook implements AuthPlugin {
plugin.getLog().warn("Currently SodionAuth is not accepting forceRegister, " +
"It may be caused by unsupported AuthBackend");
return false;
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- return false;
}
}
+
+ @Override
public boolean isRegistered(String playerName) {
return SodionAuthApi.isRegistered(playerName);
}
From 68d23e127a6e9f2f6a7ea09f42fcb34432e513cd Mon Sep 17 00:00:00 2001
From: InkerBot <2924657226@qq.com>
Date: Tue, 6 Apr 2021 21:27:25 +0800
Subject: [PATCH 04/10] Bump SodionAuth version and fix errors.
---
.../github/games647/fastlogin/bukkit/hook/SodionAuthHook.java | 2 --
1 file changed, 2 deletions(-)
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/SodionAuthHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/SodionAuthHook.java
index 9a22ed30..8b9888ec 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/SodionAuthHook.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/SodionAuthHook.java
@@ -32,8 +32,6 @@ import red.mohist.sodionauth.bukkit.implementation.BukkitPlayer;
import red.mohist.sodionauth.core.SodionAuthApi;
import red.mohist.sodionauth.core.exception.AuthenticatedException;
-import java.util.concurrent.ExecutionException;
-
/**
* GitHub: https://github.com/Mohist-Community/SodionAuth
*
From f766e6213e2151fa479de6ccaf1d8b9e0c421724 Mon Sep 17 00:00:00 2001
From: InkerBot <2924657226@qq.com>
Date: Tue, 6 Apr 2021 21:58:53 +0800
Subject: [PATCH 05/10] Use a loop to hook AuthPlugin
---
.../fastlogin/bungee/FastLoginBungee.java | 39 ++++++++++---------
.../fastlogin/bungee/hook/BungeeAuthHook.java | 4 ++
...=> BungeeCordAuthenticatorBungeeHook.java} | 14 +++----
3 files changed, 31 insertions(+), 26 deletions(-)
rename bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/{BungeeCordAuthenticatorHook.java => BungeeCordAuthenticatorBungeeHook.java} (85%)
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 3c1410da..439877da 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
@@ -26,12 +26,13 @@
package com.github.games647.fastlogin.bungee;
import com.github.games647.fastlogin.bungee.hook.BungeeAuthHook;
-import com.github.games647.fastlogin.bungee.hook.BungeeCordAuthenticatorHook;
+import com.github.games647.fastlogin.bungee.hook.BungeeCordAuthenticatorBungeeHook;
import com.github.games647.fastlogin.bungee.hook.SodionAuthHook;
import com.github.games647.fastlogin.bungee.listener.ConnectListener;
import com.github.games647.fastlogin.bungee.listener.PluginMessageListener;
import com.github.games647.fastlogin.core.AsyncScheduler;
import com.github.games647.fastlogin.core.CommonUtil;
+import com.github.games647.fastlogin.core.hooks.AuthPlugin;
import com.github.games647.fastlogin.core.message.ChangePremiumMessage;
import com.github.games647.fastlogin.core.message.ChannelMessage;
import com.github.games647.fastlogin.core.message.NamespaceKey;
@@ -44,6 +45,8 @@ import com.google.common.io.ByteStreams;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ThreadFactory;
@@ -56,6 +59,8 @@ import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.api.plugin.PluginManager;
import net.md_5.bungee.api.scheduler.GroupedThreadFactory;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
import org.slf4j.Logger;
/**
@@ -111,23 +116,21 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin>> hooks = Arrays.asList(
+ BungeeAuthHook.class, BungeeCordAuthenticatorBungeeHook.class, SodionAuthHook.class);
+
+ for (Class extends AuthPlugin> clazz : hooks) {
+ String pluginName = clazz.getSimpleName().replace("Hook", "");
+ //uses only member classes which uses AuthPlugin interface (skip interfaces)
+ Plugin plugin = getProxy().getPluginManager().getPlugin(pluginName);
+ if (plugin != null) {
+ core.setAuthPluginHook(
+ clazz.getDeclaredConstructor(FastLoginBungee.class).newInstance(this));
+ }
+ }
+ } catch (ReflectiveOperationException ex) {
+ logger.error("Couldn't load the auth hook class", ex);
}
}
diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeAuthHook.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeAuthHook.java
index cb22a6ee..abddb172 100644
--- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeAuthHook.java
+++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeAuthHook.java
@@ -25,6 +25,7 @@
*/
package com.github.games647.fastlogin.bungee.hook;
+import com.github.games647.fastlogin.bungee.FastLoginBungee;
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
import me.vik1395.BungeeAuth.Main;
@@ -43,6 +44,9 @@ public class BungeeAuthHook implements AuthPlugin {
private final RequestHandler requestHandler = new RequestHandler();
+ public BungeeAuthHook(FastLoginBungee plugin) {
+ }
+
@Override
public boolean forceLogin(ProxiedPlayer player) {
String playerName = player.getName();
diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeCordAuthenticatorHook.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeCordAuthenticatorBungeeHook.java
similarity index 85%
rename from bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeCordAuthenticatorHook.java
rename to bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeCordAuthenticatorBungeeHook.java
index 2af0a6e6..beb56d96 100644
--- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeCordAuthenticatorHook.java
+++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeCordAuthenticatorBungeeHook.java
@@ -27,15 +27,13 @@ package com.github.games647.fastlogin.bungee.hook;
import java.sql.SQLException;
+import com.github.games647.fastlogin.bungee.FastLoginBungee;
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
-import org.slf4j.Logger;
-
import de.xxschrandxx.bca.bungee.BungeeCordAuthenticatorBungee;
import de.xxschrandxx.bca.bungee.api.BungeeCordAuthenticatorBungeeAPI;
import net.md_5.bungee.api.connection.ProxiedPlayer;
-import net.md_5.bungee.api.plugin.Plugin;
/**
* GitHub:
@@ -45,14 +43,14 @@ import net.md_5.bungee.api.plugin.Plugin;
*
* Spigot: https://www.spigotmc.org/resources/bungeecordauthenticator.87669/
*/
-public class BungeeCordAuthenticatorHook implements AuthPlugin {
+public class BungeeCordAuthenticatorBungeeHook implements AuthPlugin {
public final BungeeCordAuthenticatorBungeeAPI api;
- public BungeeCordAuthenticatorHook(Plugin plugin, Logger logger) {
- BungeeCordAuthenticatorBungee bcab = (BungeeCordAuthenticatorBungee) plugin;
- api = bcab.getAPI();
- logger.info("BungeeCordAuthenticatorHook | Hooked successful!");
+ public BungeeCordAuthenticatorBungeeHook(FastLoginBungee plugin) {
+ api = ((BungeeCordAuthenticatorBungee) plugin.getProxy().getPluginManager()
+ .getPlugin("BungeeCordAuthenticatorBungee")).getAPI();
+ plugin.getLog().info("BungeeCordAuthenticatorHook | Hooked successful!");
}
@Override
From fb98dd839393257035d17e707fee657a46710f57 Mon Sep 17 00:00:00 2001
From: InkerBot <2924657226@qq.com>
Date: Tue, 6 Apr 2021 22:07:26 +0800
Subject: [PATCH 06/10] Void "Hook" in plugin name
---
.../games647/fastlogin/bukkit/task/DelayedAuthHook.java | 4 ++--
.../com/github/games647/fastlogin/bungee/FastLoginBungee.java | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/DelayedAuthHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/DelayedAuthHook.java
index 22205b66..509811e0 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/DelayedAuthHook.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/DelayedAuthHook.java
@@ -94,13 +94,13 @@ public class DelayedAuthHook implements Runnable {
private AuthPlugin getAuthHook() {
try {
- @SuppressWarnings("unchecked")
List>> hooks = Arrays.asList(AuthMeHook.class,
CrazyLoginHook.class, LogItHook.class, LoginSecurityHook.class,
SodionAuthHook.class, UltraAuthHook.class, xAuthHook.class);
for (Class extends AuthPlugin> clazz : hooks) {
- String pluginName = clazz.getSimpleName().replace("Hook", "");
+ String pluginName = clazz.getSimpleName();
+ pluginName = pluginName.substring(0, pluginName.length() - 4);
//uses only member classes which uses AuthPlugin interface (skip interfaces)
if (Bukkit.getPluginManager().isPluginEnabled(pluginName)) {
//check only for enabled plugins. A single plugin could be disabled by plugin managers
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 439877da..8f3b61cf 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
@@ -121,7 +121,8 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin> clazz : hooks) {
- String pluginName = clazz.getSimpleName().replace("Hook", "");
+ String pluginName = clazz.getSimpleName();
+ pluginName = pluginName.substring(0, pluginName.length() - 4);
//uses only member classes which uses AuthPlugin interface (skip interfaces)
Plugin plugin = getProxy().getPluginManager().getPlugin(pluginName);
if (plugin != null) {
From fd045e9ed72e49a3c4b9d34c04d8824d4f9d1576 Mon Sep 17 00:00:00 2001
From: InkerBot <2924657226@qq.com>
Date: Tue, 6 Apr 2021 22:16:27 +0800
Subject: [PATCH 07/10] Add SodionAuth softDepend
---
bukkit/src/main/resources/plugin.yml | 1 +
bungee/src/main/resources/bungee.yml | 1 +
2 files changed, 2 insertions(+)
diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml
index 80ff1602..df3b48cb 100644
--- a/bukkit/src/main/resources/plugin.yml
+++ b/bukkit/src/main/resources/plugin.yml
@@ -23,6 +23,7 @@ softdepend:
# Auth plugins
- AuthMe
- LoginSecurity
+ - SodionAuth
- xAuth
- LogIt
- UltraAuth
diff --git a/bungee/src/main/resources/bungee.yml b/bungee/src/main/resources/bungee.yml
index a5fa5aa1..c52f41a1 100644
--- a/bungee/src/main/resources/bungee.yml
+++ b/bungee/src/main/resources/bungee.yml
@@ -12,6 +12,7 @@ softDepends:
# BungeeCord auth plugins
- BungeeAuth
- BungeeCordAuthenticatorBungee
+ - SodionAuth
description: |
${project.description}
From 83a6cb4bb4e2089f33ea8c01975d3fd6f4b9c393 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A2=A8=E6=B0=B4=E7=93=B6Official?=
<77919405+InkerBot@users.noreply.github.com>
Date: Wed, 7 Apr 2021 00:11:22 +0800
Subject: [PATCH 08/10] Add log info and fix errors
---
.../com/github/games647/fastlogin/bungee/FastLoginBungee.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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 8f3b61cf..3bcfab85 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
@@ -122,10 +122,11 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin> clazz : hooks) {
String pluginName = clazz.getSimpleName();
- pluginName = pluginName.substring(0, pluginName.length() - 4);
+ pluginName = pluginName.substring(0, pluginName.length() - "Hook".length());
//uses only member classes which uses AuthPlugin interface (skip interfaces)
Plugin plugin = getProxy().getPluginManager().getPlugin(pluginName);
if (plugin != null) {
+ logger.info("Hooking into auth plugin: {}", pluginName);
core.setAuthPluginHook(
clazz.getDeclaredConstructor(FastLoginBungee.class).newInstance(this));
}
From ab1d3ded63415d443906941263c6920950a34807 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A2=A8=E6=B0=B4=E7=93=B6Official?=
<77919405+InkerBot@users.noreply.github.com>
Date: Wed, 7 Apr 2021 00:12:58 +0800
Subject: [PATCH 09/10] Fix errors
---
.../github/games647/fastlogin/bukkit/task/DelayedAuthHook.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/DelayedAuthHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/DelayedAuthHook.java
index 509811e0..c5dcc9ca 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/DelayedAuthHook.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/DelayedAuthHook.java
@@ -100,7 +100,7 @@ public class DelayedAuthHook implements Runnable {
for (Class extends AuthPlugin> clazz : hooks) {
String pluginName = clazz.getSimpleName();
- pluginName = pluginName.substring(0, pluginName.length() - 4);
+ pluginName = pluginName.substring(0, pluginName.length() - "Hook".length());
//uses only member classes which uses AuthPlugin interface (skip interfaces)
if (Bukkit.getPluginManager().isPluginEnabled(pluginName)) {
//check only for enabled plugins. A single plugin could be disabled by plugin managers
From 2c3fd4a5758b3f173699e70e192bfb1c0ca48423 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A2=A8=E6=B0=B4=E7=93=B6Official?=
<77919405+InkerBot@users.noreply.github.com>
Date: Wed, 7 Apr 2021 00:30:11 +0800
Subject: [PATCH 10/10] Return when first auth plugin found
---
.../com/github/games647/fastlogin/bungee/FastLoginBungee.java | 1 +
1 file changed, 1 insertion(+)
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 3bcfab85..7d68fb45 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
@@ -129,6 +129,7 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin