FastBow Check (Without Anti-Cheat Core) Giving False Positives

Discussion in 'Plugin Development' started by Supergrupgr, Apr 22, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    Supergrupgr

    So I made this check for fastbow, which has given too many false positives, but when you think logically, that shouldnt be possible at ALL, because no where in the code is it wrong, when you draw your bow it waits 1/4 of a second & then adds you to an array list, if you shoot @ full force (which takes 1 second to draw for) without being in the array list it kicks you, this shouldnt happen @ all, & I am not capable of fixing it myself because I see no error, does anyone know how to improve it? I'm not asking to be spoonfed, just a basic understanding of what I did wrong, what I should use, what to possibly avoid.

    Code:
    Code:
        ArrayList<String> drawing = new ArrayList<String>();
    
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent e) {
            if (e.getAction() == Action.RIGHT_CLICK_AIR) {
                if (e.getPlayer().getItemInHand().getType().equals(Material.BOW)) {
                    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
                        public void run() {
                            drawing.add(e.getPlayer().getName());
                        }
                    }, 5);
                }
            }
    
        }
    
        @EventHandler
        public void onShoot(EntityShootBowEvent e) {
            if (e.getEntity() instanceof Player) {
                Player p = (Player) e.getEntity();
                if (e.getForce() == 1.0 || e.getForce() > 1.0) {
                    if (!(drawing.contains(e.getEntity().getName()))) {
                        p.kickPlayer("§aKicked by §bAntiCaffeine\n§aReason: §bFastbow");
                    } else {
                        drawing.remove(e.getEntity().getName());
                    }
                } else {
                    if (drawing.contains(e.getEntity().getName())) {
                        drawing.remove(e.getEntity().getName());
                    }
                }
            }
        }
    
        @EventHandler
        public void onChangeSlot(PlayerItemHeldEvent e) {
            if (drawing.contains(e.getPlayer().getName())) {
                drawing.remove(e.getPlayer().getName());
            }
        }
        @EventHandler
        public void join(PlayerJoinEvent e) {
            if (drawing.contains(e.getPlayer().getName())) {
                drawing.remove(e.getPlayer().getName());
            }
        }
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    Supergrupgr

    I could never get it to false kick me purposefully, it just happened occasionally, theres no way I could really use that to help me
     
Thread Status:
Not open for further replies.

Share This Page