BC_Remove.java

mudlibs/tinylib/src/net/sourceforge/pain/tinylib/logic/event/console/command/builder/BC_Remove.java · 1.8 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.builder;

import net.sourceforge.pain.data.role.*;
import net.sourceforge.pain.tinylib.*;
import net.sourceforge.pain.tinylib.logic.fn.*;

/**
 * PAiN  Date: 05.06.2003  Time: 1:40:02
 */
public final class BC_Remove extends BuilderCommand {

    public void processBuilderCommand(BuilderShell p, String args) throws Exception {
        Prototype role = p.builder.getEditedRole();
        if (role == null) {
            MessageOutFn.outln(p.console, "No active role found!");
        } else if (args == null) {
            showHelp(p.console);
        } else {
            args = args.trim();
            try {
                Class protoClass = Class.forName("net.sourceforge.pain.data.prototype." + args);
                if (!role.is(protoClass)) {
                    MessageOutFn.outln(p.console, "Role not found in active prototype:" + args);
                } else if (protoClass == PrototypeInfo.class) {
                    MessageOutFn.outln(p.console, "PrototypeInfo can't not be removed!");
                } else {
                    if (role.getClass() == protoClass) {
                        p.builder.setEditedRole((Prototype) role.getRole(PrototypeInfo.class));
                    }
                    role.removeRole(protoClass);
                    MessageOutFn.outln(p.console, "Role Removed:" + protoClass.getName());
                }
            } catch (ClassNotFoundException e) {
                MessageOutFn.outln(p.console, "No prototype found with name:" + args);
            }
        }
    }

    public void showHelp(Console console) {
        MessageOutFn.outln(console, "Builder command REMOVE removes specified role from the active prototype");
        MessageOutFn.outln(console, "Usage: remove <Prototype_Role_Name>");
    }

}



Site Stats

Snippets: 1791
Codebases: 571