L2SiegeClan.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 com.l2jserver.gameserver.model.actor.L2Npc;
  18. import javolution.util.FastList;
  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) return false;
  57. boolean ret = getFlag().remove(flag);
  58. //check if null objects or duplicates remain in the list.
  59. //for some reason, this might be happening sometimes...
  60. // delete false duplicates: if this flag got deleted, delete its copies too.
  61. if (ret)
  62. while (getFlag().remove(flag)) ;
  63. flag.deleteMe();
  64. _numFlagsAdded--;
  65. return ret;
  66. }
  67. public void removeFlags()
  68. {
  69. for (L2Npc flag: getFlag())
  70. removeFlag(flag);
  71. }
  72. // =========================================================
  73. // Property
  74. public final int getClanId() { return _clanId; }
  75. public final List<L2Npc> getFlag()
  76. {
  77. if (_flag == null) _flag = new FastList<L2Npc>();
  78. return _flag;
  79. }
  80. public SiegeClanType getType() { return _type; }
  81. public void setType(SiegeClanType setType) { _type = setType; }
  82. }