Advertisement
horato

Claninvite

Sep 18th, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.55 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2J_DataPack_BETA
  3. Index: data/scripts/handlers/MasterHandler.java
  4. ===================================================================
  5. --- data/scripts/handlers/MasterHandler.java (revision 8223)
  6. +++ data/scripts/handlers/MasterHandler.java (working copy)
  7. @@ -243,8 +245,10 @@
  8. import handlers.usercommandhandlers.OlympiadStat;
  9. import handlers.usercommandhandlers.PartyInfo;
  10. import handlers.usercommandhandlers.Time;
  11. import handlers.voicedcommandhandlers.Banking;
  12. import handlers.voicedcommandhandlers.ChatAdmin;
  13. +import handlers.voicedcommandhandlers.Clan;
  14. import handlers.voicedcommandhandlers.Debug;
  15. import handlers.voicedcommandhandlers.Lang;
  16. import handlers.voicedcommandhandlers.TvTVoicedInfo;
  17. @@ -563,6 +569,8 @@
  18. VOICE.registerVoicedCommandHandler(new Lang());
  19. if (Config.L2JMOD_DEBUG_VOICE_COMMAND)
  20. VOICE.registerVoicedCommandHandler(new Debug());
  21. + VOICE.registerVoicedCommandHandler(new Clan());
  22. _log.config("Loaded " + VOICE.size() + " VoicedHandlers");
  23. }
  24.  
  25. Index: data/scripts/handlers/voicedcommandhandlers/Clan.java
  26. ===================================================================
  27. --- data/scripts/handlers/voicedcommandhandlers/Clan.java (revision 0)
  28. +++ data/scripts/handlers/voicedcommandhandlers/Clan.java (revision 0)
  29. @@ -0,0 +1,102 @@
  30. +/*
  31. + * This program is free software: you can redistribute it and/or modify it under
  32. + * the terms of the GNU General Public License as published by the Free Software
  33. + * Foundation, either version 3 of the License, or (at your option) any later
  34. + * version.
  35. + *
  36. + * This program is distributed in the hope that it will be useful, but WITHOUT
  37. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  38. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  39. + * details.
  40. + *
  41. + * You should have received a copy of the GNU General Public License along with
  42. + * this program. If not, see <http://www.gnu.org/licenses/>.
  43. + */
  44. +package handlers.voicedcommandhandlers;
  45. +
  46. +import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
  47. +import com.l2jserver.gameserver.model.L2Clan.SubPledge;
  48. +import com.l2jserver.gameserver.model.L2World;
  49. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  50. +import com.l2jserver.gameserver.network.clientpackets.RequestJoinPledge;
  51. +import com.l2jserver.gameserver.network.serverpackets.AskJoinPledge;
  52. +
  53. +/**
  54. + *
  55. + * @author horato
  56. + *
  57. + * Handler for claninvite command
  58. + *
  59. + */
  60. +public class Clan implements IVoicedCommandHandler
  61. +{
  62. + private static final String[] VOICED_COMMANDS = { "claninvite" };
  63. +
  64. + /**
  65. + *
  66. + * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
  67. + */
  68. + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  69. + {
  70. + if (command.startsWith("claninvite"))
  71. + {
  72. + if (params != null && params.length() > 3)
  73. + invite(activeChar, params);
  74. + else
  75. + activeChar.sendMessage("Usage: .claninvite <playerName> <subpledgeName>");
  76. + }
  77. + return true;
  78. + }
  79. +
  80. + private void invite(L2PcInstance activeChar, String params)
  81. + {
  82. + if (activeChar == null)
  83. + return;
  84. + if (activeChar.getClan() == null)
  85. + {
  86. + activeChar.sendMessage("You are not in any clan");
  87. + return;
  88. + }
  89. + L2PcInstance player = L2World.getInstance().getPlayer(params.split(" ")[0]);
  90. +
  91. + SubPledge subPledge = null;
  92. + try
  93. + {
  94. + subPledge = activeChar.getClan().getSubPledge(params.split(" ")[1]);
  95. + }
  96. + catch (Exception e)
  97. + {
  98. +
  99. + }
  100. +
  101. + if (!activeChar.getClan().checkClanJoinCondition(activeChar, player, subPledge == null ? 0 : subPledge.getId()))
  102. + return;
  103. +
  104. + try
  105. + {
  106. + RequestJoinPledge rjp = new RequestJoinPledge();
  107. + rjp.setTarget(player.getObjectId());
  108. + rjp.setPledgeType(subPledge == null ? 0 : subPledge.getId());
  109. + if (!activeChar.getRequest().setRequest(player, rjp))
  110. + return;
  111. + }
  112. + catch (Exception e)
  113. + {
  114. + e.printStackTrace();
  115. + }
  116. +
  117. + if (subPledge == null)
  118. + player.sendPacket(new AskJoinPledge(activeChar.getObjectId(), null, 0, activeChar.getClan().getName()));
  119. + else
  120. + player.sendPacket(new AskJoinPledge(activeChar.getObjectId(), activeChar.getClan().getName(), subPledge.getId(), subPledge.getName()));
  121. + }
  122. +
  123. + /**
  124. + *
  125. + * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
  126. + */
  127. + public String[] getVoicedCommandList()
  128. + {
  129. + return VOICED_COMMANDS;
  130. + }
  131. +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement