Legendary Battlemage
- Joined
- Jun 16, 2011
- Messages
- 610
- Reaction score
- 347
I am bored, so i'm releasing something useless(well not really useless because i can crash servers with this), but yeah.
Enjoy.
Bye.
Enjoy.
Code:
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package communication.channel.handlers;
import communication.MapleClient;
import communication.AbstractMaplePacketHandler;
import character.inventory.MapleInventoryType;
import character.inventory.MapleInventory;
import server.MapleInventoryManipulator;
import packet.MaplePacketCreator;
import packet.input.SeekableLittleEndianAccessor;
public class ItemSortHandler extends AbstractMaplePacketHandler {
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
slea.readInt(); // timestamp
byte mode = slea.readByte();
boolean sorted = false;
MapleInventoryType pInvType = MapleInventoryType.getByType(mode);
MapleInventory pInv = c.getPlayer().getInventory(pInvType);
if (pInv == null || pInv.isFull()) {
return;
}
while (!sorted) {
byte freeSlot = pInv.getNextFreeSlot();
if (freeSlot != -1) {
byte itemSlot = -1;
for (int i = freeSlot + 1; i <= pInv.getSlotLimit(); i++) {
if (pInv.getItem((byte) i) != null) {
itemSlot = (byte) i;
break;
}
}
if (itemSlot <= 100 && itemSlot > 0) {
MapleInventoryManipulator.move(c, pInvType, itemSlot, freeSlot);
} else {
sorted = true;
}
}
}
c.getSession().write(MaplePacketCreator.finishedSort(mode));
c.getSession().write(MaplePacketCreator.enableActions());
}
}
Bye.
Last edited: