SendBypassBuildCmd.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 net.sf.l2j.gameserver.clientpackets;
  16. import java.util.logging.Logger;
  17. import net.sf.l2j.gameserver.datatables.AdminCommandAccessRights;
  18. import net.sf.l2j.gameserver.handler.AdminCommandHandler;
  19. import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  20. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  21. /**
  22. * This class handles all GM commands triggered by //command
  23. *
  24. * @version $Revision: 1.3.4.2 $ $Date: 2005/03/27 15:29:29 $
  25. */
  26. public final class SendBypassBuildCmd extends L2GameClientPacket
  27. {
  28. private static Logger _log = Logger.getLogger(SendBypassBuildCmd.class.getName());
  29. private static final String _C__5B_SENDBYPASSBUILDCMD = "[C] 5b SendBypassBuildCmd";
  30. public final static int GM_MESSAGE = 9;
  31. public final static int ANNOUNCEMENT = 10;
  32. private String _command;
  33. @Override
  34. protected void readImpl()
  35. {
  36. _command = readS();
  37. if (_command != null)
  38. _command = _command.trim();
  39. }
  40. @Override
  41. protected void runImpl()
  42. {
  43. L2PcInstance activeChar = getClient().getActiveChar();
  44. if(activeChar == null)
  45. return;
  46. String command = "admin_" + _command.split(" ")[0];
  47. IAdminCommandHandler ach = AdminCommandHandler.getInstance().getAdminCommandHandler(command);
  48. if (ach == null)
  49. {
  50. if ( activeChar.isGM() )
  51. activeChar.sendMessage("The command " + command.split("_")[0] + " does not exists!");
  52. _log.warning("No handler registered for admin command '" + command + "'");
  53. return;
  54. }
  55. if (!AdminCommandAccessRights.getInstance().hasAccess(command , activeChar.getAccessLevel()))
  56. {
  57. activeChar.sendMessage("You don't have the access right to use this command!");
  58. _log.warning("Character " + activeChar.getName() + " tryed to use admin command " + command + ", but have no access to it!");
  59. return;
  60. }
  61. ach.useAdminCommand("admin_" + _command, activeChar);
  62. }
  63. /* (non-Javadoc)
  64. * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()
  65. */
  66. @Override
  67. public String getType()
  68. {
  69. return _C__5B_SENDBYPASSBUILDCMD;
  70. }
  71. }