Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ProcessNickInUse.java 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2006-2017 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.parser.irc.processors;
  23. import com.dmdirc.parser.events.NickInUseEvent;
  24. import com.dmdirc.parser.irc.IRCParser;
  25. import java.time.LocalDateTime;
  26. import javax.inject.Inject;
  27. /**
  28. * Process a NickInUse message.
  29. * Parser implements handling of this if Pre-001 and no other handler found,
  30. * adding the NickInUse handler (addNickInUse) after 001 is prefered over before.<br><br>
  31. * <br>
  32. * If the first nickname is in use, and a NickInUse message is recieved before 001, we
  33. * will attempt to use the altnickname instead.<br>
  34. * If this also fails, we will start prepending _ (or the value of me.cPrepend) to the main nickname.
  35. */
  36. public class ProcessNickInUse extends IRCProcessor {
  37. /**
  38. * Create a new instance of the ProcessNickInUse Object.
  39. *
  40. * @param parser IRCParser That owns this object
  41. */
  42. @Inject
  43. public ProcessNickInUse(final IRCParser parser) {
  44. super(parser, "433");
  45. }
  46. /**
  47. * Process a NickInUse message.
  48. * Parser implements handling of this if Pre-001 and no other handler found,
  49. * adding the NickInUse handler (addNickInUse) after 001 is prefered over before.<br><br>
  50. * <br>
  51. * If the first nickname is in use, and a NickInUse message is recieved before 001, we
  52. * will attempt to use the altnickname instead.<br>
  53. * If this also fails, we will start prepending _ (or the value of me.cPrepend) to the main nickname.
  54. *
  55. * @param sParam Type of line to process ("433")
  56. * @param token IRCTokenised line to process
  57. */
  58. @Override
  59. public void process(final LocalDateTime time, final String sParam, final String... token) {
  60. callNickInUse(time, token[3]);
  61. }
  62. /**
  63. * Callback to all objects implementing the NickInUse Callback.
  64. *
  65. * @param nickname Nickname that was wanted.
  66. */
  67. protected void callNickInUse(final LocalDateTime time, final String nickname) {
  68. getCallbackManager().publish(new NickInUseEvent(parser, time, nickname));
  69. }
  70. }