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 target = commandParams == null ? "" : commandParams.trim();
if (target.length() == 0) {
MessageOutFn.outln(console, "Goto where?");
return;
}
Player p = GlobalFindFn.findActivePlayerByName(target);
Space targetSpace;
if (p != null) {
targetSpace = p.getLocation();
} else {
IndexedSpace indexedSpace = Core.getWorld().getIndexedSpacesRegistry().getSpace(target);
if (indexedSpace == null) {
MessageOutFn.outln(console, "No such location!");
return;
}
targetSpace = indexedSpace.asSpace();
}
MessageOutFn.outSpace(player, "$n leaves room", player);
// Log.debug("setting location from:"+space.getVnum()+" to :"+targetSpace.getVnum());
final Located located = player.asLocated();
if (targetSpace != located.getLocation()) {
RelocateFn.relocate(located, targetSpace);
}
ShowFn.showSpace(player.asReceptive(), targetSpace);
MessageOutFn.outSpace(located, "$n arrives", player);
}
public void showHelp() {
MessageOutFn.outln(console, command.name + ": moves you to the specified unique space or player");
}
}