Начинающий
			
			
				
					
				
			
		Начинающий
		- Статус
- Оффлайн
- Регистрация
- 27 Май 2024
- Сообщения
- 10
- Реакции
- 0
			
				AntiBot:
			
		
		
		@Annotation(name = "AntiBot", type = Type.Combat)
public class AntiBot extends Function {
    private final Set<UUID> susPlayers = new ConcurrentSet<>();
    private static final Map<UUID, Boolean> botsMap = new HashMap<>();
    @Override
    public Item onEvent(Event event) {
        if (event instanceof EventUpdate) {
            for (UUID susPlayer : susPlayers) {
                PlayerEntity entity = mc.world.getPlayerByUuid(susPlayer);
                if (entity != null) {
                    Iterator<ItemStack> armor = entity.getArmorInventoryList().iterator();
                    int count = 0;
                    while (armor.hasNext()) {
                        ItemStack current = armor.next();
                        if (!current.isEmpty()) {
                            count++;
                        }
                    }
                    boolean isFullArmor = count == 4;
                    count = 0;
                    for (NetworkPlayerInfo networkPlayerInfo : mc.player.connection.getPlayerInfoMap()) {
                        GameProfile profile = networkPlayerInfo.getGameProfile();
                        if (entity.getGameProfile().getName().equals(profile.getName())) {
                            count++;
                        }
                    }
                    boolean isBot = isFullArmor || !entity.getUniqueID().equals(PlayerEntity.getOfflineUUID(entity.getGameProfile().getName()));
                    botsMap.put(susPlayer, isBot);
                }
                susPlayers.remove(susPlayer);
            }
        }
        if (event instanceof EventPacket e) {
            if (e.getPacket() instanceof SPlayerListItemPacket p) {
                if (p.getAction() == SPlayerListItemPacket.Action.ADD_PLAYER) {
                    for (SPlayerListItemPacket.AddPlayerData entry : p.getEntries()) {
                        GameProfile profile = entry.getProfile();
                        if (botsMap.containsKey(profile.getId()) || susPlayers.contains(profile.getId())) {
                            continue;
                        }
                        boolean isInvalid = profile.getProperties().isEmpty() && entry.getPing() != 0;
                        if (isInvalid) {
                            susPlayers.add(profile.getId());
                        }
                    }
                }
            }
        }
        return null;
    }
    public static boolean isBot(Entity entity) {
        return entity instanceof PlayerEntity && botsMap.getOrDefault(entity.getUniqueID(), false);
    }
    public static boolean isBotU(Entity entity) {
        if (!entity.getUniqueID().equals(PlayerEntity.getOfflineUUID(entity.getName().getString()))) {
            return entity.isInvisible();
        }
        return false;
    }
    @Override
    public void onDisable() {
        super.onDisable();
        botsMap.clear();
    }
} 
				 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		