Guest User

command dp

a guest
Nov 26th, 2014
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.90 KB | None | 0 0
  1. Index: dist/game/data/html/mods/ChangePassword.htm
  2. ===================================================================
  3. --- dist/game/data/html/mods/ChangePassword.htm (revision 0)
  4. +++ dist/game/data/html/mods/ChangePassword.htm (working copy)
  5. @@ -0,0 +1,10 @@
  6. +<html><body>
  7. +<center>
  8. +<td>
  9. +<tr>Current Password:</tr><tr><edit type="password" var="oldpass" width=150></tr><br>
  10. +<tr>New Password</tr><tr><edit type="password" var="newpass" width=150></tr><br>
  11. +<tr>Repeat New Password</tr><tr><edit type="password" var="repeatnewpass" width=150></tr><br>
  12. +<td>
  13. +<button value="Change Password" action="bypass -h voice .changepassword $oldpass $newpass $repeatnewpass" width=160 height=25 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
  14. +</center>
  15. +</body></html>
  16. \ No newline at end of file
  17. Index: dist/game/data/scripts/handlers/MasterHandler.java
  18. ===================================================================
  19. --- dist/game/data/scripts/handlers/MasterHandler.java  (revision 9149)
  20. +++ dist/game/data/scripts/handlers/MasterHandler.java  (working copy)
  21. @@ -240,6 +240,7 @@
  22.  import handlers.usercommandhandlers.PartyInfo;
  23.  import handlers.usercommandhandlers.Time;
  24.  import handlers.voicedcommandhandlers.Banking;
  25. +import handlers.voicedcommandhandlers.ChangePassword;
  26.  import handlers.voicedcommandhandlers.ChatAdmin;
  27.  import handlers.voicedcommandhandlers.Debug;
  28.  import handlers.voicedcommandhandlers.Lang;
  29. @@ -548,6 +549,7 @@
  30.             VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Lang());
  31.         if (Config.L2JMOD_DEBUG_VOICE_COMMAND)
  32.             VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Debug());
  33. +       VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new ChangePassword());
  34.         _log.config("Loaded " + VoicedCommandHandler.getInstance().size() + " VoicedHandlers");
  35.     }
  36.    
  37. Index: dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java
  38. ===================================================================
  39. --- dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java   (revision 0)
  40. +++ dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java   (working copy)
  41. @@ -0,0 +1,99 @@
  42. +/*
  43. + * This program is free software: you can redistribute it and/or modify it under
  44. + * the terms of the GNU General Public License as published by the Free Software
  45. + * Foundation, either version 3 of the License, or (at your option) any later
  46. + * version.
  47. + *
  48. + * This program is distributed in the hope that it will be useful, but WITHOUT
  49. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  50. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  51. + * details.
  52. + *
  53. + * You should have received a copy of the GNU General Public License along with
  54. + * this program. If not, see <http://www.gnu.org/licenses/>.
  55. + */
  56. +package handlers.voicedcommandhandlers;
  57. +
  58. +import java.util.StringTokenizer;
  59. +import java.util.logging.Level;
  60. +
  61. +import com.l2jserver.gameserver.LoginServerThread;
  62. +import com.l2jserver.gameserver.cache.HtmCache;
  63. +import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
  64. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  65. +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  66. +
  67. +
  68. +/**
  69. + *
  70. + * @author Nik
  71. + *
  72. + */
  73. +public class ChangePassword implements IVoicedCommandHandler
  74. +{
  75. +        private static final String[] _voicedCommands =
  76. +        {
  77. +                "changepassword"
  78. +        };
  79. +      
  80. +        public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
  81. +        {
  82. +                if (target != null)
  83. +                {
  84. +                        StringTokenizer st = new StringTokenizer(target);
  85. +                        try
  86. +                        {
  87. +                                String curpass = null, newpass = null, repeatnewpass = null;
  88. +                                if (st.hasMoreTokens()) curpass = st.nextToken();
  89. +                                if (st.hasMoreTokens()) newpass = st.nextToken();
  90. +                                if (st.hasMoreTokens()) repeatnewpass = st.nextToken();
  91. +                              
  92. +                                if (!(curpass == null || newpass == null || repeatnewpass == null))
  93. +                                {
  94. +                                        if (!newpass.equals(repeatnewpass))
  95. +                                        {
  96. +                                                activeChar.sendMessage("The new password doesn't match with the repeated one!");
  97. +                                                return false;
  98. +                                        }
  99. +                                        if (newpass.length() < 3)
  100. +                                        {
  101. +                                                activeChar.sendMessage("The new password is shorter than 3 chars! Please try with a longer one.");
  102. +                                                return false;
  103. +                                        }
  104. +                                        if (newpass.length() > 30)
  105. +                                        {
  106. +                                                activeChar.sendMessage("The new password is longer than 30 chars! Please try with a shorter one.");
  107. +                                                return false;
  108. +                                        }
  109. +                                  
  110. +                                        LoginServerThread.getInstance().sendChangePassword(activeChar.getAccountName(), activeChar.getName(), curpass, newpass);
  111. +                                }
  112. +                                else
  113. +                                {
  114. +                                        activeChar.sendMessage("Invalid password data! You have to fill all boxes.");
  115. +                                        return false;
  116. +                                }
  117. +                        }
  118. +                        catch (Exception e)
  119. +                        {
  120. +                                activeChar.sendMessage("A problem occured while changing password!");
  121. +                                _log.log(Level.WARNING, "", e);
  122. +                        }
  123. +                }
  124. +                else
  125. +                {
  126. +                        //showHTML(activeChar);
  127. +                        String html = HtmCache.getInstance().getHtm("en", "data/html/mods/ChangePassword.htm");
  128. +                        if (html == null)
  129. +                                html = "<html><body><br><br><center><font color=LEVEL>404:</font> File Not Found</center></body></html>";
  130. +                        activeChar.sendPacket(new NpcHtmlMessage(1, html));
  131. +                        return true;
  132. +                }
  133. +                return true;
  134. +        }
  135. +
  136. +        public String[] getVoicedCommandList()
  137. +        {
  138. +                return _voicedCommands;
  139. +        }
  140. +}
  141. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment