L2AccessLevel.java 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. * Copyright (C) 2004-2013 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 com.l2jserver.gameserver.datatables.AdminTable;
  21. /**
  22. * @author FBIagent<br>
  23. */
  24. public class L2AccessLevel
  25. {
  26. /** The access level<br> */
  27. private int _accessLevel = 0;
  28. /** The access level name<br> */
  29. private String _name = null;
  30. /** Child access levels */
  31. L2AccessLevel _childsAccessLevel = null;
  32. /** Child access levels */
  33. private int _child = 0;
  34. /** The name color for the access level<br> */
  35. private int _nameColor = 0;
  36. /** The title color for the access level<br> */
  37. private int _titleColor = 0;
  38. /** Flag to determine if the access level has gm access<br> */
  39. private boolean _isGm = false;
  40. /** Flag for peace zone attack */
  41. private boolean _allowPeaceAttack = false;
  42. /** Flag for fixed res */
  43. private boolean _allowFixedRes = false;
  44. /** Flag for transactions */
  45. private boolean _allowTransaction = false;
  46. /** Flag for AltG commands */
  47. private boolean _allowAltG = false;
  48. /** Flag to give damage */
  49. private boolean _giveDamage = false;
  50. /** Flag to take aggro */
  51. private boolean _takeAggro = false;
  52. /** Flag to gain exp in party */
  53. private boolean _gainExp = false;
  54. public L2AccessLevel(StatsSet set)
  55. {
  56. _accessLevel = set.getInt("level");
  57. _name = set.getString("name");
  58. _nameColor = Integer.decode("0x" + set.getString("nameColor", "FFFFFF"));
  59. _titleColor = Integer.decode("0x" + set.getString("titleColor", "FFFFFF"));
  60. _child = set.getInt("childAccess", 0);
  61. _isGm = set.getBoolean("isGM", false);
  62. _allowPeaceAttack = set.getBoolean("allowPeaceAttack", false);
  63. _allowFixedRes = set.getBoolean("allowFixedRes", false);
  64. _allowTransaction = set.getBoolean("allowTransaction", true);
  65. _allowAltG = set.getBoolean("allowAltg", false);
  66. _giveDamage = set.getBoolean("giveDamage", true);
  67. _takeAggro = set.getBoolean("takeAggro", true);
  68. _gainExp = set.getBoolean("gainExp", true);
  69. }
  70. public L2AccessLevel()
  71. {
  72. _accessLevel = 0;
  73. _name = "User";
  74. _nameColor = Integer.decode("0xFFFFFF");
  75. _titleColor = Integer.decode("0xFFFFFF");
  76. _child = 0;
  77. _isGm = false;
  78. _allowPeaceAttack = false;
  79. _allowFixedRes = false;
  80. _allowTransaction = true;
  81. _allowAltG = false;
  82. _giveDamage = true;
  83. _takeAggro = true;
  84. _gainExp = true;
  85. }
  86. /**
  87. * Returns the access level<br>
  88. * <br>
  89. * @return int: access level<br>
  90. */
  91. public int getLevel()
  92. {
  93. return _accessLevel;
  94. }
  95. /**
  96. * Returns the access level name<br>
  97. * <br>
  98. * @return String: access level name<br>
  99. */
  100. public String getName()
  101. {
  102. return _name;
  103. }
  104. /**
  105. * Returns the name color of the access level<br>
  106. * <br>
  107. * @return int: the name color for the access level<br>
  108. */
  109. public int getNameColor()
  110. {
  111. return _nameColor;
  112. }
  113. /**
  114. * Returns the title color color of the access level<br>
  115. * <br>
  116. * @return int: the title color for the access level<br>
  117. */
  118. public int getTitleColor()
  119. {
  120. return _titleColor;
  121. }
  122. /**
  123. * Retuns if the access level has gm access or not<br>
  124. * <br>
  125. * @return boolean: true if access level have gm access, otherwise false<br>
  126. */
  127. public boolean isGm()
  128. {
  129. return _isGm;
  130. }
  131. /**
  132. * Returns if the access level is allowed to attack in peace zone or not<br>
  133. * <br>
  134. * @return boolean: true if the access level is allowed to attack in peace zone, otherwise false<br>
  135. */
  136. public boolean allowPeaceAttack()
  137. {
  138. return _allowPeaceAttack;
  139. }
  140. /**
  141. * Retruns if the access level is allowed to use fixed res or not<br>
  142. * <br>
  143. * @return true if the access level is allowed to use fixed res, otherwise false<br>
  144. */
  145. public boolean allowFixedRes()
  146. {
  147. return _allowFixedRes;
  148. }
  149. /**
  150. * Returns if the access level is allowed to perform transactions or not<br>
  151. * <br>
  152. * @return boolean: true if access level is allowed to perform transactions, otherwise false<br>
  153. */
  154. public boolean allowTransaction()
  155. {
  156. return _allowTransaction;
  157. }
  158. /**
  159. * Returns if the access level is allowed to use AltG commands or not<br>
  160. * <br>
  161. * @return boolean: true if access level is allowed to use AltG commands, otherwise false<br>
  162. */
  163. public boolean allowAltG()
  164. {
  165. return _allowAltG;
  166. }
  167. /**
  168. * Returns if the access level can give damage or not<br>
  169. * <br>
  170. * @return boolean: true if the access level can give damage, otherwise false<br>
  171. */
  172. public boolean canGiveDamage()
  173. {
  174. return _giveDamage;
  175. }
  176. /**
  177. * Returns if the access level can take aggro or not<br>
  178. * <br>
  179. * @return boolean: true if the access level can take aggro, otherwise false<br>
  180. */
  181. public boolean canTakeAggro()
  182. {
  183. return _takeAggro;
  184. }
  185. /**
  186. * Returns if the access level can gain exp or not<br>
  187. * <br>
  188. * @return boolean: true if the access level can gain exp, otherwise false<br>
  189. */
  190. public boolean canGainExp()
  191. {
  192. return _gainExp;
  193. }
  194. /**
  195. * Returns if the access level contains allowedAccess as child<br>
  196. * @param accessLevel as AccessLevel<br>
  197. * @return boolean: true if a child access level is equals to allowedAccess, otherwise false<br>
  198. */
  199. public boolean hasChildAccess(L2AccessLevel accessLevel)
  200. {
  201. if (_childsAccessLevel == null)
  202. {
  203. if (_child <= 0)
  204. {
  205. return false;
  206. }
  207. _childsAccessLevel = AdminTable.getInstance().getAccessLevel(_child);
  208. }
  209. return ((_childsAccessLevel.getLevel() == accessLevel.getLevel()) || _childsAccessLevel.hasChildAccess(accessLevel));
  210. }
  211. }