package net.sourceforge.pain.logic.event.console.command.builder;
import net.sourceforge.pain.*;
import net.sourceforge.pain.data.*;
import net.sourceforge.pain.data.prototype.*;
import net.sourceforge.pain.logic.event.console.*;
import net.sourceforge.pain.logic.fn.*;
import net.sourceforge.pain.network.console.*;
/**
* PAiN Date: 05.06.2003 Time: 1:40:02
*/
public final class BC_New extends BuilderCommand {
public void processBuilderCommand(BuilderShell p, String args) throws Exception {
if (args != null) {
String params[] = new String[2];
ConsoleInputEvent.parseCommand(args, params);
if (params[1] != null) {
PrototypesRegistry prototypesRegistry = Core.getWorld().getPrototypesRegistry();
if (prototypesRegistry.isVnumInUse(params[0])) {
MessageOutFn.outln(p.console, "Vnum is already in use:" + params[0]);
} else {
MessageOutFn.outln(p.console, "Prototype created vnum:" + params[0] + " name:" + params[1]);
PrototypeInfo prototype = (PrototypeInfo) ObjectFactory.create(PrototypeInfo.class);
prototype.setAuthor(p.console.getPlayer().getName());
prototype.setName(params[1]);
prototype.setDesc("NONE");
prototype.setVnum(params[0]);
prototypesRegistry.registerPrototype(prototype);
p.builder.getEditedPrototypesList().add(prototype);
p.builder.setEditedRole(prototype);
}
return;
} else {
showUsage(p.console);
}
} else {
showUsage(p.console);
}
}
public void showUsage(Console console) {
MessageOutFn.outln(console, "NEW:Command syntax <VNUM> <PROTONAME>\n");
}
public void showHelp(Console console) {
MessageOutFn.outln(console, "Builder command NEW creates new prototype object and adds it to edited prototypes list");
MessageOutFn.outln(console, "Usage: new <VNUM> <PROTONAME>");
}
}