SetVCmd.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 handlers.voicedcommandhandlers;
  16. import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
  17. import com.l2jserver.gameserver.model.L2Object;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.util.Util;
  20. /**
  21. * @author Zoey76
  22. */
  23. public class SetVCmd implements IVoicedCommandHandler
  24. {
  25. private static final String[] VOICED_COMMANDS =
  26. {
  27. "set name",
  28. "set home",
  29. "set group"
  30. };
  31. @Override
  32. public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  33. {
  34. if (command.equals("set"))
  35. {
  36. final L2Object target = activeChar.getTarget();
  37. if ((target == null) || !target.isPlayer())
  38. {
  39. return false;
  40. }
  41. final L2PcInstance player = activeChar.getTarget().getActingPlayer();
  42. if ((activeChar.getClan() == null) || (player.getClan() == null) || (activeChar.getClan().getClanId() != player.getClan().getClanId()))
  43. {
  44. return false;
  45. }
  46. if (params.startsWith("privileges"))
  47. {
  48. final String val = params.substring(11);
  49. if (!Util.isDigit(val))
  50. {
  51. return false;
  52. }
  53. final int n = Integer.parseInt(val);
  54. if (!((activeChar.getClanPrivileges() > n) || activeChar.isClanLeader()))
  55. {
  56. return false;
  57. }
  58. player.setClanPrivileges(n);
  59. activeChar.sendMessage("Your clan privileges have been set to " + n + " by " + activeChar.getName() + ".");
  60. }
  61. else if (params.startsWith("title"))
  62. {
  63. }
  64. }
  65. return true;
  66. }
  67. @Override
  68. public String[] getVoicedCommandList()
  69. {
  70. return VOICED_COMMANDS;
  71. }
  72. }