| 1 | package net.minecraft.client.stream;
|
| 2 |
|
| 3 | import com.google.common.collect.Lists;
|
| 4 | import java.util.HashMap;
|
| 5 | import java.util.HashSet;
|
| 6 | import java.util.LinkedList;
|
| 7 | import java.util.List;
|
| 8 | import java.util.ListIterator;
|
| 9 | import org.apache.logging.log4j.LogManager;
|
| 10 | import org.apache.logging.log4j.Logger;
|
| 11 | import tv.twitch.AuthToken;
|
| 12 | import tv.twitch.Core;
|
| 13 | import tv.twitch.ErrorCode;
|
| 14 | import tv.twitch.StandardCoreAPI;
|
| 15 | import tv.twitch.chat.Chat;
|
| 16 | import tv.twitch.chat.ChatBadgeData;
|
| 17 | import tv.twitch.chat.ChatChannelInfo;
|
| 18 | import tv.twitch.chat.ChatEmoticonData;
|
| 19 | import tv.twitch.chat.ChatEvent;
|
| 20 | import tv.twitch.chat.ChatRawMessage;
|
| 21 | import tv.twitch.chat.ChatTokenizationOption;
|
| 22 | import tv.twitch.chat.ChatTokenizedMessage;
|
| 23 | import tv.twitch.chat.ChatUserInfo;
|
| 24 | import tv.twitch.chat.IChatAPIListener;
|
| 25 | import tv.twitch.chat.IChatChannelListener;
|
| 26 | import tv.twitch.chat.StandardChatAPI;
|
| 27 |
|
| 28 | public class ChatController
|
| 29 | {
|
| 30 | private static final Logger LOGGER = LogManager.getLogger();
|
| 31 | protected ChatController.ChatListener field_153003_a = null;
|
| 32 | protected String field_153004_b = "";
|
| 33 | protected String field_153006_d = "";
|
| 34 | protected String field_153007_e = "";
|
| 35 | protected Core field_175992_e = null;
|
| 36 | protected Chat field_153008_f = null;
|
| 37 | protected ChatController.ChatState field_153011_i = ChatController.ChatState.Uninitialized;
|
| 38 | protected AuthToken field_153012_j = new AuthToken();
|
| 39 | protected HashMap<String, ChatController.ChatChannelListener> field_175998_i = new HashMap();
|
| 40 | protected int field_153015_m = 128;
|
| 41 | protected ChatController.EnumEmoticonMode field_175997_k = ChatController.EnumEmoticonMode.None;
|
| 42 | protected ChatController.EnumEmoticonMode field_175995_l = ChatController.EnumEmoticonMode.None;
|
| 43 | protected ChatEmoticonData field_175996_m = null;
|
| 44 | protected int field_175993_n = 500;
|
| 45 | protected int field_175994_o = 2000;
|
| 46 | protected IChatAPIListener field_175999_p = new IChatAPIListener()
|
| 47 | {
|
| 48 | public void chatInitializationCallback(ErrorCode p_chatInitializationCallback_1_)
|
| 49 | {
|
| 50 | if (ErrorCode.succeeded(p_chatInitializationCallback_1_))
|
| 51 | {
|
| 52 | ChatController.this.field_153008_f.setMessageFlushInterval(ChatController.this.field_175993_n);
|
| 53 | ChatController.this.field_153008_f.setUserChangeEventInterval(ChatController.this.field_175994_o);
|
| 54 | ChatController.this.func_153001_r();
|
| 55 | ChatController.this.func_175985_a(ChatController.ChatState.Initialized);
|
| 56 | }
|
| 57 | else
|
| 58 | {
|
| 59 | ChatController.this.func_175985_a(ChatController.ChatState.Uninitialized);
|
| 60 | }
|
| 61 |
|
| 62 | try
|
| 63 | {
|
| 64 | if (ChatController.this.field_153003_a != null)
|
| 65 | {
|
| 66 | ChatController.this.field_153003_a.func_176023_d(p_chatInitializationCallback_1_);
|
| 67 | }
|
| 68 | }
|
| 69 | catch (Exception exception)
|
| 70 | {
|
| 71 | ChatController.this.func_152995_h(exception.toString());
|
| 72 | }
|
| 73 | }
|
| 74 | public void chatShutdownCallback(ErrorCode p_chatShutdownCallback_1_)
|
| 75 | {
|
| 76 | if (ErrorCode.succeeded(p_chatShutdownCallback_1_))
|
| 77 | {
|
| 78 | ErrorCode errorcode = ChatController.this.field_175992_e.shutdown();
|
| 79 |
|
| 80 | if (ErrorCode.failed(errorcode))
|
| 81 | {
|
| 82 | String s = ErrorCode.getString(errorcode);
|
| 83 | ChatController.this.func_152995_h(String.format("Error shutting down the Twitch sdk: %s", new Object[] {s}));
|
| 84 | }
|
| 85 |
|
| 86 | ChatController.this.func_175985_a(ChatController.ChatState.Uninitialized);
|
| 87 | }
|
| 88 | else
|
| 89 | {
|
| 90 | ChatController.this.func_175985_a(ChatController.ChatState.Initialized);
|
| 91 | ChatController.this.func_152995_h(String.format("Error shutting down Twith chat: %s", new Object[] {p_chatShutdownCallback_1_}));
|
| 92 | }
|
| 93 |
|
| 94 | try
|
| 95 | {
|
| 96 | if (ChatController.this.field_153003_a != null)
|
| 97 | {
|
| 98 | ChatController.this.field_153003_a.func_176022_e(p_chatShutdownCallback_1_);
|
| 99 | }
|
| 100 | }
|
| 101 | catch (Exception exception)
|
| 102 | {
|
| 103 | ChatController.this.func_152995_h(exception.toString());
|
| 104 | }
|
| 105 | }
|
| 106 | public void chatEmoticonDataDownloadCallback(ErrorCode p_chatEmoticonDataDownloadCallback_1_)
|
| 107 | {
|
| 108 | if (ErrorCode.succeeded(p_chatEmoticonDataDownloadCallback_1_))
|
| 109 | {
|
| 110 | ChatController.this.func_152988_s();
|
| 111 | }
|
| 112 | }
|
| 113 | };
|
| 114 |
|
| 115 | public void func_152990_a(ChatController.ChatListener p_152990_1_)
|
| 116 | {
|
| 117 | this.field_153003_a = p_152990_1_;
|
| 118 | }
|
| 119 |
|
| 120 | public void func_152994_a(AuthToken p_152994_1_)
|
| 121 | {
|
| 122 | this.field_153012_j = p_152994_1_;
|
| 123 | }
|
| 124 |
|
| 125 | public void func_152984_a(String p_152984_1_)
|
| 126 | {
|
| 127 | this.field_153006_d = p_152984_1_;
|
| 128 | }
|
| 129 |
|
| 130 | public void func_152998_c(String p_152998_1_)
|
| 131 | {
|
| 132 | this.field_153004_b = p_152998_1_;
|
| 133 | }
|
| 134 |
|
| 135 | public ChatController.ChatState func_153000_j()
|
| 136 | {
|
| 137 | return this.field_153011_i;
|
| 138 | }
|
| 139 |
|
| 140 | public boolean func_175990_d(String p_175990_1_)
|
| 141 | {
|
| 142 | if (!this.field_175998_i.containsKey(p_175990_1_))
|
| 143 | {
|
| 144 | return false;
|
| 145 | }
|
| 146 | else
|
| 147 | {
|
| 148 | ChatController.ChatChannelListener chatcontroller$chatchannellistener = (ChatController.ChatChannelListener)this.field_175998_i.get(p_175990_1_);
|
| 149 | return chatcontroller$chatchannellistener.func_176040_a() == ChatController.EnumChannelState.Connected;
|
| 150 | }
|
| 151 | }
|
| 152 |
|
| 153 | public ChatController.EnumChannelState func_175989_e(String p_175989_1_)
|
| 154 | {
|
| 155 | if (!this.field_175998_i.containsKey(p_175989_1_))
|
| 156 | {
|
| 157 | return ChatController.EnumChannelState.Disconnected;
|
| 158 | }
|
| 159 | else
|
| 160 | {
|
| 161 | ChatController.ChatChannelListener chatcontroller$chatchannellistener = (ChatController.ChatChannelListener)this.field_175998_i.get(p_175989_1_);
|
| 162 | return chatcontroller$chatchannellistener.func_176040_a();
|
| 163 | }
|
| 164 | }
|
| 165 |
|
| 166 | public ChatController()
|
| 167 | {
|
| 168 | this.field_175992_e = Core.getInstance();
|
| 169 |
|
| 170 | if (this.field_175992_e == null)
|
| 171 | {
|
| 172 | this.field_175992_e = new Core(new StandardCoreAPI());
|
| 173 | }
|
| 174 |
|
| 175 | this.field_153008_f = new Chat(new StandardChatAPI());
|
| 176 | }
|
| 177 |
|
| 178 | public boolean func_175984_n()
|
| 179 | {
|
| 180 | if (this.field_153011_i != ChatController.ChatState.Uninitialized)
|
| 181 | {
|
| 182 | return false;
|
| 183 | }
|
| 184 | else
|
| 185 | {
|
| 186 | this.func_175985_a(ChatController.ChatState.Initializing);
|
| 187 | ErrorCode errorcode = this.field_175992_e.initialize(this.field_153006_d, (String)null);
|
| 188 |
|
| 189 | if (ErrorCode.failed(errorcode))
|
| 190 | {
|
| 191 | this.func_175985_a(ChatController.ChatState.Uninitialized);
|
| 192 | String s1 = ErrorCode.getString(errorcode);
|
| 193 | this.func_152995_h(String.format("Error initializing Twitch sdk: %s", new Object[] {s1}));
|
| 194 | return false;
|
| 195 | }
|
| 196 | else
|
| 197 | {
|
| 198 | this.field_175995_l = this.field_175997_k;
|
| 199 | HashSet<ChatTokenizationOption> hashset = new HashSet();
|
| 200 |
|
| 201 | switch (this.field_175997_k)
|
| 202 | {
|
| 203 | case None:
|
| 204 | hashset.add(ChatTokenizationOption.TTV_CHAT_TOKENIZATION_OPTION_NONE);
|
| 205 | break;
|
| 206 |
|
| 207 | case Url:
|
| 208 | hashset.add(ChatTokenizationOption.TTV_CHAT_TOKENIZATION_OPTION_EMOTICON_URLS);
|
| 209 | break;
|
| 210 |
|
| 211 | case TextureAtlas:
|
| 212 | hashset.add(ChatTokenizationOption.TTV_CHAT_TOKENIZATION_OPTION_EMOTICON_TEXTURES);
|
| 213 | }
|
| 214 |
|
| 215 | errorcode = this.field_153008_f.initialize(hashset, this.field_175999_p);
|
| 216 |
|
| 217 | if (ErrorCode.failed(errorcode))
|
| 218 | {
|
| 219 | this.field_175992_e.shutdown();
|
| 220 | this.func_175985_a(ChatController.ChatState.Uninitialized);
|
| 221 | String s = ErrorCode.getString(errorcode);
|
| 222 | this.func_152995_h(String.format("Error initializing Twitch chat: %s", new Object[] {s}));
|
| 223 | return false;
|
| 224 | }
|
| 225 | else
|
| 226 | {
|
| 227 | this.func_175985_a(ChatController.ChatState.Initialized);
|
| 228 | return true;
|
| 229 | }
|
| 230 | }
|
| 231 | }
|
| 232 | }
|
| 233 |
|
| 234 | public boolean func_152986_d(String p_152986_1_)
|
| 235 | {
|
| 236 | return this.func_175987_a(p_152986_1_, false);
|
| 237 | }
|
| 238 |
|
| 239 | protected boolean func_175987_a(String p_175987_1_, boolean p_175987_2_)
|
| 240 | {
|
| 241 | if (this.field_153011_i != ChatController.ChatState.Initialized)
|
| 242 | {
|
| 243 | return false;
|
| 244 | }
|
| 245 | else if (this.field_175998_i.containsKey(p_175987_1_))
|
| 246 | {
|
| 247 | this.func_152995_h("Already in channel: " + p_175987_1_);
|
| 248 | return false;
|
| 249 | }
|
| 250 | else if (p_175987_1_ != null && !p_175987_1_.equals(""))
|
| 251 | {
|
| 252 | ChatController.ChatChannelListener chatcontroller$chatchannellistener = new ChatController.ChatChannelListener(p_175987_1_);
|
| 253 | this.field_175998_i.put(p_175987_1_, chatcontroller$chatchannellistener);
|
| 254 | boolean flag = chatcontroller$chatchannellistener.func_176038_a(p_175987_2_);
|
| 255 |
|
| 256 | if (!flag)
|
| 257 | {
|
| 258 | this.field_175998_i.remove(p_175987_1_);
|
| 259 | }
|
| 260 |
|
| 261 | return flag;
|
| 262 | }
|
| 263 | else
|
| 264 | {
|
| 265 | return false;
|
| 266 | }
|
| 267 | }
|
| 268 |
|
| 269 | public boolean func_175991_l(String p_175991_1_)
|
| 270 | {
|
| 271 | if (this.field_153011_i != ChatController.ChatState.Initialized)
|
| 272 | {
|
| 273 | return false;
|
| 274 | }
|
| 275 | else if (!this.field_175998_i.containsKey(p_175991_1_))
|
| 276 | {
|
| 277 | this.func_152995_h("Not in channel: " + p_175991_1_);
|
| 278 | return false;
|
| 279 | }
|
| 280 | else
|
| 281 | {
|
| 282 | ChatController.ChatChannelListener chatcontroller$chatchannellistener = (ChatController.ChatChannelListener)this.field_175998_i.get(p_175991_1_);
|
| 283 | return chatcontroller$chatchannellistener.func_176034_g();
|
| 284 | }
|
| 285 | }
|
| 286 |
|
| 287 | public boolean func_152993_m()
|
| 288 | {
|
| 289 | if (this.field_153011_i != ChatController.ChatState.Initialized)
|
| 290 | {
|
| 291 | return false;
|
| 292 | }
|
| 293 | else
|
| 294 | {
|
| 295 | ErrorCode errorcode = this.field_153008_f.shutdown();
|
| 296 |
|
| 297 | if (ErrorCode.failed(errorcode))
|
| 298 | {
|
| 299 | String s = ErrorCode.getString(errorcode);
|
| 300 | this.func_152995_h(String.format("Error shutting down chat: %s", new Object[] {s}));
|
| 301 | return false;
|
| 302 | }
|
| 303 | else
|
| 304 | {
|
| 305 | this.func_152996_t();
|
| 306 | this.func_175985_a(ChatController.ChatState.ShuttingDown);
|
| 307 | return true;
|
| 308 | }
|
| 309 | }
|
| 310 | }
|
| 311 |
|
| 312 | public void func_175988_p()
|
| 313 | {
|
| 314 | if (this.func_153000_j() != ChatController.ChatState.Uninitialized)
|
| 315 | {
|
| 316 | this.func_152993_m();
|
| 317 |
|
| 318 | if (this.func_153000_j() == ChatController.ChatState.ShuttingDown)
|
| 319 | {
|
| 320 | while (this.func_153000_j() != ChatController.ChatState.Uninitialized)
|
| 321 | {
|
| 322 | try
|
| 323 | {
|
| 324 | Thread.sleep(200L);
|
| 325 | this.func_152997_n();
|
| 326 | }
|
| 327 | catch (InterruptedException var2)
|
| 328 | {
|
| 329 | ;
|
| 330 | }
|
| 331 | }
|
| 332 | }
|
| 333 | }
|
| 334 | }
|
| 335 |
|
| 336 | public void func_152997_n()
|
| 337 | {
|
| 338 | if (this.field_153011_i != ChatController.ChatState.Uninitialized)
|
| 339 | {
|
| 340 | ErrorCode errorcode = this.field_153008_f.flushEvents();
|
| 341 |
|
| 342 | if (ErrorCode.failed(errorcode))
|
| 343 | {
|
| 344 | String s = ErrorCode.getString(errorcode);
|
| 345 | this.func_152995_h(String.format("Error flushing chat events: %s", new Object[] {s}));
|
| 346 | }
|
| 347 | }
|
| 348 | }
|
| 349 |
|
| 350 | public boolean func_175986_a(String p_175986_1_, String p_175986_2_)
|
| 351 | {
|
| 352 | if (this.field_153011_i != ChatController.ChatState.Initialized)
|
| 353 | {
|
| 354 | return false;
|
| 355 | }
|
| 356 | else if (!this.field_175998_i.containsKey(p_175986_1_))
|
| 357 | {
|
| 358 | this.func_152995_h("Not in channel: " + p_175986_1_);
|
| 359 | return false;
|
| 360 | }
|
| 361 | else
|
| 362 | {
|
| 363 | ChatController.ChatChannelListener chatcontroller$chatchannellistener = (ChatController.ChatChannelListener)this.field_175998_i.get(p_175986_1_);
|
| 364 | return chatcontroller$chatchannellistener.func_176037_b(p_175986_2_);
|
| 365 | }
|
| 366 | }
|
| 367 |
|
| 368 | protected void func_175985_a(ChatController.ChatState p_175985_1_)
|
| 369 | {
|
| 370 | if (p_175985_1_ != this.field_153011_i)
|
| 371 | {
|
| 372 | this.field_153011_i = p_175985_1_;
|
| 373 |
|
| 374 | try
|
| 375 | {
|
| 376 | if (this.field_153003_a != null)
|
| 377 | {
|
| 378 | this.field_153003_a.func_176017_a(p_175985_1_);
|
| 379 | }
|
| 380 | }
|
| 381 | catch (Exception exception)
|
| 382 | {
|
| 383 | this.func_152995_h(exception.toString());
|
| 384 | }
|
| 385 | }
|
| 386 | }
|
| 387 |
|
| 388 | protected void func_153001_r()
|
| 389 | {
|
| 390 | if (this.field_175995_l != ChatController.EnumEmoticonMode.None)
|
| 391 | {
|
| 392 | if (this.field_175996_m == null)
|
| 393 | {
|
| 394 | ErrorCode errorcode = this.field_153008_f.downloadEmoticonData();
|
| 395 |
|
| 396 | if (ErrorCode.failed(errorcode))
|
| 397 | {
|
| 398 | String s = ErrorCode.getString(errorcode);
|
| 399 | this.func_152995_h(String.format("Error trying to download emoticon data: %s", new Object[] {s}));
|
| 400 | }
|
| 401 | }
|
| 402 | }
|
| 403 | }
|
| 404 |
|
| 405 | protected void func_152988_s()
|
| 406 | {
|
| 407 | if (this.field_175996_m == null)
|
| 408 | {
|
| 409 | this.field_175996_m = new ChatEmoticonData();
|
| 410 | ErrorCode errorcode = this.field_153008_f.getEmoticonData(this.field_175996_m);
|
| 411 |
|
| 412 | if (ErrorCode.succeeded(errorcode))
|
| 413 | {
|
| 414 | try
|
| 415 | {
|
| 416 | if (this.field_153003_a != null)
|
| 417 | {
|
| 418 | this.field_153003_a.func_176021_d();
|
| 419 | }
|
| 420 | }
|
| 421 | catch (Exception exception)
|
| 422 | {
|
| 423 | this.func_152995_h(exception.toString());
|
| 424 | }
|
| 425 | }
|
| 426 | else
|
| 427 | {
|
| 428 | this.func_152995_h("Error preparing emoticon data: " + ErrorCode.getString(errorcode));
|
| 429 | }
|
| 430 | }
|
| 431 | }
|
| 432 |
|
| 433 | protected void func_152996_t()
|
| 434 | {
|
| 435 | if (this.field_175996_m != null)
|
| 436 | {
|
| 437 | ErrorCode errorcode = this.field_153008_f.clearEmoticonData();
|
| 438 |
|
| 439 | if (ErrorCode.succeeded(errorcode))
|
| 440 | {
|
| 441 | this.field_175996_m = null;
|
| 442 |
|
| 443 | try
|
| 444 | {
|
| 445 | if (this.field_153003_a != null)
|
| 446 | {
|
| 447 | this.field_153003_a.func_176024_e();
|
| 448 | }
|
| 449 | }
|
| 450 | catch (Exception exception)
|
| 451 | {
|
| 452 | this.func_152995_h(exception.toString());
|
| 453 | }
|
| 454 | }
|
| 455 | else
|
| 456 | {
|
| 457 | this.func_152995_h("Error clearing emoticon data: " + ErrorCode.getString(errorcode));
|
| 458 | }
|
| 459 | }
|
| 460 | }
|
| 461 |
|
| 462 | protected void func_152995_h(String p_152995_1_)
|
| 463 | {
|
| 464 | LOGGER.error(TwitchStream.STREAM_MARKER, "[Chat controller] {}", new Object[] {p_152995_1_});
|
| 465 | }
|
| 466 |
|
| 467 | public class ChatChannelListener implements IChatChannelListener
|
| 468 | {
|
| 469 | protected String field_176048_a = null;
|
| 470 | protected boolean field_176046_b = false;
|
| 471 | protected ChatController.EnumChannelState field_176047_c = ChatController.EnumChannelState.Created;
|
| 472 | protected List<ChatUserInfo> field_176044_d = Lists.<ChatUserInfo>newArrayList();
|
| 473 | protected LinkedList<ChatRawMessage> field_176045_e = new LinkedList();
|
| 474 | protected LinkedList<ChatTokenizedMessage> field_176042_f = new LinkedList();
|
| 475 | protected ChatBadgeData field_176043_g = null;
|
| 476 |
|
| 477 | public ChatChannelListener(String p_i46061_2_)
|
| 478 | {
|
| 479 | this.field_176048_a = p_i46061_2_;
|
| 480 | }
|
| 481 |
|
| 482 | public ChatController.EnumChannelState func_176040_a()
|
| 483 | {
|
| 484 | return this.field_176047_c;
|
| 485 | }
|
| 486 |
|
| 487 | public boolean func_176038_a(boolean p_176038_1_)
|
| 488 | {
|
| 489 | this.field_176046_b = p_176038_1_;
|
| 490 | ErrorCode errorcode = ErrorCode.TTV_EC_SUCCESS;
|
| 491 |
|
| 492 | if (p_176038_1_)
|
| 493 | {
|
| 494 | errorcode = ChatController.this.field_153008_f.connectAnonymous(this.field_176048_a, this);
|
| 495 | }
|
| 496 | else
|
| 497 | {
|
| 498 | errorcode = ChatController.this.field_153008_f.connect(this.field_176048_a, ChatController.this.field_153004_b, ChatController.this.field_153012_j.data, this);
|
| 499 | }
|
| 500 |
|
| 501 | if (ErrorCode.failed(errorcode))
|
| 502 | {
|
| 503 | String s = ErrorCode.getString(errorcode);
|
| 504 | ChatController.this.func_152995_h(String.format("Error connecting: %s", new Object[] {s}));
|
| 505 | this.func_176036_d(this.field_176048_a);
|
| 506 | return false;
|
| 507 | }
|
| 508 | else
|
| 509 | {
|
| 510 | this.func_176035_a(ChatController.EnumChannelState.Connecting);
|
| 511 | this.func_176041_h();
|
| 512 | return true;
|
| 513 | }
|
| 514 | }
|
| 515 |
|
| 516 | public boolean func_176034_g()
|
| 517 | {
|
| 518 | switch (this.field_176047_c)
|
| 519 | {
|
| 520 | case Connected:
|
| 521 | case Connecting:
|
| 522 | ErrorCode errorcode = ChatController.this.field_153008_f.disconnect(this.field_176048_a);
|
| 523 |
|
| 524 | if (ErrorCode.failed(errorcode))
|
| 525 | {
|
| 526 | String s = ErrorCode.getString(errorcode);
|
| 527 | ChatController.this.func_152995_h(String.format("Error disconnecting: %s", new Object[] {s}));
|
| 528 | return false;
|
| 529 | }
|
| 530 |
|
| 531 | this.func_176035_a(ChatController.EnumChannelState.Disconnecting);
|
| 532 | return true;
|
| 533 |
|
| 534 | case Created:
|
| 535 | case Disconnected:
|
| 536 | case Disconnecting:
|
| 537 | default:
|
| 538 | return false;
|
| 539 | }
|
| 540 | }
|
| 541 |
|
| 542 | protected void func_176035_a(ChatController.EnumChannelState p_176035_1_)
|
| 543 | {
|
| 544 | if (p_176035_1_ != this.field_176047_c)
|
| 545 | {
|
| 546 | this.field_176047_c = p_176035_1_;
|
| 547 | }
|
| 548 | }
|
| 549 |
|
| 550 | public void func_176032_a(String p_176032_1_)
|
| 551 | {
|
| 552 | if (ChatController.this.field_175995_l == ChatController.EnumEmoticonMode.None)
|
| 553 | {
|
| 554 | this.field_176045_e.clear();
|
| 555 | this.field_176042_f.clear();
|
| 556 | }
|
| 557 | else
|
| 558 | {
|
| 559 | if (this.field_176045_e.size() > 0)
|
| 560 | {
|
| 561 | ListIterator<ChatRawMessage> listiterator = this.field_176045_e.listIterator();
|
| 562 |
|
| 563 | while (listiterator.hasNext())
|
| 564 | {
|
| 565 | ChatRawMessage chatrawmessage = (ChatRawMessage)listiterator.next();
|
| 566 |
|
| 567 | if (chatrawmessage.userName.equals(p_176032_1_))
|
| 568 | {
|
| 569 | listiterator.remove();
|
| 570 | }
|
| 571 | }
|
| 572 | }
|
| 573 |
|
| 574 | if (this.field_176042_f.size() > 0)
|
| 575 | {
|
| 576 | ListIterator<ChatTokenizedMessage> listiterator1 = this.field_176042_f.listIterator();
|
| 577 |
|
| 578 | while (listiterator1.hasNext())
|
| 579 | {
|
| 580 | ChatTokenizedMessage chattokenizedmessage = (ChatTokenizedMessage)listiterator1.next();
|
| 581 |
|
| 582 | if (chattokenizedmessage.displayName.equals(p_176032_1_))
|
| 583 | {
|
| 584 | listiterator1.remove();
|
| 585 | }
|
| 586 | }
|
| 587 | }
|
| 588 | }
|
| 589 |
|
| 590 | try
|
| 591 | {
|
| 592 | if (ChatController.this.field_153003_a != null)
|
| 593 | {
|
| 594 | ChatController.this.field_153003_a.func_176019_a(this.field_176048_a, p_176032_1_);
|
| 595 | }
|
| 596 | }
|
| 597 | catch (Exception exception)
|
| 598 | {
|
| 599 | ChatController.this.func_152995_h(exception.toString());
|
| 600 | }
|
| 601 | }
|
| 602 |
|
| 603 | public boolean func_176037_b(String p_176037_1_)
|
| 604 | {
|
| 605 | if (this.field_176047_c != ChatController.EnumChannelState.Connected)
|
| 606 | {
|
| 607 | return false;
|
| 608 | }
|
| 609 | else
|
| 610 | {
|
| 611 | ErrorCode errorcode = ChatController.this.field_153008_f.sendMessage(this.field_176048_a, p_176037_1_);
|
| 612 |
|
| 613 | if (ErrorCode.failed(errorcode))
|
| 614 | {
|
| 615 | String s = ErrorCode.getString(errorcode);
|
| 616 | ChatController.this.func_152995_h(String.format("Error sending chat message: %s", new Object[] {s}));
|
| 617 | return false;
|
| 618 | }
|
| 619 | else
|
| 620 | {
|
| 621 | return true;
|
| 622 | }
|
| 623 | }
|
| 624 | }
|
| 625 |
|
| 626 | protected void func_176041_h()
|
| 627 | {
|
| 628 | if (ChatController.this.field_175995_l != ChatController.EnumEmoticonMode.None)
|
| 629 | {
|
| 630 | if (this.field_176043_g == null)
|
| 631 | {
|
| 632 | ErrorCode errorcode = ChatController.this.field_153008_f.downloadBadgeData(this.field_176048_a);
|
| 633 |
|
| 634 | if (ErrorCode.failed(errorcode))
|
| 635 | {
|
| 636 | String s = ErrorCode.getString(errorcode);
|
| 637 | ChatController.this.func_152995_h(String.format("Error trying to download badge data: %s", new Object[] {s}));
|
| 638 | }
|
| 639 | }
|
| 640 | }
|
| 641 | }
|
| 642 |
|
| 643 | protected void func_176039_i()
|
| 644 | {
|
| 645 | if (this.field_176043_g == null)
|
| 646 | {
|
| 647 | this.field_176043_g = new ChatBadgeData();
|
| 648 | ErrorCode errorcode = ChatController.this.field_153008_f.getBadgeData(this.field_176048_a, this.field_176043_g);
|
| 649 |
|
| 650 | if (ErrorCode.succeeded(errorcode))
|
| 651 | {
|
| 652 | try
|
| 653 | {
|
| 654 | if (ChatController.this.field_153003_a != null)
|
| 655 | {
|
| 656 | ChatController.this.field_153003_a.func_176016_c(this.field_176048_a);
|
| 657 | }
|
| 658 | }
|
| 659 | catch (Exception exception)
|
| 660 | {
|
| 661 | ChatController.this.func_152995_h(exception.toString());
|
| 662 | }
|
| 663 | }
|
| 664 | else
|
| 665 | {
|
| 666 | ChatController.this.func_152995_h("Error preparing badge data: " + ErrorCode.getString(errorcode));
|
| 667 | }
|
| 668 | }
|
| 669 | }
|
| 670 |
|
| 671 | protected void func_176033_j()
|
| 672 | {
|
| 673 | if (this.field_176043_g != null)
|
| 674 | {
|
| 675 | ErrorCode errorcode = ChatController.this.field_153008_f.clearBadgeData(this.field_176048_a);
|
| 676 |
|
| 677 | if (ErrorCode.succeeded(errorcode))
|
| 678 | {
|
| 679 | this.field_176043_g = null;
|
| 680 |
|
| 681 | try
|
| 682 | {
|
| 683 | if (ChatController.this.field_153003_a != null)
|
| 684 | {
|
| 685 | ChatController.this.field_153003_a.func_176020_d(this.field_176048_a);
|
| 686 | }
|
| 687 | }
|
| 688 | catch (Exception exception)
|
| 689 | {
|
| 690 | ChatController.this.func_152995_h(exception.toString());
|
| 691 | }
|
| 692 | }
|
| 693 | else
|
| 694 | {
|
| 695 | ChatController.this.func_152995_h("Error releasing badge data: " + ErrorCode.getString(errorcode));
|
| 696 | }
|
| 697 | }
|
| 698 | }
|
| 699 |
|
| 700 | protected void func_176031_c(String p_176031_1_)
|
| 701 | {
|
| 702 | try
|
| 703 | {
|
| 704 | if (ChatController.this.field_153003_a != null)
|
| 705 | {
|
| 706 | ChatController.this.field_153003_a.func_180606_a(p_176031_1_);
|
| 707 | }
|
| 708 | }
|
| 709 | catch (Exception exception)
|
| 710 | {
|
| 711 | ChatController.this.func_152995_h(exception.toString());
|
| 712 | }
|
| 713 | }
|
| 714 |
|
| 715 | protected void func_176036_d(String p_176036_1_)
|
| 716 | {
|
| 717 | try
|
| 718 | {
|
| 719 | if (ChatController.this.field_153003_a != null)
|
| 720 | {
|
| 721 | ChatController.this.field_153003_a.func_180607_b(p_176036_1_);
|
| 722 | }
|
| 723 | }
|
| 724 | catch (Exception exception)
|
| 725 | {
|
| 726 | ChatController.this.func_152995_h(exception.toString());
|
| 727 | }
|
| 728 | }
|
| 729 |
|
| 730 | private void func_176030_k()
|
| 731 | {
|
| 732 | if (this.field_176047_c != ChatController.EnumChannelState.Disconnected)
|
| 733 | {
|
| 734 | this.func_176035_a(ChatController.EnumChannelState.Disconnected);
|
| 735 | this.func_176036_d(this.field_176048_a);
|
| 736 | this.func_176033_j();
|
| 737 | }
|
| 738 | }
|
| 739 |
|
| 740 | public void chatStatusCallback(String p_chatStatusCallback_1_, ErrorCode p_chatStatusCallback_2_)
|
| 741 | {
|
| 742 | if (!ErrorCode.succeeded(p_chatStatusCallback_2_))
|
| 743 | {
|
| 744 | ChatController.this.field_175998_i.remove(p_chatStatusCallback_1_);
|
| 745 | this.func_176030_k();
|
| 746 | }
|
| 747 | }
|
| 748 |
|
| 749 | public void chatChannelMembershipCallback(String p_chatChannelMembershipCallback_1_, ChatEvent p_chatChannelMembershipCallback_2_, ChatChannelInfo p_chatChannelMembershipCallback_3_)
|
| 750 | {
|
| 751 | switch (p_chatChannelMembershipCallback_2_)
|
| 752 | {
|
| 753 | case TTV_CHAT_JOINED_CHANNEL:
|
| 754 | this.func_176035_a(ChatController.EnumChannelState.Connected);
|
| 755 | this.func_176031_c(p_chatChannelMembershipCallback_1_);
|
| 756 | break;
|
| 757 |
|
| 758 | case TTV_CHAT_LEFT_CHANNEL:
|
| 759 | this.func_176030_k();
|
| 760 | }
|
| 761 | }
|
| 762 |
|
| 763 | public void chatChannelUserChangeCallback(String p_chatChannelUserChangeCallback_1_, ChatUserInfo[] p_chatChannelUserChangeCallback_2_, ChatUserInfo[] p_chatChannelUserChangeCallback_3_, ChatUserInfo[] p_chatChannelUserChangeCallback_4_)
|
| 764 | {
|
| 765 | for (int i = 0; i < p_chatChannelUserChangeCallback_3_.length; ++i)
|
| 766 | {
|
| 767 | int j = this.field_176044_d.indexOf(p_chatChannelUserChangeCallback_3_[i]);
|
| 768 |
|
| 769 | if (j >= 0)
|
| 770 | {
|
| 771 | this.field_176044_d.remove(j);
|
| 772 | }
|
| 773 | }
|
| 774 |
|
| 775 | for (int k = 0; k < p_chatChannelUserChangeCallback_4_.length; ++k)
|
| 776 | {
|
| 777 | int i1 = this.field_176044_d.indexOf(p_chatChannelUserChangeCallback_4_[k]);
|
| 778 |
|
| 779 | if (i1 >= 0)
|
| 780 | {
|
| 781 | this.field_176044_d.remove(i1);
|
| 782 | }
|
| 783 |
|
| 784 | this.field_176044_d.add(p_chatChannelUserChangeCallback_4_[k]);
|
| 785 | }
|
| 786 |
|
| 787 | for (int l = 0; l < p_chatChannelUserChangeCallback_2_.length; ++l)
|
| 788 | {
|
| 789 | this.field_176044_d.add(p_chatChannelUserChangeCallback_2_[l]);
|
| 790 | }
|
| 791 |
|
| 792 | try
|
| 793 | {
|
| 794 | if (ChatController.this.field_153003_a != null)
|
| 795 | {
|
| 796 | ChatController.this.field_153003_a.func_176018_a(this.field_176048_a, p_chatChannelUserChangeCallback_2_, p_chatChannelUserChangeCallback_3_, p_chatChannelUserChangeCallback_4_);
|
| 797 | }
|
| 798 | }
|
| 799 | catch (Exception exception)
|
| 800 | {
|
| 801 | ChatController.this.func_152995_h(exception.toString());
|
| 802 | }
|
| 803 | }
|
| 804 |
|
| 805 | public void chatChannelRawMessageCallback(String p_chatChannelRawMessageCallback_1_, ChatRawMessage[] p_chatChannelRawMessageCallback_2_)
|
| 806 | {
|
| 807 | for (int i = 0; i < p_chatChannelRawMessageCallback_2_.length; ++i)
|
| 808 | {
|
| 809 | this.field_176045_e.addLast(p_chatChannelRawMessageCallback_2_[i]);
|
| 810 | }
|
| 811 |
|
| 812 | try
|
| 813 | {
|
| 814 | if (ChatController.this.field_153003_a != null)
|
| 815 | {
|
| 816 | ChatController.this.field_153003_a.func_180605_a(this.field_176048_a, p_chatChannelRawMessageCallback_2_);
|
| 817 | }
|
| 818 | }
|
| 819 | catch (Exception exception)
|
| 820 | {
|
| 821 | ChatController.this.func_152995_h(exception.toString());
|
| 822 | }
|
| 823 |
|
| 824 | while (this.field_176045_e.size() > ChatController.this.field_153015_m)
|
| 825 | {
|
| 826 | this.field_176045_e.removeFirst();
|
| 827 | }
|
| 828 | }
|
| 829 |
|
| 830 | public void chatChannelTokenizedMessageCallback(String p_chatChannelTokenizedMessageCallback_1_, ChatTokenizedMessage[] p_chatChannelTokenizedMessageCallback_2_)
|
| 831 | {
|
| 832 | for (int i = 0; i < p_chatChannelTokenizedMessageCallback_2_.length; ++i)
|
| 833 | {
|
| 834 | this.field_176042_f.addLast(p_chatChannelTokenizedMessageCallback_2_[i]);
|
| 835 | }
|
| 836 |
|
| 837 | try
|
| 838 | {
|
| 839 | if (ChatController.this.field_153003_a != null)
|
| 840 | {
|
| 841 | ChatController.this.field_153003_a.func_176025_a(this.field_176048_a, p_chatChannelTokenizedMessageCallback_2_);
|
| 842 | }
|
| 843 | }
|
| 844 | catch (Exception exception)
|
| 845 | {
|
| 846 | ChatController.this.func_152995_h(exception.toString());
|
| 847 | }
|
| 848 |
|
| 849 | while (this.field_176042_f.size() > ChatController.this.field_153015_m)
|
| 850 | {
|
| 851 | this.field_176042_f.removeFirst();
|
| 852 | }
|
| 853 | }
|
| 854 |
|
| 855 | public void chatClearCallback(String p_chatClearCallback_1_, String p_chatClearCallback_2_)
|
| 856 | {
|
| 857 | this.func_176032_a(p_chatClearCallback_2_);
|
| 858 | }
|
| 859 |
|
| 860 | public void chatBadgeDataDownloadCallback(String p_chatBadgeDataDownloadCallback_1_, ErrorCode p_chatBadgeDataDownloadCallback_2_)
|
| 861 | {
|
| 862 | if (ErrorCode.succeeded(p_chatBadgeDataDownloadCallback_2_))
|
| 863 | {
|
| 864 | this.func_176039_i();
|
| 865 | }
|
| 866 | }
|
| 867 | }
|
| 868 |
|
| 869 | public interface ChatListener
|
| 870 | {
|
| 871 | void func_176023_d(ErrorCode p_176023_1_);
|
| 872 |
|
| 873 | void func_176022_e(ErrorCode p_176022_1_);
|
| 874 |
|
| 875 | void func_176021_d();
|
| 876 |
|
| 877 | void func_176024_e();
|
| 878 |
|
| 879 | void func_176017_a(ChatController.ChatState p_176017_1_);
|
| 880 |
|
| 881 | void func_176025_a(String p_176025_1_, ChatTokenizedMessage[] p_176025_2_);
|
| 882 |
|
| 883 | void func_180605_a(String p_180605_1_, ChatRawMessage[] p_180605_2_);
|
| 884 |
|
| 885 | void func_176018_a(String p_176018_1_, ChatUserInfo[] p_176018_2_, ChatUserInfo[] p_176018_3_, ChatUserInfo[] p_176018_4_);
|
| 886 |
|
| 887 | void func_180606_a(String p_180606_1_);
|
| 888 |
|
| 889 | void func_180607_b(String p_180607_1_);
|
| 890 |
|
| 891 | void func_176019_a(String p_176019_1_, String p_176019_2_);
|
| 892 |
|
| 893 | void func_176016_c(String p_176016_1_);
|
| 894 |
|
| 895 | void func_176020_d(String p_176020_1_);
|
| 896 | }
|
| 897 |
|
| 898 | public static enum ChatState
|
| 899 | {
|
| 900 | Uninitialized,
|
| 901 | Initializing,
|
| 902 | Initialized,
|
| 903 | ShuttingDown;
|
| 904 | }
|
| 905 |
|
| 906 | public static enum EnumChannelState
|
| 907 | {
|
| 908 | Created,
|
| 909 | Connecting,
|
| 910 | Connected,
|
| 911 | Disconnecting,
|
| 912 | Disconnected;
|
| 913 | }
|
| 914 |
|
| 915 | public static enum EnumEmoticonMode
|
| 916 | {
|
| 917 | None,
|
| 918 | Url,
|
| 919 | TextureAtlas;
|
| 920 | }
|
| 921 | }
|
| 922 |
|