Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package net.sf.l2j.gameserver.handler.chathandlers;
  16.  
  17. import java.util.StringTokenizer;
  18.  
  19. import net.sf.l2j.gameserver.handler.IChatHandler;
  20. import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  21. import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
  22. import net.sf.l2j.gameserver.model.BlockList;
  23. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  24. import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  25. import net.sf.l2j.gameserver.util.FloodProtectors;
  26. import net.sf.l2j.gameserver.util.FloodProtectors.Action;
  27.  
  28. public class ChatAll implements IChatHandler
  29. {
  30. private static final int[] COMMAND_IDS =
  31. {
  32. 0
  33. };
  34.  
  35. @Override
  36. public void handleChat(int type, L2PcInstance activeChar, String params, String text)
  37. {
  38. if (!FloodProtectors.performAction(activeChar.getClient(), Action.GLOBAL_CHAT))
  39. return;
  40.  
  41. boolean vcd_used = false;
  42. if (text.startsWith("."))
  43. {
  44. StringTokenizer st = new StringTokenizer(text);
  45. IVoicedCommandHandler vch;
  46. String command = "";
  47. if (st.countTokens() > 1)
  48. {
  49. command = st.nextToken().substring(1);
  50. params = text.substring(command.length() + 2);
  51. vch = VoicedCommandHandler.getInstance().getHandler(command);
  52. }
  53. else
  54. {
  55. command = text.substring(1);
  56. vch = VoicedCommandHandler.getInstance().getHandler(command);
  57. }
  58.  
  59. if (vch != null)
  60. {
  61. vch.useVoicedCommand(command, activeChar, params);
  62. vcd_used = true;
  63. }
  64. }
  65. if (!vcd_used)
  66.  
  67. {
  68. CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  69.  
  70. for (L2PcInstance player : activeChar.getKnownList().getKnownTypeInRadius(L2PcInstance.class, 1250))
  71. {
  72. if (!BlockList.isBlocked(player, activeChar))
  73. player.sendPacket(cs);
  74. }
  75.  
  76. activeChar.sendPacket(cs);
  77. }
  78. }
  79.  
  80. @Override
  81. public int[] getChatTypeList()
  82. {
  83. return COMMAND_IDS;
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement