Package megamek.server.commands

Source Code of megamek.server.commands.ShowEntityCommand

/**
*
*/
package megamek.server.commands;

import megamek.common.Entity;
import megamek.server.Server;

/**
* @author dirk This command exists to print entity information to the chat
*         window, it's primarily intended for vissually impaired users.
*/

public class ShowEntityCommand extends ServerCommand {

    public ShowEntityCommand(Server server) {
        super(
                server,
                "entity",
                "print the information about a entity into the chat window. Ussage: /entity # whih would show the details for the entity numbered #.");
        // to be extended by adding /entity unit# loc# to list details on
        // locations.
    }

    /**
     * Run this command with the arguments supplied
     *
     * @see megamek.server.commands.ServerCommand#run(int, java.lang.String[])
     */
    @Override
    public void run(int connId, String[] args) {
        if (server.getGame().getOptions().booleanOption("double_blind")) {
            server.sendServerChat(connId,
                    "Sorry, this command is disabled during double blind.");
            return;
        }
        try {
            int id = Integer.parseInt(args[1]);
            Entity ent = server.getGame().getEntity(id);

            if (ent != null) {
                server.sendServerChat(connId, ent.statusToString());
            } else {
                server.sendServerChat(connId, "No such entity.");
            }
        } catch (NumberFormatException nfe) {
        } catch (NullPointerException npe) {
        } catch (IndexOutOfBoundsException ioobe) {
        }
    }

}
TOP

Related Classes of megamek.server.commands.ShowEntityCommand

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.