L2SiegeClan.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.model;
  16. import java.util.List;
  17. import javolution.util.FastList;
  18. import com.l2jserver.gameserver.model.actor.L2Npc;
  19. public class L2SiegeClan
  20. {
  21. private int _clanId = 0;
  22. private List<L2Npc> _flag = new FastList<L2Npc>();
  23. private int _numFlagsAdded = 0;
  24. private SiegeClanType _type;
  25. public enum SiegeClanType
  26. {
  27. OWNER,
  28. DEFENDER,
  29. ATTACKER,
  30. DEFENDER_PENDING
  31. }
  32. public L2SiegeClan(int clanId, SiegeClanType type)
  33. {
  34. _clanId = clanId;
  35. _type = type;
  36. }
  37. public int getNumFlags()
  38. {
  39. return _numFlagsAdded;
  40. }
  41. public void addFlag(L2Npc flag)
  42. {
  43. _numFlagsAdded++;
  44. getFlag().add(flag);
  45. }
  46. public boolean removeFlag(L2Npc flag)
  47. {
  48. if (flag == null)
  49. {
  50. return false;
  51. }
  52. boolean ret = getFlag().remove(flag);
  53. // check if null objects or duplicates remain in the list.
  54. // for some reason, this might be happening sometimes...
  55. // delete false duplicates: if this flag got deleted, delete its copies too.
  56. if (ret)
  57. {
  58. while (getFlag().remove(flag))
  59. {
  60. //
  61. }
  62. }
  63. flag.deleteMe();
  64. _numFlagsAdded--;
  65. return ret;
  66. }
  67. public void removeFlags()
  68. {
  69. for (L2Npc flag : getFlag())
  70. {
  71. removeFlag(flag);
  72. }
  73. }
  74. public final int getClanId()
  75. {
  76. return _clanId;
  77. }
  78. public final List<L2Npc> getFlag()
  79. {
  80. if (_flag == null)
  81. {
  82. _flag = new FastList<L2Npc>();
  83. }
  84. return _flag;
  85. }
  86. public SiegeClanType getType()
  87. {
  88. return _type;
  89. }
  90. public void setType(SiegeClanType setType)
  91. {
  92. _type = setType;
  93. }
  94. }