summaryrefslogtreecommitdiffstats
path: root/EssentialsUpdate/src/f00f/net/irc/martyr/errors/NickInUseError.java
blob: 93e37b4a424e81df82db49e3929c7f0824023808 (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
/*
 * Original version: Ben Damm <bdamm@dammfine.com>
 * Changes by: Mog
 * 	- Retains the nick that is in use
 * 	*/
package f00f.net.irc.martyr.errors;

import f00f.net.irc.martyr.InCommand;
import f00f.net.irc.martyr.State;
import f00f.net.irc.martyr.util.FullNick;

/**
 * Code: 433 ERR_ERRONEUSNICKNAME
 * &lt;nick&gt; :Nickname is already in use
 * Returned when a NICK message is processed that result in an attempt to change
 * to a currently existing nickname.
 * TODO: Should we rename this to NicknameInUseError for consistency with rest of errors/matching RFC?
 */
public class NickInUseError extends GenericError
{
    private FullNick _nick;
    String errorMessage;

    public NickInUseError()
    {
        _nick = null;
    }
    public NickInUseError(FullNick nick, String errorMessage)
    {
        _nick = nick;
        this.errorMessage = errorMessage;
    }

    public State getState()
    {
        return State.UNKNOWN;
    }

    public String getIrcIdentifier()
    {
        return "433";
    }

    public InCommand parse( String prefix, String identifier, String params )
    {
        return new NickInUseError(new FullNick(getParameter(params, 1)), getParameter(params, 2));
    }

    /**
     * @return The nick in use.
     */
    public FullNick getNick()
    {
        return _nick;
    }

    public String getErrorMessage()
    {
        return errorMessage;
    }

}