diff options
author | snowleo <schneeleo@gmail.com> | 2011-10-12 05:00:36 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-10-12 05:00:36 +0200 |
commit | 93128712506bb0d4d422553b0480195cfd2cc9b3 (patch) | |
tree | b43500e52a607ceca0781062ac17570fdf1d4ab7 /EssentialsUpdate/src/f00f/net/irc/martyr/commands/ChannelModeCommand.java | |
parent | 860d446d28776ec842fa53e8e08538d4e093d6e9 (diff) | |
download | Essentials-93128712506bb0d4d422553b0480195cfd2cc9b3.tar Essentials-93128712506bb0d4d422553b0480195cfd2cc9b3.tar.gz Essentials-93128712506bb0d4d422553b0480195cfd2cc9b3.tar.lz Essentials-93128712506bb0d4d422553b0480195cfd2cc9b3.tar.xz Essentials-93128712506bb0d4d422553b0480195cfd2cc9b3.zip |
Replacing martyr with Pircbot 1.5
Diffstat (limited to 'EssentialsUpdate/src/f00f/net/irc/martyr/commands/ChannelModeCommand.java')
-rw-r--r-- | EssentialsUpdate/src/f00f/net/irc/martyr/commands/ChannelModeCommand.java | 189 |
1 files changed, 0 insertions, 189 deletions
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/commands/ChannelModeCommand.java b/EssentialsUpdate/src/f00f/net/irc/martyr/commands/ChannelModeCommand.java deleted file mode 100644 index f8305852b..000000000 --- a/EssentialsUpdate/src/f00f/net/irc/martyr/commands/ChannelModeCommand.java +++ /dev/null @@ -1,189 +0,0 @@ -package f00f.net.irc.martyr.commands; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.StringTokenizer; - -import f00f.net.irc.martyr.InCommand; -import f00f.net.irc.martyr.Mode; -import f00f.net.irc.martyr.clientstate.Channel; -import f00f.net.irc.martyr.clientstate.ClientState; -import f00f.net.irc.martyr.modes.channel.AnonChannelMode; -import f00f.net.irc.martyr.modes.channel.BanMode; -import f00f.net.irc.martyr.modes.channel.ExceptionMode; -import f00f.net.irc.martyr.modes.channel.InviteMaskMode; -import f00f.net.irc.martyr.modes.channel.InviteOnlyMode; -import f00f.net.irc.martyr.modes.channel.KeyMode; -import f00f.net.irc.martyr.modes.channel.LimitMode; -import f00f.net.irc.martyr.modes.channel.ModeratedMode; -import f00f.net.irc.martyr.modes.channel.NoExtMsgMode; -import f00f.net.irc.martyr.modes.channel.OperMode; -import f00f.net.irc.martyr.modes.channel.PrivateMode; -import f00f.net.irc.martyr.modes.channel.SecretMode; -import f00f.net.irc.martyr.modes.channel.TopicLockMode; -import f00f.net.irc.martyr.modes.channel.VoiceMode; -import f00f.net.irc.martyr.util.FullNick; - -/** - * Defines the ChannelMode command. Can be used to send a Channel - * mode. For receiving, this defines which channel modes Martyr knows - * about and passes them on to the Channel object. Note that the - * actual logic of what happens when a mode arrives lies in the - * clientstate.Channel object. - */ -public class ChannelModeCommand extends ModeCommand -{ - - private String prefix; - private String channelName; - private FullNick sender; - - private List modes; - - private static HashMap<Character,Mode> modeTypes; - - /** - * For receiving a mode command. - * @param prefix Currently unused prefix string - * @param channelName Channel that the mode change is in reference to - * @param params List of params to be parsed - */ - public ChannelModeCommand( String prefix, String channelName, - StringTokenizer params ) - { - makeModes(); - - this.prefix = prefix; - this.channelName = channelName; - - modes = parseModes( modeTypes, params ); - - // System.out.println( modes ); - } - - /** - * For sending a mode discovery. - * - * @param channelName Channel that the mode change is in reference to - */ - public ChannelModeCommand( String channelName ) - { - sender = null; - this.channelName = channelName; - - // Empty list, no modes. - modes = new LinkedList(); - } - - public void makeModes() - { - if( modeTypes == null ) - { - modeTypes = new HashMap<Character,Mode>(); - - registerMode( modeTypes, new BanMode() ); - registerMode( modeTypes, new KeyMode() ); - registerMode( modeTypes, new OperMode() ); - registerMode( modeTypes, new VoiceMode() ); - registerMode( modeTypes, new LimitMode() ); - // registerMode( modeTypes, new QuietMode() ); - registerMode( modeTypes, new SecretMode() ); - registerMode( modeTypes, new PrivateMode() ); - registerMode( modeTypes, new NoExtMsgMode() ); - registerMode( modeTypes, new ExceptionMode() ); - registerMode( modeTypes, new TopicLockMode() ); - registerMode( modeTypes, new ModeratedMode() ); - registerMode( modeTypes, new InviteMaskMode() ); - registerMode( modeTypes, new InviteOnlyMode() ); - registerMode( modeTypes, new AnonChannelMode() ); - } - } - - /** - * Shouldn't be called, as ModeCommand should be responsible for parsing - * and creating this class. - */ - public InCommand parse( String prefix, String identifier, String params ) - { - throw new IllegalStateException( "Don't call this method!" ); - } - - public String render() - { - return "MODE " + channelName + renderParams(); - } - - public String renderParams() - { - Iterator modesI = modes.iterator(); - - String modes = ""; - String params = ""; - - while( modesI.hasNext() ) - { - Mode mode = (Mode)modesI.next(); - - if( mode.getSign() != Mode.Sign.NOSIGN ) - { - modes += (mode.getSign() == Mode.Sign.POSITIVE ? "+" : "-" ); - } - modes += mode.getChar(); - - if( mode.getParam() != null ) - { - // Does the parameter list already have params? - // If so, stick in a space. - if( params.length() > 0 ) - { - params += " "; - } - params += mode.getParam(); - } - } - - return modes + " " + params; - } - - public String getChannel() - { - return channelName; - } - - public FullNick getSender() - { - return sender; - } - - public String getPrefix() { - return prefix; - } - - /** - * Passes the modes on to the clientstate.Channel object. - */ - public boolean updateClientState( ClientState state ) - { - boolean changed = false; - - Iterator modesI = modes.iterator(); - Channel channel = state.getChannel( channelName ); - - while( modesI.hasNext() ) - { - Mode mode = (Mode)modesI.next(); - - channel.setMode( mode ); - - changed = true; - } - - return changed; - } - - -} - - |