Remove Hired Merchants

Junior Spellweaver
Joined
Apr 18, 2009
Messages
171
Reaction score
4
hi, this is a semi-release, as its not 100% removing it, but will save enough space and does the job.

*KEEP IN MIND that different sources/repacks vary, so try finding part of the code and see it from there (the differences are very small)

first, go: src\net\sf\odinms\net\channel\handler and delete the file, "HiredMerchantRequest"

next, go: \src\net\sf\odinms\server\PlayerInteraction and delete the file, "Hiredmerchant.java"

to prevent total spoonfeeding, look for the files yourself. (easy enough)

in "iplayerinteractionmanager", delete this:
Code:
public final byte HIRED_MERCHANT = 1;

in "mapleclient" delete this:
Code:
import net.sf.odinms.server.PlayerInteraction.HiredMerchant;

and

Code:
            IPlayerInteractionManager interaction = chr.getInteraction(); // just for safety.
            if (interaction != null) {
                if (interaction.isOwner(chr)) {
                    if (interaction.getShopType() == 1) {
                        HiredMerchant hm = (HiredMerchant) interaction;
                        hm.setOpen(true);
                    } else if (interaction.getShopType() == 2) {
                        for (MaplePlayerShopItem items : interaction.getItems()) {
                            if (items.getBundles() > 0) {
                                IItem item = items.getItem();
                                item.setQuantity(items.getBundles());
                                MapleInventoryManipulator.addFromDrop(this, item);
                            }
                        }
                        interaction.removeAllVisitors(3, 1);
                        interaction.closeShop(false); // wont happen unless some idiot hacks, hopefully ?
                    } else if (interaction.getShopType() == 3 || interaction.getShopType() == 4) {
                        interaction.removeAllVisitors(3, 1);
                        interaction.closeShop(false);
                    }
                } else {
                    interaction.removeVisitor(chr);
                }
            }

in "maplecharacter" remove:
Code:
import net.sf.odinms.server.PlayerInteraction.HiredMerchant;

and

Code:
 IPlayerInteractionManager interaction = MapleCharacter.this.getInteraction(); // just for safety.
                    if (interaction != null) {
                        if (interaction.isOwner(MapleCharacter.this)) {
                            if (interaction.getShopType() == 1) {
                                HiredMerchant hm = (HiredMerchant) interaction;
                                hm.setOpen(true);
                            } else if (interaction.getShopType() == 2) {
                                for (MaplePlayerShopItem items : interaction.getItems()) {
                                    if (items.getBundles() > 0) {
                                        IItem item = items.getItem();
                                        item.setQuantity(items.getBundles());
                                        MapleInventoryManipulator.addFromDrop(client, item);
                                    }
                                }
                                interaction.removeAllVisitors(3, 1);
                                interaction.closeShop(false); // wont happen unless some idiot hacks, hopefully ?
                            } else if (interaction.getShopType() == 3 || interaction.getShopType() == 4) {
                                interaction.removeAllVisitors(3, 1);
                                interaction.closeShop(false);
                            }
                        } else {
                            interaction.removeVisitor(MapleCharacter.this);
                        }
                    }

in "channelserver" remove:
Code:
import net.sf.odinms.server.PlayerInteraction.HiredMerchant;

and

Code:
                for (ChannelServer channel : getAllInstances()) {
                    for (int i = 910000001; i <= 910000022; i++) {
                        for (MapleMapObject obj : channel.getMapFactory().getMap(i).getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.HIRED_MERCHANT))) {
                            HiredMerchant hm = (HiredMerchant) obj;
                            hm.closeShop(true);
                        }
                    }
                    for (MapleCharacter mc : channel.getPlayerStorage().getAllCharacters()) {
                        mc.saveToDB(true, true);
                    }
                }
            }

in "npcconverstationmanager" remove:
Code:
    public void removeHiredMerchantItem(int id) {
        Connection con = DatabaseConnection.getConnection();
        try {
            PreparedStatement ps = con.prepareStatement("DELETE FROM hiredmerchant WHERE id = ?");
            ps.setInt(1, id);
            ps.executeUpdate();
            ps.close();
        } catch (SQLException se) {
        }
    }

    public int getHiredMerchantMesos() {
        Connection con = DatabaseConnection.getConnection();
        int mesos;
        try {
            PreparedStatement ps = con.prepareStatement("SELECT MerchantMesos FROM characters WHERE id = ?");
            ps.setInt(1, getPlayer().getId());
            ResultSet rs = ps.executeQuery();
            rs.next();
            mesos = rs.getInt("MerchantMesos");
            rs.close();
            ps.close();

        } catch (SQLException se) {
            return 0;
        }
        return mesos;
    }

    public void setHiredMerchantMesos(int set) {
        Connection con = DatabaseConnection.getConnection();
        try {
            PreparedStatement ps = con.prepareStatement("UPDATE characters SET MerchantMesos = ? WHERE id = ?");
            ps.setInt(1, set);
            ps.setInt(2, getPlayer().getId());
            ps.executeUpdate();
            ps.close();

        } catch (SQLException se) {
        }
    }

    public List<Pair<Integer, IItem>> getHiredMerchantItems() {
        Connection con = DatabaseConnection.getConnection();
        List<Pair<Integer, IItem>> items = new ArrayList<Pair<Integer, IItem>>();
        try {
            PreparedStatement ps = con.prepareStatement("SELECT * FROM hiredmerchant WHERE ownerid = ?");
            ps.setInt(1, getPlayer().getId());
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                if (rs.getInt("type") == 1) {
                    Equip eq = new Equip(rs.getInt("itemid"), (byte) 0, -1);
                    eq.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
                    eq.setLevel((byte) rs.getInt("level"));
                    eq.setStr((short) rs.getInt("str"));
                    eq.setDex((short) rs.getInt("dex"));
                    eq.setInt((short) rs.getInt("int"));
                    eq.setLuk((short) rs.getInt("luk"));
                    eq.setHp((short) rs.getInt("hp"));
                    eq.setMp((short) rs.getInt("mp"));
                    eq.setWatk((short) rs.getInt("watk"));
                    eq.setMatk((short) rs.getInt("matk"));
                    eq.setWdef((short) rs.getInt("wdef"));
                    eq.setMdef((short) rs.getInt("mdef"));
                    eq.setAcc((short) rs.getInt("acc"));
                    eq.setAvoid((short) rs.getInt("avoid"));
                    eq.setHands((short) rs.getInt("hands"));
                    eq.setSpeed((short) rs.getInt("speed"));
                    eq.setJump((short) rs.getInt("jump"));
                    eq.setOwner(rs.getString("owner"));
                    items.add(new Pair<Integer, IItem>(rs.getInt("id"), eq));
                } else if (rs.getInt("type") == 2) {
                    Item newItem = new Item(rs.getInt("itemid"), (byte) 0, (short) rs.getInt("quantity"));
                    newItem.setOwner(rs.getString("owner"));
                    items.add(new Pair<Integer, IItem>(rs.getInt("id"), newItem));
                }
            }
            ps.close();
            rs.close();
        } catch (SQLException se) {
            se.printStackTrace();
            return null;
        }
        return items;
    }
}

in "changechannelhandler" remove:
Code:
import net.sf.odinms.server.PlayerInteraction.HiredMerchant;

and

Code:
        IPlayerInteractionManager playershop = player.getInteraction(); // just for safety.
        if (playershop != null) {
            if (playershop.isOwner(player)) {
                if (playershop instanceof HiredMerchant) {
                    HiredMerchant hm = (HiredMerchant) playershop;
                    hm.setOpen(true);
                } else if (playershop instanceof MaplePlayerShop) {
                    for (MaplePlayerShopItem items : playershop.getItems()) {
                        if (items.getBundles() > 0) {
                            IItem item = items.getItem();
                            item.setQuantity(items.getBundles());
                            MapleInventoryManipulator.addFromDrop(c, item);
                        }
                    }
                    playershop.closeShop(false); // wont happen unless some idiot hacks, hopefully ?
                }
            } else {
                playershop.removeVisitor(player);
            }

in "maplepacketcreator" remove:

Code:
import net.sf.odinms.server.PlayerInteraction.HiredMerchant;

and

Code:
    public static MaplePacket hiredMerchantBox() {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(0x2F); // header.
        mplew.write(0x07);
        return mplew.getPacket();
    }

    public static MaplePacket getInteraction(MapleCharacter chr, boolean firstTime) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.PLAYER_INTERACTION.getValue()); // header.

        IPlayerInteractionManager ips = chr.getInteraction();
        int type = ips.getShopType();
        if (type == 1) {
            mplew.write(HexTool.getByteArrayFromHexString("05 05 04"));
        } else if (type == 2) {
            mplew.write(HexTool.getByteArrayFromHexString("05 04 04"));
        } else if (type == 3) {
            mplew.write(HexTool.getByteArrayFromHexString("05 02 02"));
        } else if (type == 4) {
            mplew.write(HexTool.getByteArrayFromHexString("05 01 02"));
        }

        mplew.write(ips.isOwner(chr) ? 0 : 1);
        mplew.write(0);
        if (type == 2 || type == 3 || type == 4) {
            addCharLook(mplew, ((MaplePlayerShop) ips).getMCOwner(), false);
            mplew.writeMapleAsciiString(ips.getOwnerName());
        } else {
            mplew.writeInt(((HiredMerchant) ips).getItemId());
            mplew.writeMapleAsciiString("Hired Merchant");
        }

sql:
Code:
DROP TABLE IF EXISTS `hiredmerchant`;

time to change my writing style to keep your attention
delete this:
Code:
  registerHandler(RecvPacketOpcode.HIRED_MERCHANT_REQUEST, new HiredMerchantRequest());

from:

packetprocessor

in your souce folder (with the .bats), open "recvops" and delete this:
Code:
HIRED_MERCHANT_REQUEST = 0x3B

in sendops,
Code:
SPAWN_HIRED_MERCHANT = 0xCA
DESTROY_HIRED_MERCHANT = 0xCB
**Press thanks if this did the job.


credits?
MrMysterious
Me for being bored and doing this
 
Last edited:
@ holthelper, i know why, just wanted to add the files also
but the only prob with what you did is throw out a huge amount of code at us and some are going to get confused and deleted something. after that we'll have like thousands of help threads because they deleted something for they cant read.

the simple answer to it is just to delete the ops or add a feature to turn it on/off
 
but the only prob with what you did is throw out a huge amount of code at us and some are going to get confused and deleted something. after that we'll have like thousands of help threads because they deleted something for they cant read.

the simple answer to it is just to delete the ops or add a feature to turn it on/off

well i know that.
just wanted to release something i guess.
its probably semi-useless for most of the RZ community anyways, but if people were looking for it, they could do all that, or just my last 2 steps.
 
this saves space you fucking idiots. removing recvops and sendops will just keep the useless crap there.
sir you are a
...fucking idiot...
i dont think you realize the amount of "space" you save by taking this much code out.

a couple KB for the jar.
about 10-15 KB for each file deleted
and about 1-10 KB for deleting the code within the file.

thats a **** load of "space" saved.

OPPS forgot to talk about your quote lol.
going off what i said above, just deleting the ops will basically get rid of hired merchants or you can just comment it out if you plan to use it later.

now have the code still in the source is going to do nothing but add more KB (from the text above) big deal. you dont have to go the extreme langth as to delete everything that has to do with hired merchants.

by deleting what if the person decides later that he/she wants hired merchants again. what now? its more simple to comment out the ops then delete the code for "space"
 
Last edited:
sir you are a

i dont think you realize the amount of "space" you save by taking this much code out.

a couple KB for the jar.
about 10-15 KB for each file deleted
and about 1-10 KB for deleting the code within the file.

thats a **** load of "space" saved.

OPPS forgot to talk about your quote lol.
going off what i said above, just deleting the ops will basically get rid of hired merchants or you can just comment it out if you plan to use it later.

now have the code still in the source is going to do nothing but add more KB (from the text above) big deal. you dont have to go the extreme langth as to delete everything that has to do with hired merchants.

by deleting what if the person decides later that he/she wants hired merchants again. what now? its more simple to comment out the ops then delete the code for "space"

well i thought it did save space at first also, but then it is only a few lines, so yeah, its just a few KB. but if you think about it, if its not being used and your going to remove the OPs either way, might as well do this.
(not taking any sides)
 
well i thought it did save space at first also, but then it is only a few lines, so yeah, its just a few KB. but if you think about it, if its not being used and your going to remove the OPs either way, might as well do this.
(not taking any sides)
lol its ok. my bother is the same way.

he tried getting me to use another program thats 50 KB smaller and it does the same thing. i said to him, once i absolutely need those 50 KB ill get your program.
 
Back