Goto.java

mudlibs/tinylib/src/net/sourceforge/pain/tinylib/logic/event/console/command/Goto.java · 1.5 KB

From the archive pain_0_45.tgz

Download the archive   « Back to the archive contents

package net.sourceforge.pain.tinylib.logic.event.console.command;

import net.sourceforge.pain.tinylib.*;
import net.sourceforge.pain.tinylib.data.type.*;
import net.sourceforge.pain.tinylib.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 {
            Room room = Mudlib.getWorld().getRoomsRegistry().findRoom(target);
            if (room == null) {
                MessageOutFn.outln(console, "No such location!");
                return;
            }
            targetSpace = room.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");
    }
}

Site Stats

Snippets: 1791
Codebases: 571