SetVCmd.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack 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 DataPack 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 handlers.voicedcommandhandlers;
  20. import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
  21. import com.l2jserver.gameserver.model.L2Object;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.util.Util;
  24. /**
  25. * @author Zoey76
  26. */
  27. public class SetVCmd implements IVoicedCommandHandler
  28. {
  29. private static final String[] VOICED_COMMANDS =
  30. {
  31. "set name",
  32. "set home",
  33. "set group"
  34. };
  35. @Override
  36. public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  37. {
  38. if (command.equals("set"))
  39. {
  40. final L2Object target = activeChar.getTarget();
  41. if ((target == null) || !target.isPlayer())
  42. {
  43. return false;
  44. }
  45. final L2PcInstance player = activeChar.getTarget().getActingPlayer();
  46. if ((activeChar.getClan() == null) || (player.getClan() == null) || (activeChar.getClan().getId() != player.getClan().getId()))
  47. {
  48. return false;
  49. }
  50. if (params.startsWith("privileges"))
  51. {
  52. final String val = params.substring(11);
  53. if (!Util.isDigit(val))
  54. {
  55. return false;
  56. }
  57. final int n = Integer.parseInt(val);
  58. if ((activeChar.getClanPrivileges().getBitmask() <= n) || !activeChar.isClanLeader())
  59. {
  60. return false;
  61. }
  62. player.getClanPrivileges().setBitmask(n);
  63. activeChar.sendMessage("Your clan privileges have been set to " + n + " by " + activeChar.getName() + ".");
  64. }
  65. else if (params.startsWith("title"))
  66. {
  67. // TODO why is this empty?
  68. }
  69. }
  70. return true;
  71. }
  72. @Override
  73. public String[] getVoicedCommandList()
  74. {
  75. return VOICED_COMMANDS;
  76. }
  77. }