Need Help for Anticheat

Discussion in 'Plugin Development' started by aweewee, Jan 13, 2020.

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

    aweewee

    For both the speed and noslowdown check(for blocking) in my anticheat, the check is with xzspeed, so it logs the player when they jump off the ground and when they land. This is bad because OnGround speed bypasses, no matter how fast it is. Noslowdown(while blocking) also bypasses as long as the player does not jump. How would I make it so it just takes the speed of the player constantly instead of when the player jumps?

    Noslowdown check for eating is different than blocking. This is because I made an arraylist of all minecraft foods (imported from org.bukkit.material), but you can't put swords in the arraylist, so it is a separate check. The noslowdown check for food only flags after they eat the food, not while they're eating it. I am trying to make it flag them while they are eating the food, can anyone give me a hint as to how?

    If what I just said was confusing, here's explanation video .

    NoSlowdown Check:

    Code:
    package com.bika.PAC.checks.movement;
    
    import com.bika.PAC.checks.CheckResult;
    import com.bika.PAC.checks.CheckType;
    import com.bika.PAC.checks.Level;
    import com.bika.PAC.util.Distance;
    import com.bika.PAC.util.Settings;
    import com.bika.PAC.util.User;
    
    public class NoSlowdown {
       
        private static final CheckResult PASS = new CheckResult(Level.PASSED, null, CheckType.NOSLOW);
    
        public static void registerMove(Distance d, User u) {
            double xzDist = (d.getxDiff() > d.getzDiff() ? d.getxDiff() : d.getzDiff());
            if (xzDist > Settings.MAX_XZ_EATING_SPEED && u.getFoodStarting() != null && System.currentTimeMillis() - u.getFoodStarting() > 1200)
                u.addInvalidFoodEatableCount();
        }
    
        public static CheckResult runCheck(Distance d, User u) {
            double xzDist = (d.getxDiff() > d.getzDiff() ? d.getxDiff() : d.getzDiff());
            if (u.getPlayer().isBlocking()) {
                if (xzDist > Settings.MAX_XZ_BLOCKING_SPEED)
                return new CheckResult(Level.FAILED, "", CheckType.NOSLOW);
            }
            return PASS;
        }
       
    }
    Speed Check:

    Code:
    package com.bika.PAC.checks.movement;
    
    import com.bika.PAC.checks.CheckResult;
    import com.bika.PAC.checks.CheckType;
    import com.bika.PAC.checks.Level;
    import com.bika.PAC.util.Distance;
    import com.bika.PAC.util.Settings;
    import com.bika.PAC.util.User;
    
    public class Speed {
       
        private static final CheckResult PASS = new CheckResult(Level.PASSED, null, CheckType.SPEED);
       
        public static CheckResult runCheck(Distance d, User u) {
            Double xz_speed = (d.getxDiff() > d.getzDiff() ? d.getxDiff() : d.getzDiff());
            if (xz_speed > Settings.MAX_XZ_SPEED)
                return new CheckResult(Level.FAILED, "speed =(" + xz_speed.toString() + "), MAX =(" + Settings.MAX_XZ_SPEED, CheckType.SPEED);
            return PASS;
        }
    
    }
    
     
Thread Status:
Not open for further replies.

Share This Page