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));
}
}
}
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());
}
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();
}
Aggregations