From 165e5fe856df9a2acfa1017b8967cb30311f23ef Mon Sep 17 00:00:00 2001
From: Smart123s <28480228+Smart123s@users.noreply.github.com>
Date: Sat, 22 May 2021 13:45:14 +0200
Subject: [PATCH 1/8] Add 'no-conflict' option to some Floodgate config entries
---
.../bukkit/task/FloodgateAuthTask.java | 30 +++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java
index 45c74a7a..0642fd03 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java
@@ -25,10 +25,15 @@
*/
package com.github.games647.fastlogin.bukkit.task;
+import java.io.IOException;
+import java.util.Optional;
+
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.geysermc.floodgate.api.player.FloodgatePlayer;
+import com.github.games647.craftapi.model.Profile;
+import com.github.games647.craftapi.resolver.RateLimitException;
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
import com.github.games647.fastlogin.core.StoredProfile;
@@ -58,7 +63,8 @@ public class FloodgateAuthTask implements Runnable {
AuthPlugin authPlugin = plugin.getCore().getAuthPluginHook();
String autoLoginFloodgate = plugin.getCore().getConfig().get("autoLoginFloodgate").toString().toLowerCase();
- boolean autoRegisterFloodgate = plugin.getCore().getConfig().getBoolean("autoRegisterFloodgate");
+ String autoRegisterFloodgate = plugin.getCore().getConfig().get("autoRegisterFloodgate").toString().toLowerCase();
+ String allowNameConflict = plugin.getCore().getConfig().get("allowFloodgateNameConflict").toString().toLowerCase();
boolean isRegistered;
try {
@@ -70,7 +76,27 @@ public class FloodgateAuthTask implements Runnable {
return;
}
- if (!isRegistered && !autoRegisterFloodgate) {
+ //decide if checks should be made for conflicting Java player names
+ if (autoLoginFloodgate.equals("no-conflict")
+ || !isRegistered && autoRegisterFloodgate.equals("no-conflict")) {
+ // check for conflicting Premium Java name
+ Optional premiumUUID = Optional.empty();
+ try {
+ premiumUUID = plugin.getCore().getResolver().findProfile(player.getName());
+ } catch (IOException | RateLimitException e) {
+ plugin.getLog().error(
+ "Could not check wether Floodgate Player {}'s name conflits a premium Java player's name.",
+ player.getName());
+ return;
+ }
+
+ //stop execution if player's name is conflicting
+ if (premiumUUID.isPresent()) {
+ return;
+ }
+ }
+
+ if (!isRegistered && autoRegisterFloodgate.equals("false")) {
plugin.getLog().info(
"Auto registration is disabled for Floodgate players in config.yml");
return;
From dc8dd13d5b18b3901d5dab3ec4aee34957b673dd Mon Sep 17 00:00:00 2001
From: Smart123s <28480228+Smart123s@users.noreply.github.com>
Date: Sat, 22 May 2021 14:09:35 +0200
Subject: [PATCH 2/8] Expand possible values in config.yml
---
core/src/main/resources/config.yml | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml
index ecb1c44a..768b3e3a 100644
--- a/core/src/main/resources/config.yml
+++ b/core/src/main/resources/config.yml
@@ -194,9 +194,11 @@ autoLogin: true
# !!!!!!!! WARNING: FLOODGATE SUPPORT IS AN EXPERIMENTAL FEATURE !!!!!!!!
# Enabling any of these settings might lead to people gaining unauthorized access to other's accounts!
-# This enables auto login for every player connecting through Floodgate.
-# Possible values: false, true, linked
-# Linked means that only Bedrock accounts linked to a Java account will be logged in automatically
+# Automatically log in players connecting through Floodgate.
+# Possible values:
+# false: Disables auto login for every player connecting through Floodgate
+# true: Enables auto login for every player connecting through Floodgate
+# linked: Only Bedrock accounts that are linked to a Java account will be logged in automatically
# !!!!!!!! WARNING: FLOODGATE SUPPORT IS AN EXPERIMENTAL FEATURE !!!!!!!!
# Enabling this might lead to people gaining unauthorized access to other's accounts!
autoLoginFloodgate: false
@@ -225,8 +227,11 @@ autoLoginFloodgate: false
# Enabling this might lead to people gaining unauthorized access to other's accounts!
allowFloodgateNameConflict: false
-# This enables auto registering every player connecting through Floodgate.
+# Automatically register players connecting through Floodgate.
# autoLoginFloodgate must be 'true' for this to work
+# Possible values:
+# false: Disables auto registering for every player connecting through Floodgate
+# true: Enables auto registering for every player connecting through Floodgate
# !!!!!!!! WARNING: FLOODGATE SUPPORT IS AN EXPERIMENTAL FEATURE !!!!!!!!
# Enabling this might lead to people gaining unauthorized access to other's accounts!
autoRegisterFloodgate: false
From fed1e91b2802a0f906b04d86b8f436dbd45ba882 Mon Sep 17 00:00:00 2001
From: Smart123s <28480228+Smart123s@users.noreply.github.com>
Date: Sat, 22 May 2021 14:10:32 +0200
Subject: [PATCH 3/8] Document 'no-conflict' in config.yml
---
core/src/main/resources/config.yml | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml
index 768b3e3a..5164aa9c 100644
--- a/core/src/main/resources/config.yml
+++ b/core/src/main/resources/config.yml
@@ -199,6 +199,9 @@ autoLogin: true
# false: Disables auto login for every player connecting through Floodgate
# true: Enables auto login for every player connecting through Floodgate
# linked: Only Bedrock accounts that are linked to a Java account will be logged in automatically
+# no-conflict: Bedrock players will only be automatically logged in if the Mojang API reports
+# that there is no existing Premium Java MC account with their name.
+# This option can be useful if you are not using 'username-prefix' in floodgate/config.yml
# !!!!!!!! WARNING: FLOODGATE SUPPORT IS AN EXPERIMENTAL FEATURE !!!!!!!!
# Enabling this might lead to people gaining unauthorized access to other's accounts!
autoLoginFloodgate: false
@@ -228,10 +231,13 @@ autoLoginFloodgate: false
allowFloodgateNameConflict: false
# Automatically register players connecting through Floodgate.
-# autoLoginFloodgate must be 'true' for this to work
+# autoLoginFloodgate must be available for the player to use this
# Possible values:
# false: Disables auto registering for every player connecting through Floodgate
# true: Enables auto registering for every player connecting through Floodgate
+# no-conflict: Bedrock players will only be automatically registered if the Mojang API reports
+# that there is no existing Premium Java MC account with their name.
+# This option can be useful if you are not using 'username-prefix' in floodgate/config.yml
# !!!!!!!! WARNING: FLOODGATE SUPPORT IS AN EXPERIMENTAL FEATURE !!!!!!!!
# Enabling this might lead to people gaining unauthorized access to other's accounts!
autoRegisterFloodgate: false
From dbf10f47679ba273d80dadaf80c5bd9da93bc03f Mon Sep 17 00:00:00 2001
From: Smart123s <28480228+Smart123s@users.noreply.github.com>
Date: Sat, 22 May 2021 14:17:41 +0200
Subject: [PATCH 4/8] Remove unnecessary whitespaces
---
.../games647/fastlogin/bukkit/task/FloodgateAuthTask.java | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java
index 0642fd03..acc8d8a8 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java
@@ -59,7 +59,6 @@ public class FloodgateAuthTask implements Runnable {
// check if the Bedrock player is linked to a Java account
boolean isLinked = floodgatePlayer.getLinkedPlayer() != null;
-
AuthPlugin authPlugin = plugin.getCore().getAuthPluginHook();
String autoLoginFloodgate = plugin.getCore().getConfig().get("autoLoginFloodgate").toString().toLowerCase();
@@ -75,7 +74,7 @@ public class FloodgateAuthTask implements Runnable {
player.getName());
return;
}
-
+
//decide if checks should be made for conflicting Java player names
if (autoLoginFloodgate.equals("no-conflict")
|| !isRegistered && autoRegisterFloodgate.equals("no-conflict")) {
@@ -101,7 +100,7 @@ public class FloodgateAuthTask implements Runnable {
"Auto registration is disabled for Floodgate players in config.yml");
return;
}
-
+
// logging in from bedrock for a second time threw an error with UUID
StoredProfile profile = plugin.getCore().getStorage().loadProfile(player.getName());
if (profile == null) {
@@ -109,7 +108,7 @@ public class FloodgateAuthTask implements Runnable {
}
BukkitLoginSession session = new BukkitLoginSession(player.getName(), isRegistered, profile);
-
+
// enable auto login based on the value of 'autoLoginFloodgate' in config.yml
session.setVerified(autoLoginFloodgate.equals("true")
|| (autoLoginFloodgate.equals("linked") && isLinked));
From 235d7f8d8026bf5cd3d547621e1ba05fba9e5f82 Mon Sep 17 00:00:00 2001
From: Smart123s <28480228+Smart123s@users.noreply.github.com>
Date: Sat, 22 May 2021 15:49:33 +0200
Subject: [PATCH 5/8] Add 'no-conflict' as an option to config.yml value
checking
---
.../com/github/games647/fastlogin/bukkit/FastLoginBukkit.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java
index 02cf0862..74d42207 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java
@@ -256,6 +256,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin
* allowFloodgateNameConflict
* autoLoginFloodgate
+ * autoRegisterFloodgate
*
*
*
@@ -264,7 +265,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin
Date: Sat, 22 May 2021 18:23:43 +0200
Subject: [PATCH 6/8] No longer treat linked Floodgate players as conflicting
names
Since linked players inherit the name of the Java player, it'll always conflict a Java player 's name
---
.../games647/fastlogin/bukkit/task/FloodgateAuthTask.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java
index acc8d8a8..2592b064 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java
@@ -76,8 +76,11 @@ public class FloodgateAuthTask implements Runnable {
}
//decide if checks should be made for conflicting Java player names
- if (autoLoginFloodgate.equals("no-conflict")
- || !isRegistered && autoRegisterFloodgate.equals("no-conflict")) {
+ if (!isLinked &&
+ (
+ autoLoginFloodgate.equals("no-conflict")
+ || !isRegistered && autoRegisterFloodgate.equals("no-conflict"))
+ ) {
// check for conflicting Premium Java name
Optional premiumUUID = Optional.empty();
try {
From fb8780d0067864447bdb5c8b1e09ac63b7a7b649 Mon Sep 17 00:00:00 2001
From: Smart123s <28480228+Smart123s@users.noreply.github.com>
Date: Sat, 22 May 2021 21:04:35 +0200
Subject: [PATCH 7/8] Prevent duplicate name check API call
Previously: If allowFloodgateNameConflict = false or linked and either autoLoginFloodgate or
autoRegisterFloodgate is set to no-conflict and a player with a non-conflicting name
connects then there will be a double check.
---
.../games647/fastlogin/bukkit/task/FloodgateAuthTask.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java
index 2592b064..29002568 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java
@@ -76,7 +76,10 @@ public class FloodgateAuthTask implements Runnable {
}
//decide if checks should be made for conflicting Java player names
- if (!isLinked &&
+ if (!isLinked //linked players have the same name as their Java profile
+ // if allowNameConflict is 'false' or 'linked' and the player had a conflicting
+ // name, than they would have been kicked in FloodgateHook#checkNameConflict
+ && allowNameConflict.equals("true") &&
(
autoLoginFloodgate.equals("no-conflict")
|| !isRegistered && autoRegisterFloodgate.equals("no-conflict"))
From 2e83eaaa81320aaf529c2539a108f8be0adf8f5a Mon Sep 17 00:00:00 2001
From: Smart123s <28480228+Smart123s@users.noreply.github.com>
Date: Mon, 14 Jun 2021 19:42:56 +0200
Subject: [PATCH 8/8] Remove unused import
---
.../com/github/games647/fastlogin/bungee/FastLoginBungee.java | 1 -
1 file changed, 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 e26b2710..9f4a598c 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
@@ -50,7 +50,6 @@ import java.util.List;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ThreadFactory;
-import net.md_5.bungee.BungeeServerInfo;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.PendingConnection;