<commit_before>package src.io.controller;

import java.util.Scanner;
import javax.print.attribute.standard.RequestingUserName;

import src.HardCodedStrings;
import src.RunGame;
import src.enumHandler;

/**
 * Processes /commands given in the chatbox
 *
 * @author mbregg
 *
 */
class CommandMiniController {

    private KeyRemapper remap_ = null;
    private Controller cont_ = null;

    public CommandMiniController(KeyRemapper remap, Controller cont) {
        remap_ = remap;
        cont_ = cont;
    }
    private static final String man = "man";
    private static final String pwd = "<PASSWORD>";
    private static final String help = "help";
    private static final String controls = "controls";
    private static final String loadControls = "load-controls";
    private static final String saveControls = "save-controls";
    private static final String save = "save";
    private static final String load = "load";
    private static final String rebind = "rebind";
    private static final String bindings = "bindings";
    private static final String setIP = "set-ip";
    private static final String setControl = "set-control";
    private static final String setTCP = "set-tcp";

    private static final String commandKey = "/";

    public String processCommand(String foo) {
        if (!foo.startsWith(commandKey)) {
            System.err.println("This isn't a command!");
            return "Error in the CommandMini";
        }
        if (foo.startsWith(commandKey + rebind)) {
            return this.processRebind(foo);
        }
        if (foo.startsWith(commandKey + saveControls)) {
            return this.processSaveControls(foo);
        }
        if (foo.startsWith(commandKey + loadControls)) {
            return this.processLoadControls(foo);
        }
        if (foo.startsWith(commandKey + save)) {
            return this.processSave(foo);
        }
        if (foo.startsWith(commandKey + load)) {
            return this.processLoad(foo);
        }
        if (foo.startsWith(commandKey + controls)) {
            return this.processCommands();
        }
        if (foo.startsWith(commandKey + help)) {
            return this.processHelp();
        }
        if (foo.startsWith(commandKey + pwd)) {
            return System.getProperty("user.dir");
        }
        if (foo.startsWith(commandKey + "cat")) {
            return "meow";
        }
        if (foo.startsWith(commandKey + "tiger")) {
            return "ROAR!";
        }
        if (foo.startsWith(commandKey + man)) {
            return this.processManCommand(foo);
        }
        if (foo.startsWith(commandKey + bindings)) {
            return this.remap_.getBindingList();
        }
        if (foo.startsWith(commandKey + setIP)) {
            int error_code = RunGame.internet.makeConnectionUsingIP_Address(foo.split(" ")[foo.split(" ").length - 1]);
            if (error_code == 0) {
                return "Successfully connected to ip address: " + foo;
            } else {
                int error_code_2 = RunGame.internet.makeConnectionUsingIP_Address("localhost");
                if (error_code_2 == 0) {
                    return "Connection failed. Reconnecting to localhost.";
                } else {
                    RunGame.setUseInternet(false);
                    return "Something is seriously wrong with the program. Cannot connect to the internet.";
                }
            }
        }
        if (foo.startsWith(commandKey + setControl)) {
            return this.setControl(foo);
        }
        if (foo.startsWith(commandKey + setTCP)) {
            if (foo.toLowerCase().contains("n")) {
                RunGame.setUseTCP(false);
                return "TCP turned off because you said no";
            } else {
                RunGame.setUseTCP(true);
                return "TCP turned on because you didn't say no.";
            }
        }

        return "No valid command given!";
    }

    private String setControl(String foo) {
        Scanner sc = new Scanner(foo);
        String in = "";
        try {
            sc.next(); //Get rid of the command /man
            in = sc.next();
            cont_.setControlling(in);<commit_msg>Now use .equals with the command portion of the string<commit_after>package src.io.controller;

import java.util.Scanner;
import javax.print.attribute.standard.RequestingUserName;

import src.HardCodedStrings;
import src.RunGame;
import src.enumHandler;

/**
 * Processes /commands given in the chatbox
 *
 * @author mbregg
 *
 */
class CommandMiniController {

    private KeyRemapper remap_ = null;
    private Controller cont_ = null;

    public CommandMiniController(KeyRemapper remap, Controller cont) {
        remap_ = remap;
        cont_ = cont;
    }
    private static final String man = "man";
    private static final String pwd = "<PASSWORD>";
    private static final String help = "help";
    private static final String controls = "controls";
    private static final String loadControls = "load-controls";
    private static final String saveControls = "save-controls";
    private static final String save = "save";
    private static final String load = "load";
    private static final String rebind = "rebind";
    private static final String bindings = "bindings";
    private static final String setIP = "set-ip";
    private static final String setControl = "set-control";
    private static final String setTCP = "set-tcp";

    private static final String commandKey = "/";

    public String processCommand(String foo) {
    	//Firstly ensure we are dealing with a command.

        
    	 Scanner sc = new Scanner(foo);
         String command = "";
         try {
             command = sc.next();
             if (!command.startsWith(commandKey)) {
                 System.err.println("This isn't a command!");
                 return "Error in the CommandMini";
             }
             command = command.substring(1);//Strip the command key away now, we already checked that it exists.
         }finally{sc.close();}
         //invalid command send apparently, so nothing to read....
         

        if (command.equals(rebind)) {
            return this.processRebind(foo);
        }
        if (command.equals(saveControls)) {
            return this.processSaveControls(foo);
        }
        if (command.equals(loadControls)) {
            return this.processLoadControls(foo);
        }
        if (command.equals(save)) {
            return this.processSave(foo);
        }
        if (command.equals(load)) {
            return this.processLoad(foo);
        }
        if (command.equals(controls)) {
            return this.processCommands();
        }
        if (command.equals(help)) {
            return this.processHelp();
        }
        if (command.equals(pwd)) {
            return System.getProperty("user.dir");
        }
        if (command.equals("cat")) {
            return "meow";
        }
        if (command.equals("tiger")) {
            return "ROAR!";
        }
        if (command.equals(man)) {
            return this.processManCommand(foo);
        }
        if (command.equals(bindings)) {
            return this.remap_.getBindingList();
        }
        if (command.equals(setIP)) {
            int error_code = RunGame.internet.makeConnectionUsingIP_Address(foo.split(" ")[foo.split(" ").length - 1]);
            if (error_code == 0) {
                return "Successfully connected to ip address: " + foo;
            } else {
                int error_code_2 = RunGame.internet.makeConnectionUsingIP_Address("localhost");
                if (error_code_2 == 0) {
                    return "Connection failed. Reconnecting to localhost.";
                } else {
                    RunGame.setUseInternet(false);
                    return "Something is seriously wrong with the program. Cannot connect to the internet.";
                }
            }
        }
        if (command.equals(setControl)) {
            return this.setControl(foo);
        }
        if (command.equals(setTCP)) {
            if (command.toLowerCase().contains("n")) {
                RunGame.setUseTCP(false);
                return "TCP turned off because you said no";
            } else {
                RunGame.setUseTCP(true);
                return "TCP turned on because you didn't say no.";
            }
        }

        return "No valid command given!";
    }

    private String setControl(String foo) {
        Scanner sc = new Scanner(foo);
        String in = "";
        try {
            sc.next(); //Get rid of the command /man
            in = sc.next();
            cont_.setControlling(in);
{'fraction_non_alphanumeric': 0.10362694300518134, 'fraction_numerical': 0.0012665515256188831, 'mean_word_length': 1.9756766015758822, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7313692', 'n_tokens_mistral': 2297, 'n_tokens_neox': 2261, 'n_words': 634}