Fix & Move allowFloodgateNameConflict=linked

This commit is contained in:
Smart123s
2021-05-22 17:06:16 +02:00
parent 2d5a53a2f9
commit 757d0ef991
2 changed files with 7 additions and 19 deletions

View File

@ -31,14 +31,18 @@ public class FloodgateHook {
*/
public void checkNameConflict(String username, LoginSource source, FloodgatePlayer floodgatePlayer) {
String allowConflict = plugin.getCore().getConfig().get("allowFloodgateNameConflict").toString().toLowerCase();
if (allowConflict.equals("false")) {
// check if the Bedrock player is linked to a Java account
boolean isLinked = floodgatePlayer.getLinkedPlayer() != null;
if (allowConflict.equals("false")
|| allowConflict.equals("linked") && !isLinked) {
// check for conflicting Premium Java name
Optional<Profile> premiumUUID = Optional.empty();
try {
premiumUUID = plugin.getCore().getResolver().findProfile(username);
} catch (IOException | RateLimitException e) {
e.printStackTrace();
plugin.getLog().error(
"Could not check wether Floodgate Player {}'s name conflicts a premium Java player's name.",
username);
@ -55,7 +59,6 @@ public class FloodgateHook {
try {
source.kick("Your name conflicts an existing Java Premium Player's name");
} catch (Exception e) {
e.printStackTrace();
plugin.getLog().error("Could not kick Player {}", username);
}
}

View File

@ -26,25 +26,10 @@ public class FloodgateAuthTask implements Runnable {
plugin.getLog().info(
"Player {} is connecting through Geyser Floodgate.",
player.getName());
String allowNameConflict = plugin.getCore().getConfig().get("allowFloodgateNameConflict").toString().toLowerCase();
// check if the Bedrock player is linked to a Java account
boolean isLinked = floodgatePlayer.getLinkedPlayer() != null;
if (allowNameConflict.equals("linked") && !isLinked) {
plugin.getLog().info(
"Bedrock Player {}'s name conflits an existing Java Premium Player's name",
player.getName());
// kicking must be synchronous
// https://www.spigotmc.org/threads/asynchronous-player-kick-problem.168580/
Bukkit.getScheduler().runTask(plugin, new Runnable() {
public void run() {
player.kickPlayer("This name is allready in use by a Premium Java Player");
}
});
return;
}
AuthPlugin<Player> authPlugin = plugin.getCore().getAuthPluginHook();
String autoLoginFloodgate = plugin.getCore().getConfig().get("autoLoginFloodgate").toString().toLowerCase();