RequestCursedWeaponLocation.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.clientpackets;
  16. import java.util.List;
  17. import javolution.util.FastList;
  18. import net.sf.l2j.gameserver.instancemanager.CursedWeaponsManager;
  19. import net.sf.l2j.gameserver.model.CursedWeapon;
  20. import net.sf.l2j.gameserver.model.L2Character;
  21. import net.sf.l2j.gameserver.serverpackets.ExCursedWeaponLocation;
  22. import net.sf.l2j.gameserver.serverpackets.ExCursedWeaponLocation.CursedWeaponInfo;
  23. import net.sf.l2j.util.Point3D;
  24. /**
  25. * Format: (ch)
  26. * @author -Wooden-
  27. */
  28. public final class RequestCursedWeaponLocation extends L2GameClientPacket
  29. {
  30. private static final String _C__D0_23_REQUESTCURSEDWEAPONLOCATION = "[C] D0:23 RequestCursedWeaponLocation";
  31. @Override
  32. protected void readImpl()
  33. {
  34. //nothing to read it's just a trigger
  35. }
  36. /**
  37. * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#runImpl()
  38. */
  39. @Override
  40. protected
  41. void runImpl()
  42. {
  43. L2Character activeChar = getClient().getActiveChar();
  44. if (activeChar == null)
  45. return;
  46. List<CursedWeaponInfo> list = new FastList<CursedWeaponInfo>();
  47. for (CursedWeapon cw : CursedWeaponsManager.getInstance().getCursedWeapons())
  48. {
  49. if (!cw.isActive()) continue;
  50. Point3D pos = cw.getWorldPosition();
  51. if (pos != null)
  52. list.add(new CursedWeaponInfo(pos, cw.getItemId(), cw.isActivated() ? 1 : 0));
  53. }
  54. //send the ExCursedWeaponLocation
  55. if (!list.isEmpty())
  56. {
  57. activeChar.sendPacket(new ExCursedWeaponLocation(list));
  58. }
  59. }
  60. /**
  61. * @see net.sf.l2j.gameserver.BasePacket#getType()
  62. */
  63. @Override
  64. public String getType()
  65. {
  66. return _C__D0_23_REQUESTCURSEDWEAPONLOCATION;
  67. }
  68. }