if (this.getNSPass() != null && !this.getNSPass().isEmpty())
Protocol.privmsg(this.getUID(), "NickServ@services.rizon.net", "IDENTIFY " + this.getNSPass()); // XXX
- for (String channel : this.getChannels())
- {
- Channel chan = Channel.findChannel(channel);
- if (chan == null)
- {
- chan = new Channel(channel, AcidCore.getTS());
- chan.setMode('n'); chan.setMode('t');
- }
+ for (Channel chan : this.getChannels())
Protocol.join(this, chan);
- }
}
public void joinChan(final String channel)
{
- if (this.isOnChan(channel))
- return;
-
Channel chan = Channel.findChannel(channel);
+ if (chan != null && this.isOnChan(chan))
+ return;
+
if (chan == null)
{
chan = new Channel(channel, AcidCore.getTS());
if (!Acidictive.me.isBursting())
Protocol.join(this, chan);
chan.addUser(this.getNick(), "");
- this.addChan(chan.getName(), "" + AcidCore.getTS());
+ this.addChan(chan);
}
- public void partChan(final String channel)
+ public void partChan(Channel chan)
{
- if (!this.isOnChan(channel))
+ if (!this.isOnChan(chan))
return;
- Protocol.part(this, channel);
- Channel chan = Channel.findChannel(channel);
- if (chan != null)
- chan.removeUser(this.getNick());
- this.remChan(channel);
+ Protocol.part(this, chan.getName());
+ chan.removeUser(this.getNick());
+ this.remChan(chan);
}
public void quit(final String reason)
package net.rizon.acid.core;
+import net.rizon.acid.conf.AccessPreset;
+
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;
import java.util.logging.Level;
-import net.rizon.acid.conf.AccessPreset;
-
public class User implements Comparable<User>
{
private static final Logger log = Logger.getLogger(User.class.getName());
private String flags; // Access flags
private ArrayList<String> oldNicks;
private Hashtable<String, ArrayList<Integer>> chans;
- private Hashtable<String, String> chanList;
+ private HashSet<Channel> chanList;
public User(String nick, String user, String host, String vhost, String name,
Server server, int nickTS, int conTS, String modes, String UID, String ip)
this.su = "";
oldNicks = new ArrayList<String>();
chans = new Hashtable<String, ArrayList<Integer>>();
- chanList = new Hashtable<String, String>();
+ chanList = new HashSet<Channel>();
uidMap.put(UID, this);
nickMap.put(nick.toLowerCase(), this);
public void onQuit()
{
- for (Iterator<String> it = this.getChannels().iterator(); it.hasNext();)
+ for (Iterator<Channel> it = chanList.iterator(); it.hasNext();)
{
- Channel chan = Channel.findChannel(it.next());
- if (chan == null)
- continue;
-
+ Channel chan = it.next();
chan.removeUser(this.getNick());
it.remove();
}
}
- public boolean isOnChan(String chan)
+ public boolean isOnChan(Channel chan)
{
- return chanList.get(chan.toLowerCase()) != null;
+ return chanList.contains(chan);
}
- public void addChan(String chan, String TS)
+ public void addChan(Channel chan)
{
- if (chan != null && !chan.equals(""))
- {
- if (chanList.get(chan.toLowerCase()) == null)
- chanList.put(chan.toLowerCase(), TS);
- }
+ chanList.add(chan);
}
- public void remChan(String chan)
+ public void remChan(Channel chan)
{
- if (chan != null && !chan.equals(""))
- {
- chanList.remove(chan.toLowerCase());
- }
+ chanList.remove(chan);
}
- public Set<String> getChannels()
+ public Set<Channel> getChannels()
{
- return this.chanList.keySet();
+ return this.chanList;
}
public String getChanStr()
{
- String s = "none";
+ String s = "";
- for (Iterator<String> it = chanList.keySet().iterator(); it.hasNext();)
+ for (Channel c : chanList)
{
- Channel chan = Channel.findChannel(it.next());
-
- String temp = chan.getModes(this.getNick()) + chan.getName();
- if (s.equals("none"))
- s = temp;
+ if (s.isEmpty())
+ s = c.getName();
else
- s += " " + temp;
+ s += " " + c.getName();
}
+ if (s.isEmpty())
+ s = "none";
+
return s;
}
this.setMode("-r");
- for (Iterator<String> it = this.getChannels().iterator(); it.hasNext();)
+ for (Channel chan : chanList)
{
- Channel chan = Channel.findChannel(it.next());
- if (chan == null)
- continue;
-
chan.onNick(oldnick, this.getNick());
}
}
public boolean hasMode(String mode)
{
- if (modes.indexOf(mode) != -1)
- return true;
- return false;
+ return modes.contains(mode);
}
public void setMode(String mode)
package net.rizon.acid.messages;
-import java.util.logging.Level;
-
import net.rizon.acid.core.AcidCore;
import net.rizon.acid.core.Acidictive;
import net.rizon.acid.core.Channel;
import net.rizon.acid.core.Server;
import net.rizon.acid.core.User;
+import java.util.logging.Level;
+
public class SJoin extends Message
{
public SJoin()
if (users[i] != null)
{
chan.addUser(users[i].getNick(), keep_their_modes ? getModes(u[i]) : "");
- users[i].addChan(chan.getName(), "" + ts); // wtf?
+ users[i].addChan(chan);
}
else
AcidCore.log.log(Level.WARNING, "SJOIN for nonexistant user " + stripped_user + " from " + source.getName());