L2AdminCommandAccessRight.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 com.l2jserver.gameserver.datatables.AdminTable;
  17. /**
  18. * @author FBIagent
  19. */
  20. public class L2AdminCommandAccessRight
  21. {
  22. /** The admin command */
  23. private String _adminCommand = null;
  24. /** The access levels which can use the admin command. */
  25. private final int _accessLevel;
  26. private final boolean _requireConfirm;
  27. public L2AdminCommandAccessRight(StatsSet set)
  28. {
  29. _adminCommand = set.getString("command");
  30. _requireConfirm = set.getBool("confirmDlg", false);
  31. _accessLevel = set.getInteger("accessLevel", 7);
  32. }
  33. public L2AdminCommandAccessRight(String command, boolean confirm, int level)
  34. {
  35. _adminCommand = command;
  36. _requireConfirm = confirm;
  37. _accessLevel = level;
  38. }
  39. /**
  40. * Returns the admin command the access right belongs to
  41. * @return the admin command the access right belongs to
  42. */
  43. public String getAdminCommand()
  44. {
  45. return _adminCommand;
  46. }
  47. /**
  48. * Checks if the given characterAccessLevel is allowed to use the admin command which belongs to this access right.
  49. * @param characterAccessLevel
  50. * @return true if characterAccessLevel is allowed to use the admin command which belongs to this access right, otherwise false<br>
  51. */
  52. public boolean hasAccess(L2AccessLevel characterAccessLevel)
  53. {
  54. L2AccessLevel accessLevel = AdminTable.getInstance().getAccessLevel(_accessLevel);
  55. return ((accessLevel.getLevel() == characterAccessLevel.getLevel()) || characterAccessLevel.hasChildAccess(accessLevel));
  56. }
  57. public boolean getRequireConfirm()
  58. {
  59. return _requireConfirm;
  60. }
  61. }