super("read DOCUMENT", "display a specified text document");
}
public void execute(Player player, String message) {
String filename = extractArgument(message);
ReadFiles d = player.getServer().docs;
if (filename == null) {
// no arguments given -> display list of available files
StringBuilder s = new StringBuilder();
for (String file : d.getList()) {
s.append(file);
s.append(", ");
}
if (s.length() > 2) {
s.delete(s.length() - 2, s.length());
}
player.addTCaptionedMessage("Available text files", s.toString());
return;
}
String text = d.getText(filename);
if (text != null) {
player.addTCaptionedMessage("Loaded document", filename);
String[] textlines = text.split("\n");
for (String l : textlines) {