diff options
author | snowleo <schneeleo@gmail.com> | 2011-10-12 03:14:07 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-10-12 03:14:26 +0200 |
commit | 860d446d28776ec842fa53e8e08538d4e093d6e9 (patch) | |
tree | 0c4598eae4eb8c59fd36e8312eab1b27a8018794 /EssentialsUpdate/src/f00f/net/irc/martyr/clientstate/Member.java | |
parent | 9ec398b39b0f48392a9d635041b392c7dba2ca0c (diff) | |
download | Essentials-860d446d28776ec842fa53e8e08538d4e093d6e9.tar Essentials-860d446d28776ec842fa53e8e08538d4e093d6e9.tar.gz Essentials-860d446d28776ec842fa53e8e08538d4e093d6e9.tar.lz Essentials-860d446d28776ec842fa53e8e08538d4e093d6e9.tar.xz Essentials-860d446d28776ec842fa53e8e08538d4e093d6e9.zip |
EssentialsUpdate WIP
Diffstat (limited to 'EssentialsUpdate/src/f00f/net/irc/martyr/clientstate/Member.java')
-rw-r--r-- | EssentialsUpdate/src/f00f/net/irc/martyr/clientstate/Member.java | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/clientstate/Member.java b/EssentialsUpdate/src/f00f/net/irc/martyr/clientstate/Member.java new file mode 100644 index 000000000..489f21961 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/clientstate/Member.java @@ -0,0 +1,114 @@ +package f00f.net.irc.martyr.clientstate; + +import f00f.net.irc.martyr.util.FullNick; + +/** + * <p>This class allows channels to keep track of individual users. Each + * user in the channel has a nick and has voice, ops, both, or none. + * Note that nicks can change, but the information we have about that + * person does not.</p> + * + * <p>Control over events that happen to this class can be obtained in + * a similar fashion to how control for the Channel is taken from + * ClientState.</p> + */ +public class Member +{ + + private FullNick nick; + private boolean hasOpsV = false; + private boolean hasVoiceV = false; + + /** + * <p>Strips off the leading 'at' or 'plus', sets ops or voice, and + * keeps the nick. Calls the methods <code>setVoice(...)</code> and + * <code>setOps(...)</code> from the constructor, if those conditions + * are true. The nick is set before setVoice or setOps are + * called.</p> + * + * @param nickStr Nick of member + */ + public Member( String nickStr ) + { + char first = nickStr.charAt(0); + String shortNick = nickStr.substring(1, nickStr.length() ); + if( first == '@' ) + { + nick = new FullNick( shortNick ); + setOps( true ); + } + else if( first == '+' ) + { + nick = new FullNick( shortNick ); + setVoice( true ); + } + else + { + nick = new FullNick( nickStr ); + } + } + + /** + * Does a nick-wise compare. + * + * @param member Member to compare against + * @return True or false of this member equals the other one + */ + public boolean equals( Member member ) + { + return equals( member.nick ); + } + + public boolean equals( FullNick fullNick ) + { + return nick.equals( fullNick ); + } + + public boolean equals( Object o ) + { + if( o instanceof Member ) + return equals( (Member)o ); + else if( o instanceof FullNick ) + return equals( (FullNick)o ); + else return false; + } + + public int hashCode() + { + return nick.hashCode(); + } + + public void setOps( boolean ops ) + { + hasOpsV = ops; + } + + public void setVoice( boolean voice ) + { + hasVoiceV = voice; + } + + public boolean hasOps() + { + return hasOpsV; + } + + public boolean hasVoice() + { + return hasVoiceV; + } + + public void setNick( FullNick nick ) + { + this.nick = nick; + } + + public FullNick getNick() + { + return nick; + } + +} + + + |