var scriptName = "Speed disabler"; 
var scriptVersion = 1.1; 
var scriptAuthor = "soulplexis (Credit to Senk Ju for function)";

var colorIndex = 0;


//this function was made by Senk Ju and NOT ME  . .. . . . . . .. . . . . . .. . . . . . . . . . . .. .. . . .. . . .
function printMessage(message) {
    var availableColors = ["§7§l[§4§lLiquidBounce§7§l] §f", "§7§l[§c§lLiquidBounce§7§l] §c"];

    var color = availableColors[colorIndex];
    
    colorIndex += 1;
    if (colorIndex >= availableColors.length) {
        colorIndex = 0;
    }

    chat.print(color + message + "§r");

}
// . . . . . . . . .. . . . .. . .. . .. . . . . . .. . . .. . . . . . .. . . . . .. . . . . .. . . . . . ..  . . .

var highJump = new HighJump();
var highJumpClient;

// I figured some people might use speed and fly together so i added the exception.
var Fly = moduleManager.getModule("Fly");
var Speed = moduleManager.getModule("Speed");

function HighJump() {
	var flags = 0;
    this.getName = function() {
        return "SafeMode";
    };

    this.getDescription = function() {
        return "Disables speed if a flag is detected too many times.";
    };

    this.getCategory = function() {
        return "Movement";
    };

    this.onUpdate = function() {
		if(Fly.state == false) {
		if(mc.thePlayer.motionY == 0) {
			if(Speed.state == false) {
			printMessage(" Anticheat setback detected!");
			}
			if(Speed.state == true) {
		    printMessage(" Anticheat setback detected!");
			flags++;
			if(flags >= 3) {
				Speed.setState(false);
				printMessage(" Speed was disabled because of too many flags.");
				flags = 0;
			}
			}
		}
		}
    }
    this.onDisable = function() {
    }
}

function onLoad() {
};

function onEnable() {
    highJumpClient = moduleManager.registerModule(highJump);
};

function onDisable() {
    moduleManager.unregisterModule(highJumpClient);
};