/*
 * Copyright (c) 2016 MCPhoton <http://mcphoton.org> and contributors.
 *
 * This file is part of the Photon Server Implementation <https://github.com/mcphoton/Photon-Server>.
 *
 * The Photon Server Implementation is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * The Photon Server Implementation is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.mcphoton.impl.server;

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

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

	/**
	 * The world currently used for the command registry.
	 */
	public volatile World world;

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

	public ConsoleThread() {
		super("console");
	}

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

	@Override
	public void run() {
		world = Photon.getServer().getConfiguration().getSpawnLocation().getWorld();
		while (run) {
			String line = sc.nextLine();
			String[] parts = line.split(" ", 2);
			Command cmd = world.getCommandRegistry().getRegisteredCommand(parts[0]);
			if (cmd == null) {
				System.out.println("Unknown command.");
				continue;
			}
			if (parts.length == 1) {
				cmd.execute(this, new String[0]);
			} else {
				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());
	}

}

@@ -919,16 +919,82 @@
 erver;%0A%0A
+import com.electronwill.utils.StringUtils;%0Aimport java.util.List;%0A
 import j
@@ -1200,19 +1200,16 @@
 d;%0A%0A/**%0A
- *%0A
  * @auth
@@ -1298,17 +1298,16 @@
 eable %7B%0A
-%0A
 %09/**%0A%09 *
@@ -1393,17 +1393,16 @@
  world;%0A
-%0A
 %09private
@@ -1832,16 +1832,20 @@
 %0A%09%09%09
+List%3C
 String
-%5B%5D
+%3E
  par
@@ -1853,25 +1853,35 @@
 s = 
-line.split(%22 %22, 2
+StringUtils.split(line, ' '
 );%0A%09
@@ -1949,19 +1949,23 @@
 nd(parts
-%5B0%5D
+.get(0)
 );%0A%09%09%09if
@@ -2051,17 +2051,67 @@
 %0A%09%09%09
-if (parts
+String%5B%5D array = new String%5Bparts.size() - 1%5D;%0A%09%09%09if (array
 .len
@@ -2117,17 +2117,17 @@
 ngth == 
-1
+0
 ) %7B%0A%09%09%09%09
@@ -2203,11 +2203,52 @@
 arts
-%5B1%5D
+.subList(1, parts.size() - 1).toArray(array)
 );%0A%09
@@ -2453,7 +2453,5 @@
 %0A%09%7D%0A
-%0A%7D%0A
+%7D

Use StringUtils.split in ConsoleThread