PasteSite is open to the public, but with limited features. Register to be able to modify access rights, track your pastes and more...
If you prefer reading light text on a dark background to dark text on a light background, then you might want to try the dark theme.
"Untitled" by Anonymous [Java]Actions: |
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
package org.irc.channels; import java.util.ArrayList; import org.irc.apis.API_Program; public class ChannelManager { public API_Program api; public ArrayList<Channel> currentChannels; public ChannelManager(API_Program api) { this.api = api; this.currentChannels = new ArrayList<Channel>(); } public void addChannel(String name) { name = api.removeColon(name); this.currentChannels.add( new Channel ( this.api, name ) ); } public void removeChannel(String name) { name = api.removeColon(name); Channel c = getChannelFromName(name); if ( c == null ) { return; } else { this.currentChannels.remove(c); } } public void setTopicForChannel (String name, String topic ) { name = api.removeColon(name); for ( Channel aChannel : this.currentChannels ) { if ( aChannel.name.equals(name) ) { aChannel.setTopic(topic); api.logAddLine("Topic changed in " + name, 2); break; } } } public void setTopicInfoForChannel(String name, String who, String when) { name = api.removeColon(name); for ( Channel aChannel : this.currentChannels ) { if ( aChannel.name.equals(name) ) { aChannel.setTopicSetterInfo(who, when); break; } } } public void processJoin (String uih, String channel) { channel = api.removeColon(channel); String nick = uih.substring(0, uih.indexOf("!")); if ( api.getNickname().equals(nick) ) { api.logAddLine("Bot joined " + channel,2); addChannel(channel); } else { //another user. Channel c = getChannelFromName(channel); c.processUserJoin(nick); } } public boolean processOnJoinUserList ( String channel, String users[] ) { Channel c = getChannelFromName(channel); if ( c == null ) { return false; } else { c.setUsersInChannel(users); return true; } } public void processPart(String uih, String channel) { channel = api.removeColon(channel); String nick = uih.substring(0, uih.indexOf("!")); if ( api.getNickname().equals(nick) ) { api.logAddLine("Bot parted " + channel,2); removeChannel(channel); } else { //another user. Channel c = getChannelFromName(channel); if ( c != null ) { c.processUserPart(nick); } } } public boolean processQuit( String userhost ) { boolean result = false; String nick = userhost.substring(0, userhost.indexOf("!")); for ( Channel c : this.currentChannels ) { if ( c.processUserPart(nick) ) { result = true; api.requestNamesForChannel(c.name); } } return result; } public String getUserListForChannel ( String channel ) { Channel c = getChannelFromName(channel); if ( c == null ) { return "error"; } else { return c.getUserList(); } } public int getPopulationForChannel ( String name ) { Channel c = getChannelFromName(name); if ( c == null ) { return 0; } else { return c.getPopulation(); } } private Channel getChannelFromName ( String name ) { for ( Channel aChannel : this.currentChannels ) { if ( aChannel.name.equals(name) ) { return aChannel; } } return null; } public void processNickChange(String nick, String newnick) { for ( Channel c : this.currentChannels ) { if ( c.processNickChange (nick, newnick) ) { api.requestNamesForChannel(c.name); } } } public void performHouseKeeping () { for ( Channel c : this.currentChannels ) { c.performHouseKeeping(); } } } |