This commit is contained in:
HaHaWTH 2023-11-19 11:36:42 +08:00
parent ee24cabbed
commit fcec8e41a2
2 changed files with 4 additions and 2 deletions

View File

@ -59,6 +59,7 @@ public class GuiCaptchaHandler implements Listener {
private PacketAdapter chatPacketListener; private PacketAdapter chatPacketListener;
private PacketAdapter windowPacketListener; private PacketAdapter windowPacketListener;
//define timesLeft //define timesLeft
private int timesLeft = 3; private int timesLeft = 3;
//Use ConcurrentHashMap to store player and their close reason //Use ConcurrentHashMap to store player and their close reason
@ -76,10 +77,12 @@ public class GuiCaptchaHandler implements Listener {
public GuiCaptchaHandler() { public GuiCaptchaHandler() {
} }
protected List<String> whiteList = AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_COUNTRY_WHITELIST);
private boolean isBedrockPlayer(UUID uuid) { private boolean isBedrockPlayer(UUID uuid) {
return settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && settings.getProperty(SecuritySettings.GUI_CAPTCHA_BE_COMPATIBILITY) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(uuid) && getServer().getPluginManager().getPlugin("floodgate") != null; return settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && settings.getProperty(SecuritySettings.GUI_CAPTCHA_BE_COMPATIBILITY) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(uuid) && getServer().getPluginManager().getPlugin("floodgate") != null;
} }
private void removePacketListeners() { private void removePacketListeners() {
ProtocolLibrary.getProtocolManager().removePacketListener(windowPacketListener); ProtocolLibrary.getProtocolManager().removePacketListener(windowPacketListener);
ProtocolLibrary.getProtocolManager().removePacketListener(chatPacketListener); ProtocolLibrary.getProtocolManager().removePacketListener(chatPacketListener);
@ -111,7 +114,6 @@ public class GuiCaptchaHandler implements Listener {
String name = playerunreg.getName(); String name = playerunreg.getName();
if (!authmeApi.isRegistered(name) && !isNpc(playerunreg)) { if (!authmeApi.isRegistered(name) && !isNpc(playerunreg)) {
String ip = getPlayerIp(playerunreg); String ip = getPlayerIp(playerunreg);
List<String> whiteList = settings.getProperty(SecuritySettings.GUI_CAPTCHA_COUNTRY_WHITELIST);
if (whiteList.isEmpty() || !whiteList.contains(authmeApi.getCountryCode(ip))) { if (whiteList.isEmpty() || !whiteList.contains(authmeApi.getCountryCode(ip))) {
if (isBedrockPlayer(playerunreg.getUniqueId())) { if (isBedrockPlayer(playerunreg.getUniqueId())) {
closeReasonMap.put(playerunreg, "verified"); closeReasonMap.put(playerunreg, "verified");

View File

@ -24,7 +24,7 @@ public final class SecuritySettings implements SettingsHolder {
@Comment({"Should send GUI captcha by country code whitelist?", @Comment({"Should send GUI captcha by country code whitelist?",
"If the country of the player is in this list, the captcha won't be sent."}) "If the country of the player is in this list, the captcha won't be sent."})
public static final Property<List<String>> GUI_CAPTCHA_COUNTRY_WHITELIST = public static final Property<List<String>> GUI_CAPTCHA_COUNTRY_WHITELIST =
newListProperty("3rdPartyFeature.captcha.whitelist"); newListProperty("3rdPartyFeature.captcha.whiteList");
@Comment({"Should we let Bedrock players login automatically?", @Comment({"Should we let Bedrock players login automatically?",
"(Requires hookFloodgate to be true & floodgate loaded)"}) "(Requires hookFloodgate to be true & floodgate loaded)"})