Tell.java

src/net/sourceforge/pain/logic/event/console/command/Tell.java · 1.3 KB

From the archive pain_0_41.zip

Download the archive   « Back to the archive contents

package net.sourceforge.pain.logic.event.console.command;

import net.sourceforge.pain.logic.event.console.*;
import net.sourceforge.pain.logic.fn.*;
import net.sourceforge.pain.data.type.*;

public final class Tell extends CommandHandler {

	public void processCommand() throws Exception {
		String text = commandParams == null ? "" : commandParams.trim();
		int spaceIndex = text.indexOf(' ');
		if (spaceIndex < 1) {
			MessageOutFn.outln(console, "Tell whom what?");
			return;
		}
		String namePrefix = text.substring(0, spaceIndex);
		text = text.substring(spaceIndex).trim();
		if (text.length() == 0) {
			MessageOutFn.out(console, "Tell what?");
			return;
		}
		Interactive target = GlobalFindFn.findInteractiveByPrefix(player, namePrefix);
		if (target == null) {
			MessageOutFn.outln(console, "They aren't here.");
			return;
		}
		Interactive pli = player.asInteractive();
		if (target == pli) {
			MessageOutFn.outln(console, "Talking to yourself, eh?");
			return;
		}
		MessageOutFn.outOne(pli, "You tell $N '{w$t{x'", text, target);
		MessageOutFn.outOne(target, "$n tells you '{w$T{x'", pli, text);
	}

	public void showHelp() {
		MessageOutFn.outln(console, command.name+":sends a message to one awake player anywhere in the world.");
	}
}

Site Stats

Snippets: 1791
Codebases: 571