Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: dist/game/data/html/mods/ChangePassword.htm
- ===================================================================
- --- dist/game/data/html/mods/ChangePassword.htm (revision 0)
- +++ dist/game/data/html/mods/ChangePassword.htm (working copy)
- @@ -0,0 +1,10 @@
- +<html><body>
- +<center>
- +<td>
- +<tr>Current Password:</tr><tr><edit type="password" var="oldpass" width=150></tr><br>
- +<tr>New Password</tr><tr><edit type="password" var="newpass" width=150></tr><br>
- +<tr>Repeat New Password</tr><tr><edit type="password" var="repeatnewpass" width=150></tr><br>
- +<td>
- +<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">
- +</center>
- +</body></html>
- \ No newline at end of file
- Index: dist/game/data/scripts/handlers/MasterHandler.java
- ===================================================================
- --- dist/game/data/scripts/handlers/MasterHandler.java (revision 9149)
- +++ dist/game/data/scripts/handlers/MasterHandler.java (working copy)
- @@ -240,6 +240,7 @@
- import handlers.usercommandhandlers.PartyInfo;
- import handlers.usercommandhandlers.Time;
- import handlers.voicedcommandhandlers.Banking;
- +import handlers.voicedcommandhandlers.ChangePassword;
- import handlers.voicedcommandhandlers.ChatAdmin;
- import handlers.voicedcommandhandlers.Debug;
- import handlers.voicedcommandhandlers.Lang;
- @@ -548,6 +549,7 @@
- VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Lang());
- if (Config.L2JMOD_DEBUG_VOICE_COMMAND)
- VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Debug());
- + VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new ChangePassword());
- _log.config("Loaded " + VoicedCommandHandler.getInstance().size() + " VoicedHandlers");
- }
- Index: dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java
- ===================================================================
- --- dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java (revision 0)
- +++ dist/game/data/scripts/handlers/voicedcommandhandlers/ChangePassword.java (working copy)
- @@ -0,0 +1,99 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package handlers.voicedcommandhandlers;
- +
- +import java.util.StringTokenizer;
- +import java.util.logging.Level;
- +
- +import com.l2jserver.gameserver.LoginServerThread;
- +import com.l2jserver.gameserver.cache.HtmCache;
- +import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
- +
- +
- +/**
- + *
- + * @author Nik
- + *
- + */
- +public class ChangePassword implements IVoicedCommandHandler
- +{
- + private static final String[] _voicedCommands =
- + {
- + "changepassword"
- + };
- +
- + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
- + {
- + if (target != null)
- + {
- + StringTokenizer st = new StringTokenizer(target);
- + try
- + {
- + String curpass = null, newpass = null, repeatnewpass = null;
- + if (st.hasMoreTokens()) curpass = st.nextToken();
- + if (st.hasMoreTokens()) newpass = st.nextToken();
- + if (st.hasMoreTokens()) repeatnewpass = st.nextToken();
- +
- + if (!(curpass == null || newpass == null || repeatnewpass == null))
- + {
- + if (!newpass.equals(repeatnewpass))
- + {
- + activeChar.sendMessage("The new password doesn't match with the repeated one!");
- + return false;
- + }
- + if (newpass.length() < 3)
- + {
- + activeChar.sendMessage("The new password is shorter than 3 chars! Please try with a longer one.");
- + return false;
- + }
- + if (newpass.length() > 30)
- + {
- + activeChar.sendMessage("The new password is longer than 30 chars! Please try with a shorter one.");
- + return false;
- + }
- +
- + LoginServerThread.getInstance().sendChangePassword(activeChar.getAccountName(), activeChar.getName(), curpass, newpass);
- + }
- + else
- + {
- + activeChar.sendMessage("Invalid password data! You have to fill all boxes.");
- + return false;
- + }
- + }
- + catch (Exception e)
- + {
- + activeChar.sendMessage("A problem occured while changing password!");
- + _log.log(Level.WARNING, "", e);
- + }
- + }
- + else
- + {
- + //showHTML(activeChar);
- + String html = HtmCache.getInstance().getHtm("en", "data/html/mods/ChangePassword.htm");
- + if (html == null)
- + html = "<html><body><br><br><center><font color=LEVEL>404:</font> File Not Found</center></body></html>";
- + activeChar.sendPacket(new NpcHtmlMessage(1, html));
- + return true;
- + }
- + return true;
- + }
- +
- + public String[] getVoicedCommandList()
- + {
- + return _voicedCommands;
- + }
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment