PlayerEventHolder.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (C) 2004-2013 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.model.holders;
  20. import java.util.List;
  21. import javolution.util.FastList;
  22. import com.l2jserver.gameserver.datatables.ClanTable;
  23. import com.l2jserver.gameserver.model.Location;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. /**
  26. * Player event holder, meant for restoring player after event has finished.<br>
  27. * Allows you to restore following information about player:
  28. * <ul>
  29. * <li>Name</li>
  30. * <li>Title</li>
  31. * <li>Clan</li>
  32. * <li>Location</li>
  33. * <li>PvP Kills</li>
  34. * <li>PK Kills</li>
  35. * <li>Karma</li>
  36. * </ul>
  37. * @author Nik, xban1x
  38. */
  39. public final class PlayerEventHolder
  40. {
  41. private final L2PcInstance _player;
  42. private final String _name;
  43. private final String _title;
  44. private final int _clanId;
  45. private final Location _loc;
  46. private final int _pvpKills;
  47. private final int _pkKills;
  48. private final int _karma;
  49. private final List<L2PcInstance> _kills;
  50. private boolean _sitForced;
  51. public PlayerEventHolder(L2PcInstance player)
  52. {
  53. this(player, false);
  54. }
  55. public PlayerEventHolder(L2PcInstance player, boolean sitForced)
  56. {
  57. _player = player;
  58. _name = player.getName();
  59. _title = player.getTitle();
  60. _clanId = player.getClanId();
  61. _loc = new Location(player);
  62. _pvpKills = player.getPvpKills();
  63. _pkKills = player.getPkKills();
  64. _karma = player.getKarma();
  65. _kills = new FastList<>();
  66. _sitForced = sitForced;
  67. }
  68. public void restorePlayerStats()
  69. {
  70. _player.setName(_name);
  71. _player.setTitle(_title);
  72. _player.setClan(ClanTable.getInstance().getClan(_clanId));
  73. _player.teleToLocation(_loc, true);
  74. _player.setPvpKills(_pvpKills);
  75. _player.setPkKills(_pkKills);
  76. _player.setKarma(_karma);
  77. }
  78. public void setSitForced(boolean sitForced)
  79. {
  80. _sitForced = sitForced;
  81. }
  82. public boolean isSitForced()
  83. {
  84. return _sitForced;
  85. }
  86. public List<L2PcInstance> getKills()
  87. {
  88. return _kills;
  89. }
  90. }