summaryrefslogtreecommitdiffstats
path: root/EssentialsUpdate/src/f00f/net/irc/martyr/CommandRegister.java
blob: 2c7dca1dc162bfd65833b03a34529b5358c4a0b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package f00f.net.irc.martyr;

import java.util.Hashtable;

import f00f.net.irc.martyr.commands.*;
import f00f.net.irc.martyr.errors.*;
import f00f.net.irc.martyr.replies.*;

/**
 * CommandRegister is basically a big hashtable that maps IRC
 * identifiers to command objects that can be used as factories to
 * do self-parsing.  CommandRegister is also the central list of
 * commands.
 */
public class CommandRegister
{

    private Hashtable<String,InCommand> commands;
    public CommandRegister()
    {
        commands = new Hashtable<String,InCommand>();

        // Note that currently, we only have to register commands that
        // can be received from the server.
        new InviteCommand().selfRegister( this );
        new JoinCommand().selfRegister( this );
        new KickCommand().selfRegister( this );
        new MessageCommand().selfRegister( this );
        new ModeCommand().selfRegister( this );
        new IsonCommand().selfRegister( this );
        new NickCommand().selfRegister( this );
        new NoticeCommand().selfRegister( this );
        new PartCommand().selfRegister( this );
        new PingCommand().selfRegister( this );
        new QuitCommand().selfRegister( this );
        new TopicCommand().selfRegister( this );
        new WelcomeCommand().selfRegister( this );

        // Register errors
        new AlreadyRegisteredError().selfRegister( this );
        new CannotSendToChanError().selfRegister( this );
        new CantKillServerError().selfRegister( this );
        new ChannelBannedError().selfRegister( this );
        new ChannelInviteOnlyError().selfRegister( this );
        new ChannelLimitError().selfRegister( this );
        new ChannelWrongKeyError().selfRegister( this );
        new ChanOPrivsNeededError().selfRegister( this );
        new ErroneusNicknameError().selfRegister( this );
        new FileErrorError().selfRegister( this );
        new KeySetError().selfRegister( this );
        new LoadTooHighError().selfRegister( this );
        new NeedMoreParamsError().selfRegister( this );
        new NickCollisionError().selfRegister( this );
        new NickInUseError().selfRegister( this );
        new NoAdminInfoError().selfRegister( this );
        new NoLoginError().selfRegister( this );
        new NoMotdError().selfRegister( this );
        new NoNicknameGivenError().selfRegister( this );
        new NoOperHostError().selfRegister( this );
        new NoOriginError().selfRegister( this );
        new NoPermForHostError().selfRegister( this );
        new NoPrivilegesError().selfRegister( this );
        new NoRecipientError().selfRegister( this );
        new NoSuchChannelError().selfRegister( this );
        new NoSuchNickError().selfRegister( this );
        new NoSuchServerError().selfRegister( this );
        new NoTextToSendError().selfRegister( this );
        new NotOnChannelError().selfRegister( this );
        new NotRegisteredError().selfRegister( this );
        new PasswdMismatchError().selfRegister( this );
        new SummonDisabledError().selfRegister( this );
        new TooManyChannelsError().selfRegister( this );
        new TooManyTargetsError().selfRegister( this );
        new UModeUnknownFlagError().selfRegister( this );
        new UnknownCommandError().selfRegister( this );
        new UnknownModeError().selfRegister( this );
        new UserNotInChannelError().selfRegister( this );
        new UserOnChannelError().selfRegister( this );
        new UsersDisabledError().selfRegister( this );
        new UsersDontMatchError().selfRegister( this );
        new WasNoSuchNickError().selfRegister( this );
        new WildTopLevelError().selfRegister( this );
        new YoureBannedCreepError().selfRegister( this );

        // Register replies
        new ChannelCreationReply().selfRegister( this );
        new AwayReply().selfRegister( this );
        new ListEndReply().selfRegister( this );
        new ListReply().selfRegister( this );
        new ListStartReply().selfRegister( this );
        new LUserClientReply().selfRegister( this );
        new LUserMeReply().selfRegister( this );
        new LUserOpReply().selfRegister( this );
        new ModeReply().selfRegister( this );
        new NamesEndReply().selfRegister( this );
        new NamesReply().selfRegister( this );
        new NowAwayReply().selfRegister( this );
        new TopicInfoReply().selfRegister( this );
        new UnAwayReply().selfRegister( this );
        new WhoisChannelsReply().selfRegister( this );
        new WhoisEndReply().selfRegister( this );
        new WhoisIdleReply().selfRegister( this );
        new WhoisServerReply().selfRegister( this );
        new WhoisUserReply().selfRegister( this );
    }

    public void addCommand( String ident, InCommand command )
    {
        commands.put( ident, command );
    }

    public InCommand getCommand( String ident )
    {
        return commands.get( ident );
    }

}