package org.mcphoton.impl;

import java.util.Scanner;
import org.mcphoton.Photon;
import org.mcphoton.command.Command;
import org.mcphoton.messaging.ChatMessage;
import org.mcphoton.messaging.Messageable;

/**
 *
 * @author TheElectronWill
 */
public class ConsoleThread extends Thread implements Messageable {

	private volatile boolean run = true;
	private final Scanner sc = new Scanner(System.in);

	/**
	 * Stops this Thread nicely, as soon as possible but without any forcing.
	 */
	public void stopNicely() {
		run = false;
	}

	@Override
	public void run() {
		while (run) {
			String line = sc.nextLine();
			String[] parts = line.split(" ", 2);
			Command cmd = Photon.getCommandsRegistry().getRegistered(parts[0]);
			cmd.execute(this, parts[1]);
		}
	}

	@Override
	public void sendMessage(CharSequence msg) {
		System.out.println(msg);
	}

	@Override
	public void sendMessage(ChatMessage msg) {
		System.out.println(msg.toConsoleString());
	}

}

@@ -719,16 +719,95 @@
 ts%5B0%5D);%0A
+%09%09%09if (parts.length == 1) %7B%0A%09%09%09%09cmd.execute(this, new String%5B0%5D);%0A%09%09%09%7D else %7B%0A%09
 %09%09%09cmd.e
@@ -830,16 +830,21 @@
 ts%5B1%5D);%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%09%7D%0A%0A

Check the array length