No need to remove
This commit is contained in:
parent
8db8d0f6da
commit
c170c70639
@ -23,7 +23,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -46,7 +45,6 @@ import static org.bukkit.Bukkit.getServer;
|
||||
public class GuiCaptchaHandler implements Listener {
|
||||
//define AuthMeApi
|
||||
private final AuthMeApi authmeApi = AuthMeApi.getInstance();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
@Inject
|
||||
@ -74,7 +72,7 @@ public class GuiCaptchaHandler implements Listener {
|
||||
Random howManyRandom = new Random();
|
||||
|
||||
|
||||
int howLongIsRandomString;
|
||||
int howLongIsRandomString = (howManyRandom.nextInt(3) + 1);
|
||||
|
||||
public GuiCaptchaHandler() {
|
||||
}
|
||||
@ -85,25 +83,10 @@ public class GuiCaptchaHandler implements Listener {
|
||||
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;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
bukkitService.runTaskAsynchronously(() -> {
|
||||
randomString = "";
|
||||
howLongIsRandomString = (howManyRandom.nextInt(3) + 1);
|
||||
sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < howLongIsRandomString; i++) {
|
||||
//生成随机索引号
|
||||
int index = randomItemSet.nextInt(randomSet.length());
|
||||
|
||||
// 从字符串中获取由索引 index 指定的字符
|
||||
char randomChar = randomSet.charAt(index);
|
||||
|
||||
// 将字符追加到字符串生成器
|
||||
sb.append(randomChar);
|
||||
}
|
||||
|
||||
});
|
||||
private void removePacketListeners() {
|
||||
ProtocolLibrary.getProtocolManager().removePacketListener(windowPacketListener);
|
||||
ProtocolLibrary.getProtocolManager().removePacketListener(chatPacketListener);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -132,25 +115,29 @@ public class GuiCaptchaHandler implements Listener {
|
||||
String name = playerunreg.getName();
|
||||
if (!authmeApi.isRegistered(name) && !isNpc(playerunreg)) {
|
||||
String ip = getPlayerIp(playerunreg);
|
||||
if (whiteList.isEmpty() || !whiteList.contains(authmeApi.getCountryCode(ip))) {
|
||||
if (!whiteList.isEmpty()) {
|
||||
if (whiteList.contains(authmeApi.getCountryCode(ip))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isBedrockPlayer(playerunreg.getUniqueId())) {
|
||||
closeReasonMap.put(playerunreg, "verified");
|
||||
messages.send(playerunreg, MessageKey.GUI_CAPTCHA_VERIFIED_AUTO_BEDROCK);
|
||||
return;
|
||||
}
|
||||
bukkitService.runTaskAsynchronously(() -> {
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// howLongIsRandomString = (howManyRandom.nextInt(3) + 1);
|
||||
// for (int i = 0; i < howLongIsRandomString; i++) {
|
||||
// //生成随机索引号
|
||||
// int index = randomItemSet.nextInt(randomSet.length());
|
||||
//
|
||||
// // 从字符串中获取由索引 index 指定的字符
|
||||
// char randomChar = randomSet.charAt(index);
|
||||
//
|
||||
// // 将字符追加到字符串生成器
|
||||
// sb.append(randomChar);
|
||||
// }
|
||||
StringBuilder sb = new StringBuilder();
|
||||
howLongIsRandomString = (howManyRandom.nextInt(3) + 1);
|
||||
for (int i = 0; i < howLongIsRandomString; i++) {
|
||||
//生成随机索引号
|
||||
int index = randomItemSet.nextInt(randomSet.length());
|
||||
|
||||
// 从字符串中获取由索引 index 指定的字符
|
||||
char randomChar = randomSet.charAt(index);
|
||||
|
||||
// 将字符追加到字符串生成器
|
||||
sb.append(randomChar);
|
||||
}
|
||||
|
||||
bukkitService.runTask(() -> {
|
||||
randomString = sb.toString();
|
||||
@ -238,7 +225,6 @@ public class GuiCaptchaHandler implements Listener {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deletePlayerData(UUID playerUUID) {
|
||||
// 获取服务器的存储文件夹路径
|
||||
@ -294,8 +280,10 @@ public class GuiCaptchaHandler implements Listener {
|
||||
deleteAuthMePlayerData(playerUUID);
|
||||
}
|
||||
}, 100L);
|
||||
removePacketListeners();
|
||||
return;
|
||||
}
|
||||
removePacketListeners();
|
||||
closeReasonMap.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user