var scriptName = "AutoRJ";
var scriptAuthor = "Cookie";
var scriptVersion = 1.0;

var S02PacketChat = Java.type('net.minecraft.network.play.server.S02PacketChat')

function Emo() {
    var AutoRegister = value.createBoolean("AutoRegister", true);
	var AutoLogin = value.createBoolean("AutoLogin", true);
	var AutoRegisterDouble = value.createBoolean("AutoRegisterDouble", true);
	var AutoRegisterCheck = value.createText("AutoRegisterCheck", "reg");
	var AutoRegisterCommand = value.createText("AutoRegisterCommand", "/");
	var AutoRegisterCommandText = value.createText("AutoRegisterCommandText", "reg");
	var AutoRegisterText = value.createText("AutoRegisterText", "123456789a");
	var AutoLoginCheck = value.createText("AutoLoginCheck", "login");
	var AutoLoginCommand = value.createText("AutoLoginCommand", "/");
	var AutoLoginCommandText = value.createText("AutoLoginCommandText", "login");
	var AutoLoginText = value.createText("AutoLoginText", "123456789a");
	var CheckPlayer = value.createText("CheckPlayer", ":");

    this.getName = function() {
        return "AutoRJ";
    }

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

    this.getDescription = function() {
        return "AutoRJ";
    }

	this.onUpdate = function () {
	}
	this.onPacket = function (event) {
		var packet = event.getPacket();
		if (packet instanceof S02PacketChat) {
		if (AutoRegister.get() == true) {
				if (packet.getChatComponent().getUnformattedText().contains(AutoRegisterCheck.get())) {
					if (!packet.getChatComponent().getUnformattedText().contains(CheckPlayer.get())) {
						mc.thePlayer.sendChatMessage(AutoRegisterCommand.get() + AutoRegisterCommandText.get() + " " + AutoRegisterText.get() + (AutoRegisterDouble.get() ? " " + AutoRegisterText.get() : ""))
						chat.print("§f[liquidbounce]§cfinish!")
					}
				}
			}
			if (AutoLogin.get() == true) {
				if (packet.getChatComponent().getUnformattedText().contains(AutoLoginCheck.get())) {
					if (!packet.getChatComponent().getUnformattedText().contains(CheckPlayer.get())) {
						mc.thePlayer.sendChatMessage(AutoLoginCommand.get() + AutoLoginCommandText.get() + " " + AutoLoginText.get())
						chat.print("§f[liquidbounce]§cfinish!")
					}
				}
			}
		}
	}
   	this.addValues = function (values) {
		values.add(AutoRegister);
		values.add(AutoRegisterCommand);
		values.add(AutoRegisterCommandText);
		values.add(AutoRegisterDouble);
		values.add(AutoRegisterText);
		values.add(AutoRegisterCheck);
		values.add(AutoLogin);
		values.add(AutoLoginCheck);
		values.add(AutoLoginCommand);
		values.add(AutoLoginCommandText);
		values.add(AutoLoginText);
		values.add(CheckPlayer);
	}
}

var emo = new Emo();
var emoClient;

function onEnable() {
    emoClient = moduleManager.registerModule(emo);
}

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