forked from TuxCoding/FastLogin
Fix & Move allowFloodgateNameConflict=linked
This commit is contained in:
@@ -31,14 +31,18 @@ public class FloodgateHook {
|
|||||||
*/
|
*/
|
||||||
public void checkNameConflict(String username, LoginSource source, FloodgatePlayer floodgatePlayer) {
|
public void checkNameConflict(String username, LoginSource source, FloodgatePlayer floodgatePlayer) {
|
||||||
String allowConflict = plugin.getCore().getConfig().get("allowFloodgateNameConflict").toString().toLowerCase();
|
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
|
// check for conflicting Premium Java name
|
||||||
Optional<Profile> premiumUUID = Optional.empty();
|
Optional<Profile> premiumUUID = Optional.empty();
|
||||||
try {
|
try {
|
||||||
premiumUUID = plugin.getCore().getResolver().findProfile(username);
|
premiumUUID = plugin.getCore().getResolver().findProfile(username);
|
||||||
} catch (IOException | RateLimitException e) {
|
} catch (IOException | RateLimitException e) {
|
||||||
e.printStackTrace();
|
|
||||||
plugin.getLog().error(
|
plugin.getLog().error(
|
||||||
"Could not check wether Floodgate Player {}'s name conflicts a premium Java player's name.",
|
"Could not check wether Floodgate Player {}'s name conflicts a premium Java player's name.",
|
||||||
username);
|
username);
|
||||||
@@ -55,7 +59,6 @@ public class FloodgateHook {
|
|||||||
try {
|
try {
|
||||||
source.kick("Your name conflicts an existing Java Premium Player's name");
|
source.kick("Your name conflicts an existing Java Premium Player's name");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
|
||||||
plugin.getLog().error("Could not kick Player {}", username);
|
plugin.getLog().error("Could not kick Player {}", username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,25 +26,10 @@ public class FloodgateAuthTask implements Runnable {
|
|||||||
plugin.getLog().info(
|
plugin.getLog().info(
|
||||||
"Player {} is connecting through Geyser Floodgate.",
|
"Player {} is connecting through Geyser Floodgate.",
|
||||||
player.getName());
|
player.getName());
|
||||||
String allowNameConflict = plugin.getCore().getConfig().get("allowFloodgateNameConflict").toString().toLowerCase();
|
|
||||||
// check if the Bedrock player is linked to a Java account
|
// check if the Bedrock player is linked to a Java account
|
||||||
boolean isLinked = floodgatePlayer.getLinkedPlayer() != null;
|
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();
|
AuthPlugin<Player> authPlugin = plugin.getCore().getAuthPluginHook();
|
||||||
|
|
||||||
String autoLoginFloodgate = plugin.getCore().getConfig().get("autoLoginFloodgate").toString().toLowerCase();
|
String autoLoginFloodgate = plugin.getCore().getConfig().get("autoLoginFloodgate").toString().toLowerCase();
|
||||||
|
Reference in New Issue
Block a user