package com.aelfengard.i3.packet;
import java.util.List;
import com.aelfengard.i3.LPCUtils;
import com.aelfengard.i3.LPCMixed;
public class ErrorPacket extends I3Packet {
public static final String ROUTER_ERROR_CODE_UNKNOWN_DESTINATION_MUD = "unk-dst";
public static final String ROUTER_ERROR_CODE_NOT_YET_IMPLEMENTED = "not-imp";
public static final String ROUTER_ERROR_CODE_UNKNOWN_PACKET_TYPE = "unk-type";
public static final String ROUTER_ERROR_CODE_UNKNOWN_SOURCE_MUD = "unk-src";
public static final String ROUTER_ERROR_CODE_BAD_PACKET_FORMAT = "bad-pkt";
public static final String ROUTER_ERROR_CODE_BAD_PROTOCOL = "bad-proto";
public static final String ROUTER_ERROR_CODE_OPERATION_NOT_ALLOWED = "not-allowed";
public static final String MUD_ERROR_CODE_UNKNOWN_PACKET_TYPE = "unk-type";
public static final String MUD_ERROR_CODE_UNKNOWN_TARGET_USER = "unk-user";
public static final String MUD_ERROR_CODE_UNKNOWN_TARGET_CHANNEL = "unk-channel";
public static final String MUD_ERROR_CODE_BAD_PACKET_FORMAT = "bad-pkt";
public static final String TOKEN = "error";
private LPCMixed originatorMudName = new LPCMixed("");
private LPCMixed targetMudName = new LPCMixed("");
private LPCMixed targetUsername = new LPCMixed(null);
private LPCMixed errorCode = new LPCMixed("");
private LPCMixed errorMessage = new LPCMixed("");
private I3Packet errorPacket;
public ErrorPacket() {
super(I3Packet.Type.ERROR);
}
public ErrorPacket(List<LPCMixed> args) {
this();
originatorMudName = args.get(2);
targetMudName = args.get(4);
targetUsername = args.get(5);
errorCode = args.get(6);
errorMessage = args.get(7);
List<LPCMixed> list = args.get(8).asList();
if (list != null) {
errorPacket = I3Packet.forList(list);
}
else {
errorPacket = null;
}
}
public List<LPCMixed> toList() {
return LPCUtils.makeList(
TOKEN,
5, originatorMudName,
0, targetMudName,
targetUsername,
errorCode,
errorMessage,
errorPacket == null ? null : errorPacket.toList()
);
}
public LPCMixed getErrorCode() {
return errorCode;
}
public void setErrorCode(LPCMixed errorCode) {
this.errorCode = errorCode;
}
public LPCMixed getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(LPCMixed errorMessage) {
this.errorMessage = errorMessage;
}
public I3Packet getErrorPacket() {
return errorPacket;
}
public void setErrorPacket(I3Packet errorPacket) {
this.errorPacket = errorPacket;
}
public LPCMixed getOriginatorMudName() {
return originatorMudName;
}
public void setOriginatorMudName(LPCMixed originatorMudName) {
this.originatorMudName = originatorMudName;
}
public LPCMixed getTargetMudName() {
return targetMudName;
}
public void setTargetMudName(LPCMixed targetMudName) {
this.targetMudName = targetMudName;
}
public LPCMixed getTargetUsername() {
return targetUsername;
}
public void setTargetUsername(LPCMixed targetUsername) {
this.targetUsername = targetUsername;
}
}