|
@@ -27,6 +27,7 @@ import com.dmdirc.parser.interfaces.LocalClientInfo;
|
27
|
27
|
import com.dmdirc.parser.interfaces.Parser;
|
28
|
28
|
|
29
|
29
|
import java.util.ArrayList;
|
|
30
|
+import java.util.Collection;
|
30
|
31
|
import java.util.HashMap;
|
31
|
32
|
import java.util.LinkedList;
|
32
|
33
|
import java.util.List;
|
|
@@ -46,7 +47,7 @@ public class IRCClientInfo implements LocalClientInfo {
|
46
|
47
|
/** Known host of client. */
|
47
|
48
|
private String host = "";
|
48
|
49
|
/** Known user modes of client. */
|
49
|
|
- private long modes;
|
|
50
|
+ private String modes;
|
50
|
51
|
/** Known Away Reason of client. */
|
51
|
52
|
private String awayReason = "";
|
52
|
53
|
/** Known Account name of client. */
|
|
@@ -64,7 +65,7 @@ public class IRCClientInfo implements LocalClientInfo {
|
64
|
65
|
/** List of ChannelClientInfos that point to this. */
|
65
|
66
|
private final Map<String, IRCChannelClientInfo> clients = new HashMap<>();
|
66
|
67
|
/** Modes waiting to be sent to the server. */
|
67
|
|
- private final List<String> modeQueue = new LinkedList<>();
|
|
68
|
+ private final Collection<String> modeQueue = new LinkedList<>();
|
68
|
69
|
|
69
|
70
|
/**
|
70
|
71
|
* Create a new client object from a hostmask.
|
|
@@ -136,7 +137,6 @@ public class IRCClientInfo implements LocalClientInfo {
|
136
|
137
|
*/
|
137
|
138
|
public static String[] parseHostFull(final String hostmask) {
|
138
|
139
|
String[] sTemp;
|
139
|
|
- final String[] result = new String[3];
|
140
|
140
|
|
141
|
141
|
if (!hostmask.isEmpty() && hostmask.charAt(0) == ':') {
|
142
|
142
|
sTemp = hostmask.substring(1).split("@", 2);
|
|
@@ -144,6 +144,7 @@ public class IRCClientInfo implements LocalClientInfo {
|
144
|
144
|
sTemp = hostmask.split("@", 2);
|
145
|
145
|
}
|
146
|
146
|
|
|
147
|
+ final String[] result = new String[3];
|
147
|
148
|
result[2] = sTemp.length == 1 ? "" : sTemp[1];
|
148
|
149
|
sTemp = sTemp[0].split("!", 2);
|
149
|
150
|
result[1] = sTemp.length == 1 ? "" : sTemp[1];
|
|
@@ -193,7 +194,7 @@ public class IRCClientInfo implements LocalClientInfo {
|
193
|
194
|
*/
|
194
|
195
|
@Override
|
195
|
196
|
public String toString() {
|
196
|
|
- return nickname + "!" + ident + "@" + host;
|
|
197
|
+ return nickname + '!' + ident + '@' + host;
|
197
|
198
|
}
|
198
|
199
|
|
199
|
200
|
/**
|
|
@@ -206,7 +207,7 @@ public class IRCClientInfo implements LocalClientInfo {
|
206
|
207
|
public String getNickname() {
|
207
|
208
|
// If this is the localClient then do what we are supposed to do, and ask
|
208
|
209
|
// the parser using parser.getNickname()
|
209
|
|
- if (this.equals(parser.getLocalClient())) {
|
|
210
|
+ if (equals(parser.getLocalClient())) {
|
210
|
211
|
return parser.getMyNickname();
|
211
|
212
|
} else {
|
212
|
213
|
return nickname;
|
|
@@ -295,37 +296,26 @@ public class IRCClientInfo implements LocalClientInfo {
|
295
|
296
|
}
|
296
|
297
|
|
297
|
298
|
/**
|
298
|
|
- * Set the user modes (as an integer).
|
|
299
|
+ * Set the user modes.
|
299
|
300
|
*
|
300
|
|
- * @param newMode new long representing channel modes. (Boolean only)
|
|
301
|
+ * @param newMode new string containing boolean channel modes.
|
301
|
302
|
*/
|
302
|
|
- public void setUserMode(final long newMode) {
|
|
303
|
+ public void setUserMode(final String newMode) {
|
303
|
304
|
modes = newMode;
|
304
|
305
|
}
|
305
|
306
|
|
306
|
307
|
/**
|
307
|
|
- * Get the user modes (as an integer).
|
|
308
|
+ * Get the user modes.
|
308
|
309
|
*
|
309
|
310
|
* @return long representing channel modes. (Boolean only)
|
310
|
311
|
*/
|
311
|
|
- public long getUserMode() {
|
|
312
|
+ public String getUserMode() {
|
312
|
313
|
return modes;
|
313
|
314
|
}
|
314
|
315
|
|
315
|
316
|
@Override
|
316
|
317
|
public String getModes() {
|
317
|
|
- final StringBuilder sModes = new StringBuilder("+");
|
318
|
|
- final long nChanModes = this.getUserMode();
|
319
|
|
-
|
320
|
|
- for (char cTemp : parser.userModes.keySet()) {
|
321
|
|
- final long nTemp = parser.userModes.get(cTemp);
|
322
|
|
-
|
323
|
|
- if ((nChanModes & nTemp) == nTemp) {
|
324
|
|
- sModes.append(cTemp);
|
325
|
|
- }
|
326
|
|
- }
|
327
|
|
-
|
328
|
|
- return sModes.toString();
|
|
318
|
+ return '+' + modes;
|
329
|
319
|
}
|
330
|
320
|
|
331
|
321
|
/**
|
|
@@ -336,8 +326,7 @@ public class IRCClientInfo implements LocalClientInfo {
|
336
|
326
|
* @return True/False if this client appears to be an oper
|
337
|
327
|
*/
|
338
|
328
|
public boolean isOper() {
|
339
|
|
- final String modestr = getModes();
|
340
|
|
- return modestr.indexOf('o') > -1 || modestr.indexOf('O') > -1;
|
|
329
|
+ return modes.indexOf('o') > -1 || modes.indexOf('O') > -1;
|
341
|
330
|
}
|
342
|
331
|
|
343
|
332
|
/**
|
|
@@ -389,7 +378,7 @@ public class IRCClientInfo implements LocalClientInfo {
|
389
|
378
|
|
390
|
379
|
@Override
|
391
|
380
|
public void alterMode(final boolean add, final Character mode) {
|
392
|
|
- if (isFake() || !parser.userModes.containsKey(mode)) {
|
|
381
|
+ if (isFake() || !parser.userModes.isMode(mode)) {
|
393
|
382
|
return;
|
394
|
383
|
}
|
395
|
384
|
|