Jump to content

LioNa

Members
  • Posts

    22
  • Credits

  • Joined

  • Last visited

  • Feedback

    0%

About LioNa

Contact Methods

  • Website URL
    www.google.es

Profile Information

  • Gender
    Not Telling
  • Country
    Spain
  • Location
    España

Recent Profile Visitors

959 profile views

LioNa's Achievements

Newbie

Newbie (1/16)

  • Dedicated Rare
  • One Month Later Rare
  • One Year In Rare
  • Week One Done Rare

Recent Badges

0

Reputation

  1. NICCCCCCCCCC EEE
  2. You can also put without adding it to the table but then when you restart it puts the normal inventory sete
  3. Sure but it may have to change some parts of the code
  4. Hi all here you have a command to increase the inventory of Site = Slot if your PJ has 100 slot in your inventory and put the commands you have increases 20 slot for more items in the inventory. Imagen : Codigo : ### Eclipse Workspace Patch 1.0 #P L2J_Server Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java =================================================================== --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 5708) +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy) @ -286,9 +295,9 @@ private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE charId=? AND class_index=?"; // Character Character SQL String Definitions: - private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,createTime) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=? WHERE charId=?"; - private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, title_color, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot,vitality_points,createTime,language FROM characters WHERE charId=?"; + private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,createTime,moreslot) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,moreslot=? WHERE charId=?"; + private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, title_color, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,bookmarkslot,vitality_points,createTime,language,moreslot FROM characters WHERE charId=?"; // Character Teleport Bookmark: private static final String INSERT_TP_BOOKMARK = "INSERT INTO character_tpbookmark (charId,Id,x,y,z,icon,tag,name) values (?,?,?,?,?,?,?,?)"; @@ -538,6 +580,7 @@ private boolean _recoTwoHoursGiven = false; private final PcInventory _inventory = new PcInventory(this); + private int _moreslot = 0; private PcWarehouse _warehouse; private PcRefund _refund; @@ -7026,6 +7122,10 @@ statement.setInt(35, isNoble() ? 1 :0); statement.setLong(36, 0); statement.setLong(37,getCreateTime()); + statement.setInt(38, 0); statement.executeUpdate(); statement.close(); @@ -7224,6 +7324,16 @@ // Language player.setLang(rset.getString("language")); + player.setMoreSlot(rset.getInt("moreslot")); + // Retrieve the name and ID of the other characters assigned to this account. PreparedStatement stmt = con.prepareStatement("SELECT charId, char_name FROM characters WHERE account_name=? AND charId<>?"); stmt.setString(1, player._accountName); @@ -7665,7 +7775,11 @@ statement.setInt(50, getBookMarkSlot()); statement.setInt(51, getVitalityPoints()); statement.setString(52, getLang()); - statement.setInt(53, getObjectId()); + statement.setInt(53, getMoreSlot()); + statement.setInt(54, getObjectId()); statement.execute(); statement.close(); @@ -12206,56 +12342,98 @@ { int ivlim; if (isGM()) - ivlim = Config.INVENTORY_MAXIMUM_GM; + ivlim = Config.INVENTORY_MAXIMUM_GM + _moreslot; else if (getRace() == Race.Dwarf) - ivlim = Config.INVENTORY_MAXIMUM_DWARF; + ivlim = Config.INVENTORY_MAXIMUM_DWARF + _moreslot; else - ivlim = Config.INVENTORY_MAXIMUM_NO_DWARF; + ivlim = Config.INVENTORY_MAXIMUM_NO_DWARF + _moreslot; ivlim += (int)getStat().calcStat(Stats.INV_LIM, 0, null, null); return ivlim; } + public void setMoreSlot(int quantity) + { + _moreslot += quantity; + } + + public int getMoreSlot() + { + return _moreslot; + } + Let data\scripts\handlers\voicedcommandhandlers -> and create a file called slotinventario.java and paste this code /* * 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 com.l2jserver.gameserver.handler.IVoicedCommandHandler; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.network.clientpackets.Say2; import com.l2jserver.gameserver.network.serverpackets.CreatureSay; import com.l2jserver.gameserver.network.serverpackets.ExPrivateStoreSetWholeMsg; import com.l2jserver.gameserver.network.serverpackets.ExStorageMaxCount; import com.l2jserver.gameserver.network.serverpackets.SocialAction; /** * @author Lobillo */ public class slotinventario implements IVoicedCommandHandler { private static final String[] _voicedCommands = { "buyslot" }; /** * * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance, java.lang.String) */ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params) { if (command.equalsIgnoreCase("buyslot")) { if (activeChar.getLevel() < 40) { CreatureSay e = new CreatureSay(activeChar.getObjectId(), Say2.PARTY, "NAME", "Tienes que ser LvL 40 o mas!"); activeChar.sendPacket( e ); return true; } else if(activeChar.getInventory().getItemByItemId(3470) != null && activeChar.getInventory().getItemByItemId(3470).getCount() >= 100) { activeChar.getInventory().destroyItemByItemId("buyslot", 3470, 100, activeChar, activeChar.getTarget()); activeChar.setMoreSlot(20); activeChar.sendPacket(new ExStorageMaxCount(activeChar)); activeChar.sendPacket(new ExPrivateStoreSetWholeMsg(activeChar)); activeChar.broadcastPacket(new SocialAction(activeChar,2122)); CreatureSay i = new CreatureSay(activeChar.getObjectId(), Say2.BATTLEFIELD, "NAME", "Tienes +20 Slots en el Inventario!"); activeChar.broadcastUserInfo(); activeChar.sendPacket( i ); } else { CreatureSay o = new CreatureSay(activeChar.getObjectId(), Say2.TELL, "NAME", "Tienes que tener 100 Event-Apiga!"); activeChar.sendPacket( o ); return true; } } return true; } /** * * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList() */ public String[] getVoicedCommandList() { return _voicedCommands; } } Let data\scripts\handlers -> and edit the file -> MasterHandler.java import handlers.voicedcommandhandlers.stats; +import handlers.voicedcommandhandlers.slotinventario; + VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new slotinventario()); VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new stats()); SQL Create a SQL file and get this and add it to navicat ALTER TABLE characters ADD moreslot int(10) NOT NULL DEFAULT 0 and finally you have to put .buyslot Creaditos -> Lobillo
  5. look now happens to be using freya to h5
  6. and it will put the patch
  7. I and implemented in the Community Board :D
  8. many Thanks Soon I will upload more stuff :D
  9. Hi all Well I leave to give an item that gives you double clip and other +15 +30 Buff Is Item is BiggBoss but I have one little and edited and removed some things. http://www.mediafire.com/?n4f47wb4cc6h62w
  10. Well I bring the drop of mobs panel for darule player is the one I e areglao little credits are sullos but as people get erroes wing and lacks things fit and finish and aregarlo etc. Imagenes : game\data\scripts\handlers -> MasterHandler import handlers.bypasshandlers.VoiceCommand; import handlers.bypasshandlers.Wear; +import handlers.bypasshandlers.DropInfo; %%%%%%%%%%%%%%%%%%%%%%% BypassHandler.getInstance().registerBypassHandler(new VoiceCommand()); BypassHandler.getInstance().registerBypassHandler(new Wear()); + BypassHandler.getInstance().registerBypassHandler(new DropInfo()); L2jserver Freya http://www.mediafire.com/?yte7gd4cqml778l L2jserver H5 http://www.mediafire.com/?8hldd6v5csbke4d :) :)
  11. Well I bring the drop of mobs panel for darule player is the one I e areglao little credits are sullos but as people get erroes wing and lacks things fit and finish and aregarlo etc. Imagenes : game\data\scripts\handlers -> MasterHandler import handlers.bypasshandlers.VoiceCommand; import handlers.bypasshandlers.Wear; +import handlers.bypasshandlers.DropInfo; %%%%%%%%%%%%%%%%%%%%%%% BypassHandler.getInstance().registerBypassHandler(new VoiceCommand()); BypassHandler.getInstance().registerBypassHandler(new Wear()); + BypassHandler.getInstance().registerBypassHandler(new DropInfo()); http://www.mediafire.com/?yte7gd4cqml778l
  12. next version: Contains the window to sell items to sell buff. Areglado error when you wake sete change the name and title color as you had before selling buff. etc sorry for my English
  13. Well this is a PJ that sells its buff - and adapted it for Freya l2jserver ######################################### ######### Algunas Cosillas Mejoradas ######### ######################################### 1ª | Command Buff to Sell .SellBuffs 2ª | New Command to Rise .CancelSellBuffs 3ª | You can change the title from l2jmods.properties 4ª | When you see Buff and no need to remove the Target and give again and give him only with k leaves you to buff new tab. 5ª | Fixed error Adena http://img22.imageshack.us/img22/9148/shot00007lj.jpg http://img4.imageshack.us/img4/7599/shot00008os.jpg Esto va en Eclipse =================================================================== --- head-src/com/l2jserver/Config.java +++ head-src/com/l2jserver/Config.java public static boolean L2JMOD_ENABLE_WAREHOUSESORTING_PRIVATE; + public static String ADD_TITULO_PJ_SELLBUFS; =================================================================== L2JMOD_ENABLE_WAREHOUSESORTING_PRIVATE = Boolean.valueOf(L2JModSettings.getProperty("EnableWarehouseSortingPrivate", "False")); + ADD_TITULO_PJ_SELLBUFS = L2JModSettings.getProperty("TituloPjSellBuffs", "BUFF"); =================================================================== --- head-src/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java +++ head-src/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java @@ -31,6 +31,7 @@ import java.util.concurrent.locks.ReentrantLock; import java.util.logging.Level; +import javolution.text.TextBuilder; import javolution.util.FastList; import javolution.util.FastMap; import com.l2jserver.Config; @@ -451,6 +452,8 @@ private boolean _noble = false; private boolean _hero = false; + private boolean _sellbuff = false; + private int _buffprize = 0; + private String _oldtitle = ""; + private int _oldnamecolor = 0; + /** The L2FolkInstance corresponding to the last Folk wich one the player talked. */ private L2FolkInstance _lastFolkNpc = null; @@ -2375,6 +2378,9 @@ */ public void standUp() { + if(isSellBuff()) + return; + if (L2Event.active && eventSitForced) { sendMessage("A dark force beyond your mortal understanding makes your knees to shake when you try to stand up ..."); @@ -3945,6 +3951,42 @@ // Target the new L2Object (add the target to the L2PcInstance _target, _knownObject and L2PcInstance to _KnownObject of the L2Object) super.setTarget(newTarget); + + L2PcInstance t = null; + if(newTarget instanceof L2PcInstance) + t = (L2PcInstance) newTarget; + + if(t != null){ + if(t.isSellBuff() && t != this){ + TextBuilder tb = new TextBuilder(); + NpcHtmlMessage n = new NpcHtmlMessage(0); + + tb.append("<html><body>"); + tb.append("<br><br>"); + tb.append("<center>Hola <font color=LEVEL>Campesin@</font> Quieres Buff!</center>"); + tb.append("<br><center>Mis Buff Cuestan: <font color=LEVEL>"+t.getBuffPrize()+"</font> Adenas cada uno!</center><br><center><table><tr>"); + + L2Skill[] skills = t.getAllSkills(); + FastList<L2Skill> ba = new FastList<L2Skill>(); + + for(L2Skill s : skills){ + if(s == null) + continue; + + + if(s.getSkillType() == L2SkillType.BUFF && s.isActive() && s.getId() != 970 && s.getId() != 357 && s.getId() != 1323 && s.getId() != 327 && s.getId() != 1325 && s.getId() != 1326 && s.getId() != 1327) + ba.add(s); + } + + for(L2Skill p : ba){ + tb.append("<td><button action=\"bypass -h buff "+p.getId()+"\" width=32 height=32 back=\"Icon.skill"+p.getId()+"\" fore=\"Icon.skill"+p.getId()+"\"></td>"); + tb.append("<td><button value=\""+p.getName()+"\" action=\"bypass -h buff "+p.getId()+"\" width=200 height=32 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>"); + tb.append("<td><button action=\"bypass -h buff "+p.getId()+"\" width=32 height=32 back=\"Icon.skill"+p.getId()+"\" fore=\"Icon.skill"+p.getId()+"\"></td></tr><tr>"); + } + + tb.append("</tr></table></center></body></html>"); + + n.setHtml(tb.toString()); + sendPacket(n); + } + } } /** @@ -8214,7 +8256,23 @@ } return true; } + public boolean isSellBuff(){ + return _sellbuff; + } + + public void setSellBuff(boolean j){ + _sellbuff = j; + } + + public int getBuffPrize(){ + return _buffprize; + } + + public void setBuffPrize(int x){ + _buffprize = x; + } + + public String getOldTitle() + { + return _oldtitle; + } + + public int getOldNameColor() + { + return _oldnamecolor; + } + + public void setOldTitle(String title) + { + _oldtitle = title; + } + + public void setOldNameColor(int color) + { + _oldnamecolor = color; + } + public boolean isNoble() { return _noble; =================================================================== --- head-src/com/l2jserver/gameserver/clientpackets/RequestBypassToServer.java +++ head-src/com/l2jserver/gameserver/clientpackets/RequestBypassToServer.java @@ -18,16 +18,20 @@ */ package com.l2jserver.gameserver.network.clientpackets; import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; import com.l2jserver.Config; import com.l2jserver.gameserver.ai.CtrlIntention; import com.l2jserver.gameserver.communitybbs.CommunityBoard; import com.l2jserver.gameserver.datatables.AdminCommandAccessRights; +import com.l2jserver.gameserver.datatables.SkillTable; import com.l2jserver.gameserver.handler.AdminCommandHandler; import com.l2jserver.gameserver.handler.BypassHandler; import com.l2jserver.gameserver.handler.IAdminCommandHandler; import com.l2jserver.gameserver.handler.IBypassHandler; import com.l2jserver.gameserver.model.L2CharPosition; import com.l2jserver.gameserver.model.L2Object; +import com.l2jserver.gameserver.model.L2Skill; import com.l2jserver.gameserver.model.L2World; import com.l2jserver.gameserver.model.actor.L2Npc; import com.l2jserver.gameserver.model.actor.instance.L2MerchantSummonInstance; @@ -85,6 +89,57 @@ { comeHere(activeChar); } + else if(_command.startsWith("buff")){ + String[] val = _command.split(" "); + String x = val[1]; + int id = Integer.parseInt(x); + L2PcInstance target = null; + + if(activeChar.getTarget() instanceof L2PcInstance) + target = (L2PcInstance) activeChar.getTarget(); + + if(target == null) + return; + + if(activeChar.getInventory().getItemByItemId(57) == null || activeChar.getInventory().getItemByItemId(57).getCount() < ((L2PcInstance) activeChar.getTarget()).getBuffPrize()){ + activeChar.sendMessage("* No tienes adena!"); + return; + } + + + try{ + L2Skill s = SkillTable.getInstance().getInfo(id, 3); + s.getEffects(activeChar, activeChar); + activeChar.sendMessage("* Has Comprado: "+s.getName()); + activeChar.getInventory().destroyItemByItemId("", 57, target.getBuffPrize(), activeChar, null); + target.getInventory().addItem("", 57, target.getBuffPrize(), target, null); + TextBuilder tb = new TextBuilder(); + NpcHtmlMessage n = new NpcHtmlMessage(0); + + tb.append("<html><body>"); + tb.append("<br><br>"); + tb.append("<center>Hola <font color=LEVEL>Campesin@</font> Quieres Buff!</center>"); + tb.append("<br><center>Mis Buff Cuestan: <font color=LEVEL>"+target.getBuffPrize()+"</font> Adenas cada uno!</center><br><center><table><tr>"); + + + L2Skill[] skills = target.getAllSkills(); + FastList<L2Skill> ba = new FastList<L2Skill>(); + + for(L2Skill skill : skills){ + if(skill == null) + continue; + + + if(skill.getSkillType() == L2SkillType.BUFF && skill.isActive() && skill.getId() != 970 && skill.getId() != 357 && skill.getId() != 1323 && skill.getId() != 327 && skill.getId() != 1325 && skill.getId() != 1326 && skill.getId() != 1327) + ba.add(skill); + } + + for(L2Skill p : ba){ + tb.append("<td><button action=\"bypass -h buff "+p.getId()+"\" width=32 height=32 back=\"Icon.skill"+p.getId()+"\" fore=\"Icon.skill"+p.getId()+"\"></td>"); + tb.append("<td><button value=\""+p.getName()+"\" action=\"bypass -h buff "+p.getId()+"\" width=200 height=32 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>"); + tb.append("<td><button action=\"bypass -h buff "+p.getId()+"\" width=32 height=32 back=\"Icon.skill"+p.getId()+"\" fore=\"Icon.skill"+p.getId()+"\"></td></tr><tr>"); + } + + tb.append("</tr></table></center></body></html>"); + + n.setHtml(tb.toString()); + activeChar.sendPacket(n); + } + catch(Exception e){ + e.printStackTrace(); + } + } + else if(_command.startsWith("actr")){ + String l = _command.substring(5); + + int p = 0; + + p = Integer.parseInt(l); + + + if(p == 0) + return; + + if(p > 2000000000){ + activeChar.sendMessage("* Te has colado el limite de Adena!"); + return; + } + + activeChar.setBuffPrize(p); + activeChar.sitDown(); + activeChar.setTeam(1); + activeChar.setSellBuff(true); + activeChar.setOldTitle(activeChar.getTitle()); + activeChar.setOldNameColor(activeChar.getAppearance().getNameColor()); + /*activeChar.getAppearance().setNameColor(0x55155);*/ + activeChar.getAppearance().setNameColor(99, 22, 11); + activeChar.setTitle(Config.ADD_TITULO_PJ_SELLBUFS); + activeChar.broadcastUserInfo(); + activeChar.broadcastTitleInfo(); + } else if (_command.startsWith("player_help ")) { playerHelp(activeChar, _command.substring(12)); Cuando pongamos este codigo guardams y copilamos. Luego bamos a Ruta --> game\data\scripts\handlers y abrimos el MasterHandler y añadimos y guardamos y luego bamos a ruta --> game\data\scripts\handlers\voicedcommandhandlers y creamos un archivo llamado --> sellbuff y le añadimos el codigo Luego bamos a ruta -> game\config y abrimas el archivo l2jmods.properties y le agregamos EnableWarehouseSortingPrivate = False + +########################### +#### TITULO SELLBUFFS ##### +########################### +# TITULO PARA VENDER BUFF +TituloPjSellBuffs = * VENDO BUFF * Creditos : Lobillo , LioNa and Save and you're all set if it works do not forget to give the + sorry with my English
  14. game\data\scripts\handlers\voicedcommandhandlers -> Create ChangePassword.java /* * 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.security.MessageDigest; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.StringTokenizer; import java.util.logging.Level; import com.l2jserver.Base64; import com.l2jserver.L2DatabaseFactory; import com.l2jserver.gameserver.handler.IVoicedCommandHandler; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; public class ChangePassword implements IVoicedCommandHandler { private static final String[] _voicedCommands = { "changepassword" }; private static final int MIN = 6; // minimum character lengths private static final int MAX = 30; // miaximum character lengths @Override public boolean useVoicedCommand(final String command, final L2PcInstance activeChar, final String target) { if (command.equalsIgnoreCase("changepassword") && target != null) { final 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("Your repeated password must be the same as new password!"); return false; } if (newpass.length() < MIN) { activeChar.sendMessage("Your password must have min: " + MIN + " chars!"); return false; } if (newpass.length() > MAX) { activeChar.sendMessage("Your password can't have more than " + MAX + " chars!"); return false; } final MessageDigest md = MessageDigest.getInstance("SHA"); byte[] raw = curpass.getBytes("UTF-8"); raw = md.digest(raw); final String curpassEnc = Base64.encodeBytes(raw); String pass = null; int passUpdated = 0; Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); final PreparedStatement statement = con.prepareStatement("SELECT password FROM accounts WHERE login=?"); statement.setString(1, activeChar.getAccountName()); final ResultSet rset = statement.executeQuery(); if (rset.next()) pass = rset.getString("password"); rset.close(); statement.close(); if (curpassEnc.equals(pass)) { byte[] password = newpass.getBytes("UTF-8"); password = md.digest(password); final PreparedStatement ps = con.prepareStatement("UPDATE accounts SET password=? WHERE login=?"); ps.setString(1, Base64.encodeBytes(password)); ps.setString(2, activeChar.getAccountName()); passUpdated = ps.executeUpdate(); ps.close(); _log.info("Character " + activeChar.getName() + " has changed his password from " + curpassEnc + " to " + Base64.encodeBytes(password)); if (passUpdated > 0) activeChar.sendMessage("Your password was updated successfully!"); else activeChar.sendMessage("Your password wasn't changed due troubles!"); } else { L2DatabaseFactory.close(con); activeChar.sendMessage("Passess not matches."); return false; } } catch (final Exception e) { } finally { L2DatabaseFactory.close(con); } } else { activeChar.sendMessage("Wrong command structure! Use: .changepassword currendPassword newPassword retypePassword"); return false; } } catch (final Exception e) { activeChar.sendMessage("A problem occured while changing password!"); _log.log(Level.WARNING, "", e); } } else { activeChar.sendMessage("Wrong command structure! Use: .changepassword currendPassword newPassword retypePassword"); return false; } return true; } @Override public String[] getVoicedCommandList() { return _voicedCommands; } }
×
×
  • Create New...