All pastes #17717 Raw Edit

Something

public java v1 · immutable
#17717 ·published 2005-07-14 23:13 UTC
rendered paste body
/* * 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 2, 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * http://www.gnu.org/copyleft/gpl.html */package net.sf.l2j.gameserver.clientpackets;import java.nio.ByteBuffer;import java.util.logging.Logger;import net.sf.l2j.Config;import net.sf.l2j.gameserver.ClientThread;import net.sf.l2j.gameserver.ClientScheduler;//import net.sf.l2j.gameserver.ai.CtrlIntention;import net.sf.l2j.gameserver.handler.IItemHandler;import net.sf.l2j.gameserver.handler.ItemHandler;import net.sf.l2j.gameserver.model.L2ItemInstance;import net.sf.l2j.gameserver.model.L2PcInstance;import net.sf.l2j.gameserver.serverpackets.ExAutoSoulShot;import net.sf.l2j.gameserver.serverpackets.SystemMessage;/** * This class ... *  * @version $Revision: 1.0.0.0 $ $Date: 2005/07/11 15:29:30 $ */public class RequestAutoSoulShot extends ClientBasePacket{	private static final String _C__CF_REQUESTAUTOSOULSHOT = "[C] CF RequestAutoSoulShot";	private static Logger _log = Logger.getLogger(RequestAutoSoulShot.class.getName());		// format  cd	private final int _unknown;     //usually 5 ???	private final int _itemId;	private final int _type;       // 1 = on : 0 = off;	/**	 * packet type id 0xcf	 * format:		chdd	 * @param decrypt	 */	public RequestAutoSoulShot(ByteBuffer buf, ClientThread client)	{		super(buf, client);		_unknown = readH();		_itemId  = readD();		_type    = readD();	}	void runImpl()	{		L2PcInstance activeChar = getClient().getActiveChar();//		if (activeChar.getPrivateStoreType()==0 && activeChar.getTransactionRequester()==null && !activeChar.isDead() && activeChar.getAI().getIntention()==CtrlIntention.AI_INTENTION_IDLE)		if (activeChar.getPrivateStoreType()==0 && activeChar.getTransactionRequester()==null && !activeChar.isDead())		{			if (Config.DEBUG) _log.fine("AutoSoulShot:" + _itemId);						if ( _type == 1)			{					L2ItemInstance item = activeChar.getInventory().findItemByItemId(_itemId);				IItemHandler handler = ItemHandler.getInstance().getItemHandler(item.getItemId());				handler.useItem(activeChar, item);				ExAutoSoulShot atk = new ExAutoSoulShot(_itemId, _type);				activeChar.sendPacket(atk);				activeChar.setExAutoSoulShot(true);				ClientScheduler s = ClientScheduler.getInstance();				s.scheduleMedAtFixedRate(new AutoSoulShot(activeChar,_itemId, _type), 0, 300);	            SystemMessage sm = new SystemMessage(614); 	            sm.addString("Automatic ss type 1");	            activeChar.sendPacket(sm);			}					if ( _type == 0)			{				activeChar.setExAutoSoulShot(false);				ExAutoSoulShot atk = new ExAutoSoulShot(_itemId, _type);				activeChar.sendPacket(atk);	            SystemMessage sm = new SystemMessage(614); 	            sm.addString("Automatic ss type 0");	            activeChar.sendPacket(sm);			}				}	}		class AutoSoulShot implements Runnable    {   		private L2PcInstance player;        private int itemid;		private int type;		        public AutoSoulShot(L2PcInstance player,int itemid, int type) 		{   			this.player = player;			this.itemid = itemid;			this.type = type;		}        public void run()        {            startAutoSoulShot(player,itemid,type);        }    }		public void startAutoSoulShot(L2PcInstance player,int itemid,int type)    {		L2ItemInstance item = player.getInventory().findItemByItemId(itemid);		IItemHandler handler = ItemHandler.getInstance().getItemHandler(item.getItemId());		handler.useItem(player, item);		if (player.isExAutoSoulShot()==true)		{			ClientScheduler.getInstance().scheduleMed(new AutoSoulShot(player,itemid,type), 300);		}   		    }		/* (non-Javadoc)	 * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()	 */	public String getType()	{		return _C__CF_REQUESTAUTOSOULSHOT;	}}