ConditionPlayerHasClanHall.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.skills.conditions;
  16. import java.util.ArrayList;
  17. import com.l2jserver.gameserver.model.L2Clan;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.skills.Env;
  20. /**
  21. * The Class ConditionPlayerHasClanHall.
  22. *
  23. * @author MrPoke
  24. */
  25. public final class ConditionPlayerHasClanHall extends Condition
  26. {
  27. private final ArrayList<Integer> _clanHall;
  28. /**
  29. * Instantiates a new condition player has clan hall.
  30. *
  31. * @param clanHall the clan hall
  32. */
  33. public ConditionPlayerHasClanHall(ArrayList<Integer> clanHall)
  34. {
  35. _clanHall = clanHall;
  36. }
  37. /**
  38. * Test impl.
  39. *
  40. * @param env the env
  41. * @return true, if successful
  42. * @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
  43. */
  44. @Override
  45. public boolean testImpl(Env env)
  46. {
  47. if (!(env.player instanceof L2PcInstance))
  48. return false;
  49. L2Clan clan = ((L2PcInstance)env.player).getClan();
  50. if (clan == null)
  51. return (_clanHall.size() == 1 && _clanHall.get(0) == 0);
  52. // All Clan Hall
  53. if (_clanHall.size() == 1 && _clanHall.get(0) == -1)
  54. return clan.getHasHideout() > 0;
  55. return _clanHall.contains(clan.getHasHideout());
  56. }
  57. }