L2SiegeClan.java 2.6 KB

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