L2SiegeClan.java 2.3 KB

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