Search in sources :

Example 66 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class WeddingHandler method handlePacket.

@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    // System.out.println("Wedding Packet: " + slea);
    MapleCharacter chr = c.getPlayer();
    byte operation = slea.readByte();
    switch(operation) {
        case // Add an item to the Wedding Registry
        0x06:
            short slot = slea.readShort();
            int itemid = slea.readInt();
            short quantity = slea.readShort();
            MapleInventoryType type = ItemConstants.getInventoryType(itemid);
            Item item = chr.getInventory(type).getItem(slot);
            if (itemid == item.getItemId() && quantity <= item.getQuantity()) {
                c.announce(MaplePacketCreator.addItemToWeddingRegistry(chr, item));
            }
    }
}
Also used : Item(client.inventory.Item) MapleCharacter(client.MapleCharacter) MapleInventoryType(client.inventory.MapleInventoryType)

Example 67 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class WhisperHandler method handlePacket.

public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    byte mode = slea.readByte();
    if (mode == 6) {
        // whisper
        String recipient = slea.readMapleAsciiString();
        String text = slea.readMapleAsciiString();
        MapleCharacter player = c.getChannelServer().getPlayerStorage().getCharacterByName(recipient);
        if (c.getPlayer().getAutobanManager().getLastSpam(7) + 200 > System.currentTimeMillis()) {
            return;
        }
        if (text.length() > Byte.MAX_VALUE && !player.isGM()) {
            AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with whispers.");
            FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to send text with length of " + text.length() + "\r\n");
            c.disconnect(true, false);
            return;
        }
        if (player != null) {
            player.getClient().announce(MaplePacketCreator.getWhisper(c.getPlayer().getName(), c.getChannel(), text));
            if (player.isHidden() && player.gmLevel() >= c.getPlayer().gmLevel()) {
                c.announce(MaplePacketCreator.getWhisperReply(recipient, (byte) 0));
            } else {
                c.announce(MaplePacketCreator.getWhisperReply(recipient, (byte) 1));
            }
        } else {
            // not found
            World world = c.getWorldServer();
            if (world.isConnected(recipient)) {
                world.whisper(c.getPlayer().getName(), recipient, c.getChannel(), text);
                player = world.getPlayerStorage().getCharacterByName(recipient);
                if (player.isHidden() && player.gmLevel() >= c.getPlayer().gmLevel())
                    c.announce(MaplePacketCreator.getWhisperReply(recipient, (byte) 0));
                else
                    c.announce(MaplePacketCreator.getWhisperReply(recipient, (byte) 1));
            } else {
                c.announce(MaplePacketCreator.getWhisperReply(recipient, (byte) 0));
            }
        }
        c.getPlayer().getAutobanManager().spam(7);
    } else if (mode == 5) {
        // - /find
        String recipient = slea.readMapleAsciiString();
        MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(recipient);
        if (victim != null && c.getPlayer().gmLevel() >= victim.gmLevel()) {
            if (victim.getCashShop().isOpened()) {
                c.announce(MaplePacketCreator.getFindReply(victim.getName(), -1, 2));
            // } else if (victim.inMTS()) {
            // c.announce(MaplePacketCreator.getFindReply(victim.getName(), -1, 0));
            } else {
                c.announce(MaplePacketCreator.getFindReply(victim.getName(), victim.getMap().getId(), 1));
            }
        } else {
            // not found
            try {
                Connection con = DatabaseConnection.getConnection();
                PreparedStatement ps = con.prepareStatement("SELECT gm FROM characters WHERE name = ?");
                ps.setString(1, recipient);
                ResultSet rs = ps.executeQuery();
                if (rs.next()) {
                    if (rs.getInt("gm") >= c.getPlayer().gmLevel()) {
                        c.announce(MaplePacketCreator.getWhisperReply(recipient, (byte) 0));
                        return;
                    }
                }
                rs.close();
                ps.close();
                con.close();
                byte channel = (byte) (c.getWorldServer().find(recipient) - 1);
                if (channel > -1) {
                    c.announce(MaplePacketCreator.getFindReply(recipient, channel, 3));
                } else {
                    c.announce(MaplePacketCreator.getWhisperReply(recipient, (byte) 0));
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    } else if (mode == 0x44) {
    // Buddy find?
    }
}
Also used : MapleCharacter(client.MapleCharacter) SQLException(java.sql.SQLException) DatabaseConnection(tools.DatabaseConnection) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) World(net.server.world.World)

Example 68 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class MapleAlliance method getPartyGuildMasters.

private static List<MapleCharacter> getPartyGuildMasters(MapleParty party) {
    List<MapleCharacter> mcl = new LinkedList<>();
    for (MaplePartyCharacter mpc : party.getMembers()) {
        if (mpc.getPlayer().getGuildRank() == 1 && mpc.getPlayer().getMapId() == party.getLeader().getPlayer().getMapId())
            mcl.add(mpc.getPlayer());
    }
    if (!mcl.isEmpty() && !mcl.get(0).isPartyLeader()) {
        for (int i = 1; i < mcl.size(); i++) {
            if (mcl.get(i).isPartyLeader()) {
                MapleCharacter temp = mcl.get(0);
                mcl.set(0, mcl.get(i));
                mcl.set(i, temp);
            }
        }
    }
    return mcl;
}
Also used : MapleCharacter(client.MapleCharacter) LinkedList(java.util.LinkedList) MaplePartyCharacter(net.server.world.MaplePartyCharacter)

Example 69 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class MapleGuild method sendInvite.

public static MapleGuildResponse sendInvite(MapleClient c, String targetName) {
    MapleCharacter mc = c.getChannelServer().getPlayerStorage().getCharacterByName(targetName);
    if (mc == null) {
        return MapleGuildResponse.NOT_IN_CHANNEL;
    }
    if (mc.getGuildId() > 0) {
        return MapleGuildResponse.ALREADY_IN_GUILD;
    }
    mc.getClient().announce(MaplePacketCreator.guildInvite(c.getPlayer().getGuildId(), c.getPlayer().getName()));
    return null;
}
Also used : MapleCharacter(client.MapleCharacter)

Example 70 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class World method find.

public int find(String name) {
    int channel = -1;
    MapleCharacter chr = getPlayerStorage().getCharacterByName(name);
    if (chr != null) {
        channel = chr.getClient().getChannel();
    }
    return channel;
}
Also used : MapleCharacter(client.MapleCharacter)

Aggregations

MapleCharacter (client.MapleCharacter)163 Point (java.awt.Point)32 SQLException (java.sql.SQLException)22 Item (client.inventory.Item)21 Connection (java.sql.Connection)15 PreparedStatement (java.sql.PreparedStatement)15 MapleMonster (server.life.MapleMonster)15 MapleMapObject (server.maps.MapleMapObject)15 DatabaseConnection (tools.DatabaseConnection)15 MapleMap (server.maps.MapleMap)14 ArrayList (java.util.ArrayList)13 Skill (client.Skill)12 SpawnPoint (server.life.SpawnPoint)12 LinkedList (java.util.LinkedList)11 MapleInventory (client.inventory.MapleInventory)10 World (net.server.world.World)10 MapleStatEffect (server.MapleStatEffect)10 MapleInventoryType (client.inventory.MapleInventoryType)9 ResultSet (java.sql.ResultSet)9 MapleItemInformationProvider (server.MapleItemInformationProvider)9