Search in sources :

Example 1 with MapleKeyBinding

use of client.MapleKeyBinding in project HeavenMS by ronancpl.

the class KeymapChangeHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    if (slea.available() >= 8) {
        int mode = slea.readInt();
        if (mode == 0) {
            int numChanges = slea.readInt();
            for (int i = 0; i < numChanges; i++) {
                int key = slea.readInt();
                int type = slea.readByte();
                int action = slea.readInt();
                if (type == 1) {
                    Skill skill = SkillFactory.getSkill(action);
                    boolean isBanndedSkill;
                    if (skill != null) {
                        isBanndedSkill = GameConstants.bannedBindSkills(skill.getId());
                        if (isBanndedSkill || (!c.getPlayer().isGM() && GameConstants.isGMSkills(skill.getId())) || (!GameConstants.isInJobTree(skill.getId(), c.getPlayer().getJob().getId()) && !c.getPlayer().isGM())) {
                            // fk that
                            continue;
                        }
                    /* if (c.getPlayer().getSkillLevel(skill) < 1) {    HOW WOULD A SKILL EVEN BE AVAILABLE TO KEYBINDING
                                                                continue;                                   IF THERE IS NOT EVEN A SINGLE POINT USED INTO IT??
                                                        } */
                    }
                }
                c.getPlayer().changeKeybinding(key, new MapleKeyBinding(type, action));
            }
        } else if (mode == 1) {
            // Auto HP Potion
            int itemID = slea.readInt();
            if (itemID != 0 && c.getPlayer().getInventory(MapleInventoryType.USE).findById(itemID) == null) {
                // Don't let them send a packet with a use item they dont have.
                c.disconnect(false, false);
                return;
            }
            c.getPlayer().changeKeybinding(91, new MapleKeyBinding(7, itemID));
        } else if (mode == 2) {
            // Auto MP Potion
            int itemID = slea.readInt();
            if (itemID != 0 && c.getPlayer().getInventory(MapleInventoryType.USE).findById(itemID) == null) {
                // Don't let them send a packet with a use item they dont have.
                c.disconnect(false, false);
                return;
            }
            c.getPlayer().changeKeybinding(92, new MapleKeyBinding(7, itemID));
        }
    }
}
Also used : Skill(client.Skill) MapleKeyBinding(client.MapleKeyBinding)

Example 2 with MapleKeyBinding

use of client.MapleKeyBinding in project HeavenMS by ronancpl.

the class MaplePacketCreator method getKeymap.

public static byte[] getKeymap(Map<Integer, MapleKeyBinding> keybindings) {
    final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
    mplew.writeShort(SendOpcode.KEYMAP.getValue());
    mplew.write(0);
    for (int x = 0; x < 90; x++) {
        MapleKeyBinding binding = keybindings.get(Integer.valueOf(x));
        if (binding != null) {
            mplew.write(binding.getType());
            mplew.writeInt(binding.getAction());
        } else {
            mplew.write(0);
            mplew.writeInt(0);
        }
    }
    return mplew.getPacket();
}
Also used : MaplePacketLittleEndianWriter(tools.data.output.MaplePacketLittleEndianWriter) MapleKeyBinding(client.MapleKeyBinding) Point(java.awt.Point)

Aggregations

MapleKeyBinding (client.MapleKeyBinding)2 Skill (client.Skill)1 Point (java.awt.Point)1 MaplePacketLittleEndianWriter (tools.data.output.MaplePacketLittleEndianWriter)1