Search in sources :

Example 6 with MapleHiredMerchant

use of server.maps.MapleHiredMerchant in project HeavenMS by ronancpl.

the class OwlWarpHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    int ownerid = slea.readInt();
    int mapid = slea.readInt();
    // if both hired merchant and player shop is on the same map
    MapleHiredMerchant hm = c.getWorldServer().getHiredMerchant(ownerid);
    MaplePlayerShop ps;
    if (hm == null || hm.getMapId() != mapid || !hm.hasItem(c.getPlayer().getOwlSearch())) {
        ps = c.getWorldServer().getPlayerShop(ownerid);
        if (ps == null || ps.getMapId() != mapid || !ps.hasItem(c.getPlayer().getOwlSearch())) {
            if (hm == null && ps == null)
                c.announce(MaplePacketCreator.getOwlMessage(1));
            else
                c.announce(MaplePacketCreator.getOwlMessage(3));
            return;
        }
        if (ps.isOpen()) {
            if (GameConstants.isFreeMarketRoom(mapid)) {
                if (ps.getChannel() == c.getChannel()) {
                    c.getPlayer().changeMap(mapid);
                    if (ps.isOpen()) {
                        // change map has a delay, must double check
                        if (!ps.visitShop(c.getPlayer())) {
                            if (!ps.isBanned(c.getPlayer().getName()))
                                c.announce(MaplePacketCreator.getOwlMessage(2));
                            else
                                c.announce(MaplePacketCreator.getOwlMessage(17));
                        }
                    } else {
                        // c.announce(MaplePacketCreator.serverNotice(1, "That merchant has either been closed or is under maintenance."));
                        c.announce(MaplePacketCreator.getOwlMessage(18));
                    }
                } else {
                    c.announce(MaplePacketCreator.serverNotice(1, "That shop is currently located in another channel. Current location: Channel " + hm.getChannel() + ", '" + hm.getMap().getMapName() + "'."));
                }
            } else {
                c.announce(MaplePacketCreator.serverNotice(1, "That shop is currently located outside of the FM area. Current location: Channel " + hm.getChannel() + ", '" + hm.getMap().getMapName() + "'."));
            }
        } else {
            // c.announce(MaplePacketCreator.serverNotice(1, "That merchant has either been closed or is under maintenance."));
            c.announce(MaplePacketCreator.getOwlMessage(18));
        }
    } else {
        if (hm.isOpen()) {
            if (GameConstants.isFreeMarketRoom(mapid)) {
                if (hm.getChannel() == c.getChannel()) {
                    c.getPlayer().changeMap(mapid);
                    if (hm.isOpen()) {
                        // change map has a delay, must double check
                        if (hm.addVisitor(c.getPlayer())) {
                            c.announce(MaplePacketCreator.getHiredMerchant(c.getPlayer(), hm, false));
                            c.getPlayer().setHiredMerchant(hm);
                        } else {
                            // c.announce(MaplePacketCreator.serverNotice(1, hm.getOwner() + "'s merchant is full. Wait awhile before trying again."));
                            c.announce(MaplePacketCreator.getOwlMessage(2));
                        }
                    } else {
                        // c.announce(MaplePacketCreator.serverNotice(1, "That merchant has either been closed or is under maintenance."));
                        c.announce(MaplePacketCreator.getOwlMessage(18));
                    }
                } else {
                    c.announce(MaplePacketCreator.serverNotice(1, "That merchant is currently located in another channel. Current location: Channel " + hm.getChannel() + ", '" + hm.getMap().getMapName() + "'."));
                }
            } else {
                c.announce(MaplePacketCreator.serverNotice(1, "That merchant is currently located outside of the FM area. Current location: Channel " + hm.getChannel() + ", '" + hm.getMap().getMapName() + "'."));
            }
        } else {
            // c.announce(MaplePacketCreator.serverNotice(1, "That merchant has either been closed or is under maintenance."));
            c.announce(MaplePacketCreator.getOwlMessage(18));
        }
    }
}
Also used : MapleHiredMerchant(server.maps.MapleHiredMerchant) MaplePlayerShop(server.maps.MaplePlayerShop)

Example 7 with MapleHiredMerchant

use of server.maps.MapleHiredMerchant in project HeavenMS by ronancpl.

the class RemoteStoreHandler method handlePacket.

public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleCharacter chr = c.getPlayer();
    MapleHiredMerchant hm = getMerchant(c);
    if (chr.hasMerchant() && hm != null) {
        if (hm.getChannel() == chr.getClient().getChannel()) {
            hm.setOpen(false);
            hm.removeAllVisitors();
            chr.setHiredMerchant(hm);
            chr.announce(MaplePacketCreator.getHiredMerchant(chr, hm, false));
        } else {
            c.announce(MaplePacketCreator.remoteChannelChange((byte) (hm.getChannel() - 1)));
        }
        return;
    } else {
        chr.dropMessage(1, "You don't have a Merchant open.");
    }
    c.announce(MaplePacketCreator.enableActions());
}
Also used : MapleCharacter(client.MapleCharacter) MapleHiredMerchant(server.maps.MapleHiredMerchant)

Example 8 with MapleHiredMerchant

use of server.maps.MapleHiredMerchant in project HeavenMS by ronancpl.

the class MaplePacketCreator method owlOfMinerva.

public static byte[] owlOfMinerva(MapleClient c, int itemid, List<Pair<MaplePlayerShopItem, AbstractMapleMapObject>> hmsAvailable) {
    byte itemType = ItemConstants.getInventoryType(itemid).getType();
    final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
    // header.
    mplew.writeShort(SendOpcode.SHOP_SCANNER_RESULT.getValue());
    mplew.write(6);
    mplew.writeInt(0);
    mplew.writeInt(itemid);
    mplew.writeInt(hmsAvailable.size());
    for (Pair<MaplePlayerShopItem, AbstractMapleMapObject> hme : hmsAvailable) {
        MaplePlayerShopItem item = hme.getLeft();
        AbstractMapleMapObject mo = hme.getRight();
        if (mo instanceof MaplePlayerShop) {
            MaplePlayerShop ps = (MaplePlayerShop) mo;
            MapleCharacter owner = ps.getOwner();
            mplew.writeMapleAsciiString(owner.getName());
            mplew.writeInt(owner.getMapId());
            mplew.writeMapleAsciiString(ps.getDescription());
            mplew.writeInt(item.getBundles());
            mplew.writeInt(item.getItem().getQuantity());
            mplew.writeInt(item.getPrice());
            mplew.writeInt(owner.getId());
            mplew.write(owner.getClient().getChannel() - 1);
        } else {
            MapleHiredMerchant hm = (MapleHiredMerchant) mo;
            mplew.writeMapleAsciiString(hm.getOwner());
            mplew.writeInt(hm.getMapId());
            mplew.writeMapleAsciiString(hm.getDescription());
            mplew.writeInt(item.getBundles());
            mplew.writeInt(item.getItem().getQuantity());
            mplew.writeInt(item.getPrice());
            mplew.writeInt(hm.getOwnerId());
            mplew.write(hm.getChannel() - 1);
        }
        mplew.write(itemType);
        if (itemType == MapleInventoryType.EQUIP.getType()) {
            addItemInfo(mplew, item.getItem(), true);
        }
    }
    return mplew.getPacket();
}
Also used : MaplePacketLittleEndianWriter(tools.data.output.MaplePacketLittleEndianWriter) MapleCharacter(client.MapleCharacter) MapleHiredMerchant(server.maps.MapleHiredMerchant) MaplePlayerShop(server.maps.MaplePlayerShop) AbstractMapleMapObject(server.maps.AbstractMapleMapObject) MaplePlayerShopItem(server.maps.MaplePlayerShopItem)

Aggregations

MapleHiredMerchant (server.maps.MapleHiredMerchant)8 MaplePlayerShop (server.maps.MaplePlayerShop)4 MapleCharacter (client.MapleCharacter)3 MaplePlayerShopItem (server.maps.MaplePlayerShopItem)3 ArrayList (java.util.ArrayList)2 CharacterIdChannelPair (net.server.channel.CharacterIdChannelPair)2 AbstractMapleMapObject (server.maps.AbstractMapleMapObject)2 Pair (tools.Pair)2 Item (client.inventory.Item)1 MapleInventoryType (client.inventory.MapleInventoryType)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MapleItemInformationProvider (server.MapleItemInformationProvider)1 MapleMap (server.maps.MapleMap)1 MapleMapObject (server.maps.MapleMapObject)1 MapleMiniGame (server.maps.MapleMiniGame)1 MaplePacketLittleEndianWriter (tools.data.output.MaplePacketLittleEndianWriter)1