MagicSkillLaunched.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.network.serverpackets;
  20. import java.util.Arrays;
  21. import java.util.List;
  22. import com.l2jserver.gameserver.model.L2Object;
  23. import com.l2jserver.gameserver.model.actor.L2Character;
  24. /**
  25. * MagicSkillLaunched server packet implementation.
  26. * @author UnAfraid
  27. */
  28. public class MagicSkillLaunched extends L2GameServerPacket
  29. {
  30. private final int _charObjId;
  31. private final int _skillId;
  32. private final int _skillLevel;
  33. private final List<L2Object> _targets;
  34. public MagicSkillLaunched(L2Character cha, int skillId, int skillLevel, L2Object... targets)
  35. {
  36. _charObjId = cha.getObjectId();
  37. _skillId = skillId;
  38. _skillLevel = skillLevel;
  39. //@formatter:off
  40. if (targets == null)
  41. {
  42. targets = new L2Object[] { cha };
  43. }
  44. //@formatter:on
  45. _targets = Arrays.asList(targets);
  46. }
  47. public MagicSkillLaunched(L2Character cha, int skillId, int skillLevel)
  48. {
  49. this(cha, skillId, skillId, cha);
  50. }
  51. @Override
  52. protected final void writeImpl()
  53. {
  54. writeC(0x54);
  55. writeD(_charObjId);
  56. writeD(_skillId);
  57. writeD(_skillLevel);
  58. writeD(_targets.size());
  59. for (L2Object target : _targets)
  60. {
  61. writeD(target.getObjectId());
  62. }
  63. }
  64. }