package net.sourceforge.pain.logic.event.console.command;
import net.sourceforge.pain.*;
import net.sourceforge.pain.data.type.*;
import net.sourceforge.pain.logic.fn.*;
public final class Goto extends GrantedCommand {
	public void processCommand() {
		String spaceName = commandParams == null ? "" : commandParams.trim();
		if (spaceName.length() == 0) {
			MessageOutFn.outln(console, "Specify a unique room name to go to");
			return;
		}
		IndexedSpace targetSpace = Core.getWorld().getIndexedSpacesRegistry().getSpace(spaceName);
		if (targetSpace == null) {
			MessageOutFn.outln(console, "Place not found!");
		} else {
			MessageOutFn.outSpace(player, "$n leaves room", player);
			//	Log.debug("setting location from:"+space.getVnum()+" to :"+targetSpace.getVnum());
			final Space space = targetSpace.asSpace();
			final Located located = player.asLocated();
			if (space != located.getLocation()) {
				RelocateFn.relocate(located, space);
			}
			ShowFn.showSpace(player.asReceptive(), space);
			MessageOutFn.outSpace(located, "$n arrives", player);
		}
	}
	public void showHelp() {
		MessageOutFn.outln(console, command.name + ": alows you to go to the specified unique space");
	}
}