ItemSortHandler2.java
资源名称:src.rar [点击查看]
上传用户:gwt600
上传日期:2021-06-03
资源大小:704k
文件大小:3k
源码类别:
游戏
开发平台:
Java
- package net.sf.odinms.net.channel.handler;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.LinkedList;
- import java.util.List;
- import net.sf.odinms.client.IItem;
- import net.sf.odinms.client.MapleClient;
- import net.sf.odinms.net.AbstractMaplePacketHandler;
- import net.sf.odinms.client.MapleInventoryType;
- import net.sf.odinms.client.MapleInventory;
- import net.sf.odinms.server.MapleInventoryManipulator;
- import net.sf.odinms.server.maps.FakeCharacter;
- import net.sf.odinms.tools.MaplePacketCreator;
- import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
- // @Auther XoticMS
- public class ItemSortHandler2 extends AbstractMaplePacketHandler {
- @Override
- public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
- c.getPlayer().resetAfkTime();
- // [41 00] [E5 1D 55 00] [01]
- // [32 00] [01] [01] // Sent after
- slea.readInt();
- byte mode = slea.readByte();
- /*
- MapleInventoryType invType = MapleInventoryType.getByType(mode);
- MapleInventory Inv = c.getPlayer().getInventory(invType);
- List<IItem> itemMap = new LinkedList<IItem>();
- for (IItem item : Inv.list()) {
- if (item.getPetId() == -1) {
- itemMap.add(item.copy()); // clone all items T___T.
- }
- }
- for (IItem itemStats : itemMap) {
- MapleInventoryManipulator.removeById(c, invType, itemStats.getItemId(), itemStats.getQuantity(), true, false);
- }
- LinkedList<IItem> sortedItems = sortItems(itemMap);
- for (IItem item : sortedItems) {
- MapleInventoryManipulator.addFromDrop(c, item, "stuff", false);
- }
- c.getSession().write(MaplePacketCreator.enableActions());
- itemMap.clear();
- sortedItems.clear();
- */
- c.getSession().write(MaplePacketCreator.finishedSort2(mode));
- }
- // private LinkedList<IItem> sortItems(List<IItem> passedMap) {
- // List<Integer> itemIds = new ArrayList<Integer>(); // empty list.
- // for (IItem item : passedMap) {
- // itemIds.add(item.getItemId()); // adds all item ids to the empty list to be sorted.
- // }
- // Collections.sort(itemIds); // sorts item ids
- //
- // LinkedList<IItem> sortedList = new LinkedList<IItem>(); // ordered list pl0x <3.
- //
- // for (Integer val : itemIds) {
- // for (IItem item : passedMap) {
- // if (val == item.getItemId()) { // Goes through every index and finds the first value that matches
- // sortedList.add(item);
- // passedMap.remove(item);
- // break;
- // }
- // }
- // }
- // return sortedList;
- // }
- }