Advertisement
Guest User

part of code

a guest
Oct 11th, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
  2. ===================================================================
  3. --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (revision 86)
  4. +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (working copy)
  5. @@ -15,8 +15,13 @@
  6. package net.sf.l2j.gameserver.handler.chathandlers;
  7.  
  8. import java.util.Collection;
  9. +import java.util.StringTokenizer;
  10. +import java.util.logging.Logger;
  11.  
  12. +import net.sf.l2j.Config;
  13. import net.sf.l2j.gameserver.handler.IChatHandler;
  14. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  15. +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
  16. import net.sf.l2j.gameserver.model.BlockList;
  17. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  18. import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  19. @@ -29,6 +34,7 @@
  20. public class ChatAll implements IChatHandler
  21. {
  22. private static final int[] COMMAND_IDS = { 0 };
  23. + private static Logger _log = Logger.getLogger(ChatAll.class.getName());
  24.  
  25. /**
  26. * Handle chat type 'all'
  27. @@ -36,16 +42,53 @@
  28. */
  29. public void handleChat(int type, L2PcInstance activeChar, String params, String text)
  30. {
  31. - CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  32. - Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  33. -
  34. - for (L2PcInstance player : plrs)
  35. + boolean vcd_used = false;
  36. + if (text.startsWith("."))
  37. {
  38. - if (player != null && activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
  39. - player.sendPacket(cs);
  40. - }
  41. + StringTokenizer st = new StringTokenizer(text);
  42. + IVoicedCommandHandler vch;
  43. + String command = "";
  44.  
  45. - activeChar.sendPacket(cs);
  46. + if (st.countTokens() > 1)
  47. + {
  48. + command = st.nextToken().substring(1);
  49. + params = text.substring(command.length() + 2);
  50. + vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
  51. + }
  52. + else
  53. + {
  54. + command = text.substring(1);
  55. + if (Config.DEBUG)
  56. + _log.info("Command: " + command);
  57. + vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
  58. + }
  59. +
  60. + if (vch != null)
  61. + {
  62. + vch.useVoicedCommand(command, activeChar, params);
  63. + vcd_used = true;
  64. + }
  65. + else
  66. + {
  67. + if (Config.DEBUG)
  68. + _log.warning("No handler registered for bypass '" + command + "'");
  69. + vcd_used = false;
  70. + }
  71. + }
  72. +
  73. + if (!vcd_used)
  74. + {
  75. + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  76. + Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  77. +
  78. + for (L2PcInstance player : plrs)
  79. + {
  80. + if (player != null && activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
  81. + player.sendPacket(cs);
  82. + }
  83. +
  84. + activeChar.sendPacket(cs);
  85. + }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement