PetAutoPotHandler.java
资源名称:src.rar [点击查看]
上传用户:gwt600
上传日期:2021-06-03
资源大小:704k
文件大小:1k
源码类别:
游戏
开发平台:
Java
- package net.sf.odinms.net.channel.handler;
- import net.sf.odinms.client.IItem;
- import net.sf.odinms.client.MapleClient;
- import net.sf.odinms.client.MapleInventoryType;
- import net.sf.odinms.net.AbstractMaplePacketHandler;
- import net.sf.odinms.server.MapleInventoryManipulator;
- import net.sf.odinms.server.MapleItemInformationProvider;
- import net.sf.odinms.tools.MaplePacketCreator;
- import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
- /**
- *
- * @author Patrick
- */
- public class PetAutoPotHandler extends AbstractMaplePacketHandler {
- @Override
- public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
- if (!c.getPlayer().isAlive()) {
- c.getSession().write(MaplePacketCreator.enableActions());
- return;
- }
- byte type = slea.readByte();
- slea.skip(12);
- byte slot = slea.readByte();
- slea.readByte();
- int itemId = slea.readInt();
- IItem toUse = c.getPlayer().getInventory(MapleInventoryType.USE).getItem(slot);
- MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
- if (toUse != null && toUse.getQuantity() > 0) {
- if (toUse.getItemId() != itemId) {
- return;
- }
- MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot, (short) 1, false);
- ii.getItemEffect(toUse.getItemId()).applyTo(c.getPlayer());
- }
- }
- }