Optimise GeoIP & Bump floodgate to 2.2.2-SNAPSHOT

This commit is contained in:
HaHaWTH 2023-12-02 18:45:22 +08:00
parent 1d9e1cb033
commit e0cc4e0790
2 changed files with 37 additions and 12 deletions

28
pom.xml
View File

@ -531,6 +531,30 @@
</snapshots>
</repository>
<!-- Aliyun maven central repo -->
<repository>
<id>aliyun-repo</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<!-- Tencent cloud maven central repo -->
<repository>
<id>tencent-repo</id>
<url>https://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<!-- CodeMC Repo (Contains many required libraries) -->
<repository>
<id>codemc-repo</id>
@ -598,11 +622,13 @@
<enabled>true</enabled>
</snapshots>
</repository>
<!-- FoliaLib -->
<repository>
<id>devmart-other</id>
<url>https://nexuslite.gcnt.net/repos/other/</url>
</repository>
<repository>
<id>opencollab-snapshot</id>
<url>https://repo.opencollab.dev/maven-snapshots/</url>
@ -630,7 +656,7 @@
<dependency>
<groupId>org.geysermc.floodgate</groupId>
<artifactId>api</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Jalu Injector -->

View File

@ -118,6 +118,7 @@ public class GuiCaptchaHandler implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerLogin(PlayerLoginEvent event) {
Player player = event.getPlayer();
bukkitService.runTaskAsynchronously(() -> {
sb = new StringBuilder();
int howLongIsRandomString = (howManyRandom.nextInt(3) + 1);
@ -131,8 +132,15 @@ public class GuiCaptchaHandler implements Listener {
// 将字符追加到字符串生成器
sb.append(randomChar);
}
if (!whiteList.isEmpty()) {
String ip = getPlayerIp(player);
if (whiteList.contains(authmeApi.getCountryCode(ip)) && ip != null) {
if (!closeReasonMap.containsKey(player)) {
closeReasonMap.put(player, "verified:whitelist");
}
}
}
});
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
@ -140,16 +148,7 @@ public class GuiCaptchaHandler implements Listener {
randomString = "";
Player playerunreg = event.getPlayer();
String name = playerunreg.getName();
if (!authmeApi.isRegistered(name) && !isNpc(playerunreg)) {
if (!whiteList.isEmpty()) {
String ip = getPlayerIp(playerunreg);
if (whiteList.contains(authmeApi.getCountryCode(ip)) && ip != null) {
if (!closeReasonMap.containsKey(playerunreg)) {
closeReasonMap.put(playerunreg, "verified:whitelist");
}
return;
}
}
if (!authmeApi.isRegistered(name) && !isNpc(playerunreg) && !closeReasonMap.containsKey(playerunreg)) {
if (isBedrockPlayer(playerunreg.getUniqueId())) {
if (!closeReasonMap.containsKey(playerunreg)) {
closeReasonMap.put(playerunreg, "verified:bedrock");