if((rsMail.size() >= id) && (id >= 1)) {
Mail m = rsMail.get(id-1);
String response = "Deleted " + constructMessage(id, rsMail.size(), m);
try {
ObjectContext context = commanderAccount.getObjectContext();
context.deleteObject(m);
commanderAccount.updateRow();
user.sendChat(response, true);
context.performQuery(new RefreshQuery(commanderAccount));
} catch(Exception e) {
throw new CommandFailedWithDetailsException("Failed to delete mail", e);
}
} else {
throw new CommandFailedWithDetailsException("You only have " + rsMail.size() + " messages!");
}
} else if(params[0].equals("empty")
||params[0].equals("clear")) {
//empty
if(params.length != 1)
throw new InvalidUseException();
if(Mail.getUnreadCount(commanderAccount) > 0)
throw new CommandFailedWithDetailsException("You have unread mail!");
try {
ObjectContext context = commanderAccount.getObjectContext();
for(Mail m : commanderAccount.getRecievedMail())
context.deleteObject(m);
commanderAccount.updateRow();
user.sendChat("Mailbox cleaned!", whisperBack);
} catch(Exception e) {
throw new CommandFailedWithDetailsException("Failed to delete mail", e);
}