From 860d446d28776ec842fa53e8e08538d4e093d6e9 Mon Sep 17 00:00:00 2001 From: snowleo Date: Wed, 12 Oct 2011 03:14:07 +0200 Subject: EssentialsUpdate WIP --- .../f00f/net/irc/martyr/commands/NamesCommand.java | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 EssentialsUpdate/src/f00f/net/irc/martyr/commands/NamesCommand.java (limited to 'EssentialsUpdate/src/f00f/net/irc/martyr/commands/NamesCommand.java') diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/commands/NamesCommand.java b/EssentialsUpdate/src/f00f/net/irc/martyr/commands/NamesCommand.java new file mode 100644 index 000000000..6f0a9ed5d --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/commands/NamesCommand.java @@ -0,0 +1,77 @@ +package f00f.net.irc.martyr.commands; + +import f00f.net.irc.martyr.OutCommand; + +import java.util.List; +import java.util.ArrayList; + +/** + * Defines the NAMES command, which is used to get the members of certain channels, or all of them. + * + * @author Daniel Henninger + */ +public class NamesCommand implements OutCommand +{ + + /* List of channels we will request membership of. */ + List channels = new ArrayList(); + + /** + * No parameter passed to the NAMES command represents a request for all channels. + */ + public NamesCommand() + { + // Nothing to do + } + + /** + * Request the membership of a single channel. + * + * @param channel Channel you want to request membership of. + */ + public NamesCommand(String channel) + { + this.channels.add(channel); + } + + /** + * Request the membership of multiple channels. + * + * @param channels List of channels you want to retrieve the membership list of. + */ + public NamesCommand(List channels) + { + this.channels.addAll(channels); + } + + /** + * @see f00f.net.irc.martyr.OutCommand#render() + */ + public String render() + { + String ret = getIrcIdentifier(); + if (channels.size() > 0) { + ret = ret + " "; + Boolean isFirst = true; + for (String channel : channels) { + if (isFirst) { + ret = ret + channel; + isFirst = false; + } + else { + ret = ret + "," + channel; + } + } + } + return ret; + } + + /** + * @see f00f.net.irc.martyr.Command#getIrcIdentifier() + */ + public String getIrcIdentifier() + { + return "NAMES"; + } + +} -- cgit v1.2.3