RequestSocialAction.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 com.l2jserver.gameserver.network.clientpackets;
  16. import java.util.logging.Logger;
  17. import com.l2jserver.Config;
  18. import com.l2jserver.gameserver.ai.CtrlIntention;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.network.SystemMessageId;
  21. import com.l2jserver.gameserver.network.serverpackets.SocialAction;
  22. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  23. import com.l2jserver.gameserver.util.Util;
  24. /**
  25. * This class ...
  26. *
  27. * @version $Revision: 1.6.4.4 $ $Date: 2005/03/27 15:29:30 $
  28. */
  29. public class RequestSocialAction extends L2GameClientPacket
  30. {
  31. private static final String _C__1B_REQUESTSOCIALACTION = "[C] 1B RequestSocialAction";
  32. private static Logger _log = Logger.getLogger(RequestSocialAction.class.getName());
  33. // format cd
  34. private int _actionId;
  35. @Override
  36. protected void readImpl()
  37. {
  38. _actionId = readD();
  39. }
  40. @Override
  41. protected void runImpl()
  42. {
  43. L2PcInstance activeChar = getClient().getActiveChar();
  44. if (activeChar == null)
  45. return;
  46. // You cannot do anything else while fishing
  47. if (activeChar.isFishing())
  48. {
  49. SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_DO_WHILE_FISHING_3);
  50. activeChar.sendPacket(sm);
  51. sm = null;
  52. return;
  53. }
  54. // check if its the actionId is allowed
  55. if (_actionId < 2 || _actionId > 14)
  56. {
  57. Util.handleIllegalPlayerAction(activeChar, "Warning!! Character "+activeChar.getName()+" of account "+activeChar.getAccountName()+" requested an internal Social Action.", Config.DEFAULT_PUNISH);
  58. return;
  59. }
  60. if ( activeChar.getPrivateStoreType()==0 &&
  61. activeChar.getActiveRequester()==null &&
  62. !activeChar.isAlikeDead() &&
  63. (!activeChar.isAllSkillsDisabled() || activeChar.isInDuel()) &&
  64. !activeChar.isCastingNow() && !activeChar.isCastingSimultaneouslyNow() &&
  65. activeChar.getAI().getIntention()==CtrlIntention.AI_INTENTION_IDLE)
  66. {
  67. if (Config.DEBUG) _log.fine("Social Action:" + _actionId);
  68. SocialAction atk = new SocialAction(activeChar.getObjectId(), _actionId);
  69. activeChar.broadcastPacket(atk);
  70. /*
  71. // Schedule a social task to wait for the animation to finish
  72. ThreadPoolManager.getInstance().scheduleGeneral(new SocialTask(this), 2600);
  73. activeChar.setIsParalyzed(true);
  74. */
  75. }
  76. }
  77. /*
  78. class SocialTask implements Runnable
  79. {
  80. L2PcInstance _player;
  81. SocialTask(RequestSocialAction action)
  82. {
  83. _player = getClient().getActiveChar();
  84. }
  85. public void run()
  86. {
  87. _player.setIsParalyzed(false);
  88. }
  89. }
  90. */
  91. /* (non-Javadoc)
  92. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
  93. */
  94. @Override
  95. public String getType()
  96. {
  97. return _C__1B_REQUESTSOCIALACTION;
  98. }
  99. }