L2AdminCommandAccessRight.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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<br>
  19. */
  20. public class L2AdminCommandAccessRight
  21. {
  22. /** The admin command<br> */
  23. private String _adminCommand = null;
  24. /** The access levels which can use the admin command<br> */
  25. private int _accessLevel;
  26. private 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<br><br>
  41. *
  42. * @return String: the admin command the access right belongs to<br>
  43. */
  44. public String getAdminCommand()
  45. {
  46. return _adminCommand;
  47. }
  48. /**
  49. * Checks if the given characterAccessLevel is allowed to use the admin command which belongs to this access right<br><br>
  50. *
  51. * @param characterAccessLevel
  52. *
  53. * @return boolean: true if characterAccessLevel is allowed to use the admin command which belongs to this access right, otherwise false<br>
  54. */
  55. public boolean hasAccess(L2AccessLevel characterAccessLevel)
  56. {
  57. L2AccessLevel accessLevel = AdminTable.getInstance().getAccessLevel(_accessLevel);
  58. return (accessLevel.getLevel() == characterAccessLevel.getLevel() || characterAccessLevel.hasChildAccess(accessLevel));
  59. }
  60. public boolean getRequireConfirm()
  61. {
  62. return _requireConfirm;
  63. }
  64. }