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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
/* */ package NET.worlds.console;
/* */
/* */ import NET.worlds.core.IniFile;
/* */ import NET.worlds.network.Galaxy;
/* */ import NET.worlds.network.NetworkObject;
/* */ import NET.worlds.network.ObjID;
/* */ import NET.worlds.network.WorldServer;
/* */ import NET.worlds.scape.Drone;
/* */ import NET.worlds.scape.FrameEvent;
/* */ import java.awt.Container;
/* */ import java.awt.Event;
/* */ import java.awt.MenuItem;
/* */ import java.awt.Window;
/* */ import java.text.MessageFormat;
/* */ import java.util.Enumeration;
/* */ import java.util.StringTokenizer;
/* */ import java.util.Vector;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class MuteListPart
/* */ implements FramePart, NameListOwner
/* */ {
/* */ private static final String oldIniItemName = "Mutes";
/* */ private static final String iniItemName = "Mute";
/* */ private static final int maxMutes = 50;
/* */ private static final String separator = ";";
/* */ private static MuteListPart active;
/* */ private Vector<String> mutes;
/* 58 */ private Vector<String> syncMutes = new Vector();
/* */
/* */
/* */
/* */ private MenuItem editItem;
/* */
/* */
/* */ private MenuItem disableWhisperItem;
/* */
/* */
/* */ private boolean rejectWhispers;
/* */
/* */
/* */ private DefaultConsole console;
/* */
/* */
/* */ private Galaxy galaxy;
/* */
/* */
/* */ private IniFile serverSection;
/* */
/* */
/* 80 */ private Object mutesMutex = new Object();
/* */
/* */
/* */
/* 84 */ private Vector<String> updates = new Vector();
/* */
/* */
/* */
/* */
/* */
/* */ private void loadMutes()
/* */ {
/* 92 */ this.mutes = new Vector();
/* */
/* */
/* 95 */ for (int i = 0; i < 50; i++) {
/* 96 */ String name = this.serverSection.getIniString("Mute" + i, "");
/* 97 */ if (name.length() == 0)
/* */ break;
/* 99 */ if ((FriendsListPart.isValidUserName(name)) &&
/* 100 */ (!FriendsListPart.icontains(this.mutes, name))) {
/* 101 */ this.mutes.addElement(name);
/* */ }
/* */ }
/* 104 */ if (this.mutes.size() == 0)
/* */ {
/* */
/* */
/* */
/* 109 */ String mutesStr = this.serverSection.getIniString("Mutes", "");
/* 110 */ StringTokenizer tokens = new StringTokenizer(mutesStr, ";");
/* 111 */ while ((tokens.hasMoreTokens()) && (this.mutes.size() < 50)) {
/* 112 */ String name = tokens.nextToken();
/* */
/* */
/* 115 */ if ((FriendsListPart.isValidUserName(name)) &&
/* 116 */ (!FriendsListPart.icontains(this.mutes, name)))
/* 117 */ this.mutes.addElement(name);
/* */ }
/* 119 */ if (this.mutes.size() != 0) {
/* 120 */ saveMutes();
/* 121 */ this.serverSection.setIniString("Mutes", "");
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */
/* */ void saveMutes()
/* */ {
/* 130 */ int count = this.mutes.size();
/* 131 */ for (int i = 0; i < count; i++)
/* 132 */ this.serverSection.setIniString("Mute" + i,
/* 133 */ (String)this.mutes.elementAt(i));
/* 134 */ this.serverSection.setIniString("Mute" + count, "");
/* */ }
/* */
/* */ private void setDisableWhisper()
/* */ {
/* 139 */ this.rejectWhispers = (IniFile.gamma().getIniInt("RejectWhispers", 0) == 1);
/* 140 */ if (this.rejectWhispers) {
/* 141 */ this.disableWhisperItem.setLabel(Console.message("Accept-Whispers"));
/* */ } else {
/* 143 */ this.disableWhisperItem.setLabel(Console.message("Reject-Whispers"));
/* */ }
/* */ }
/* */
/* */
/* */
/* */ public void activate(Console c, Container f, Console prev)
/* */ {
/* 151 */ active = this;
/* */
/* */
/* */
/* 155 */ this.console = ((DefaultConsole)c);
/* */
/* */
/* 158 */ this.editItem = c.addMenuItem(Console.message("Edit-Mute-List"), "Options");
/* 159 */ this.editItem.setEnabled(this.mutes != null);
/* */
/* */
/* 162 */ this.disableWhisperItem = c.addMenuItem(Console.message("Reject-Whispers"),
/* 163 */ "Options");
/* 164 */ setDisableWhisper();
/* */ }
/* */
/* */
/* */ public void deactivate()
/* */ {
/* 170 */ active = null;
/* 171 */ this.editItem = null;
/* */ }
/* */
/* */
/* */
/* */ public boolean action(Event event, Object what)
/* */ {
/* 178 */ if (event.target == this.editItem)
/* */ {
/* */
/* */
/* 182 */ new EditNamesDialog(this, Console.message("Edit-Mute-List"),
/* 183 */ Console.message("Add-Mute-List"));
/* 184 */ return true; }
/* 185 */ if (event.target == this.disableWhisperItem)
/* */ {
/* 187 */ IniFile.gamma().setIniInt("RejectWhispers", this.rejectWhispers ? 0 : 1);
/* 188 */ setDisableWhisper();
/* */ }
/* */
/* 191 */ return false;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public boolean handle(FrameEvent f)
/* */ {
/* 200 */ synchronized (this.mutesMutex) {
/* 201 */ int count = this.updates.size();
/* 202 */ if (count != 0) {
/* 203 */ WorldServer server = this.console.getServerNew();
/* 204 */ if (server != null) {
/* 205 */ for (int i = 0; i < count; i++) {
/* 206 */ String name = (String)this.updates.elementAt(i);
/* 207 */ boolean muted = this.mutes.contains(name);
/* */
/* */
/* */
/* 211 */ NetworkObject obj = server.getObject(new ObjID(name));
/* 212 */ if ((obj instanceof Drone)) {
/* 213 */ Drone d = (Drone)obj;
/* 214 */ d.muteStateChanged();
/* */ }
/* */
/* */
/* 218 */ this.console.getFriends().changeMuteState(name, muted);
/* */ }
/* */
/* */
/* 222 */ this.updates.removeAllElements();
/* */
/* */
/* 225 */ this.syncMutes = ((Vector)this.mutes.clone());
/* */ }
/* */ }
/* */ }
/* 229 */ return true;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public void setServer(WorldServer server, IniFile serverSection)
/* */ {
/* 240 */ this.serverSection = serverSection;
/* 241 */ this.galaxy = server.getGalaxy();
/* */
/* */
/* */
/* 245 */ loadMutes();
/* 246 */ if (this.editItem != null)
/* 247 */ this.editItem.setEnabled(true);
/* */ }
/* */
/* */ public static boolean isMuted(WorldServer server, String name) {
/* 251 */ if ((server != null) && (name != null)) {
/* 252 */ Galaxy g = server.getGalaxy();
/* 253 */ Enumeration<NetworkObject> consoleList = g.getConsoles();
/* 254 */ while (consoleList.hasMoreElements()) {
/* 255 */ Object c = consoleList.nextElement();
/* 256 */ if ((c instanceof DefaultConsole)) {
/* 257 */ MuteListPart target = ((DefaultConsole)c).getMutes();
/* 258 */ if (target.mutes != null)
/* 259 */ return FriendsListPart.icontains(target.mutes, name);
/* */ }
/* */ }
/* */ }
/* 263 */ return false;
/* */ }
/* */
/* */ public static boolean isRejecting(WorldServer server) {
/* 267 */ if (server != null) {
/* 268 */ Galaxy g = server.getGalaxy();
/* 269 */ Enumeration<NetworkObject> consoleList = g.getConsoles();
/* 270 */ while (consoleList.hasMoreElements()) {
/* 271 */ Object c = consoleList.nextElement();
/* 272 */ if ((c instanceof DefaultConsole)) {
/* 273 */ MuteListPart target = ((DefaultConsole)c).getMutes();
/* 274 */ if (target.rejectWhispers)
/* 275 */ return true;
/* */ }
/* */ }
/* */ }
/* 279 */ return false;
/* */ }
/* */
/* */
/* */
/* */ public int getNameListCount()
/* */ {
/* 286 */ return this.mutes.size();
/* */ }
/* */
/* */ public String getNameListName(int index)
/* */ {
/* 291 */ return (String)this.mutes.elementAt(index);
/* */ }
/* */
/* */ public void removeNameListName(int index)
/* */ {
/* 296 */ synchronized (this.mutesMutex) {
/* 297 */ String name = (String)this.mutes.elementAt(index);
/* 298 */ this.mutes.removeElementAt(index);
/* 299 */ saveMutes();
/* */
/* */
/* 302 */ if (!this.updates.contains(name)) {
/* 303 */ this.updates.addElement(name);
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */
/* */ public boolean mayAddNameListName(Window currentWindow)
/* */ {
/* 312 */ if (this.mutes.size() < 50)
/* 313 */ return true;
/* 314 */ Object[] arguments = { new String("50") };
/* 315 */ new OkCancelDialog(currentWindow, null,
/* 316 */ Console.message("Too-many-names"), null, Console.message("OK"),
/* 317 */ MessageFormat.format(Console.message("You-are-limitedM"),
/* 318 */ arguments), true);
/* */
/* */
/* 321 */ return false;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public int addNameListName(String name)
/* */ {
/* 330 */ synchronized (this.mutesMutex)
/* */ {
/* 332 */ if (name.toLowerCase().startsWith("host")) {
/* 333 */ return -1;
/* */ }
/* */
/* 336 */ int index = FriendsListPart.iindexOf(this.mutes, name);
/* 337 */ if (index != -1) {
/* 338 */ return index;
/* */ }
/* */
/* 341 */ this.mutes.addElement(name);
/* 342 */ saveMutes();
/* */
/* */
/* 345 */ if (!this.updates.contains(name)) {
/* 346 */ this.updates.addElement(name);
/* */ }
/* 348 */ return this.mutes.size() - 1;
/* */ }
/* */ }
/* */ }
/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\MuteListPart.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
|