Search in sources :

Example 66 with Item

use of client.inventory.Item in project HeavenMS by ronancpl.

the class MapleStorageInventory method moveItem.

private void moveItem(short src, short dst) {
    if (src < 0 || dst < 0) {
        return;
    }
    if (dst > this.getSlotLimit()) {
        return;
    }
    Item source = this.getItem(src);
    if (source == null) {
        return;
    }
    short slotMax = MapleItemInformationProvider.getInstance().getSlotMax(c, source.getItemId());
    this.move(src, dst, slotMax);
}
Also used : Item(client.inventory.Item)

Example 67 with Item

use of client.inventory.Item in project HeavenMS by ronancpl.

the class MapleTrade method complete2.

private void complete2() {
    boolean show = ServerConstants.USE_DEBUG;
    items.clear();
    meso = 0;
    for (Item item : exchangeItems) {
        if ((item.getFlag() & ItemConstants.KARMA) == ItemConstants.KARMA)
            // items with scissors of karma used on them are reset once traded
            item.setFlag((byte) (item.getFlag() ^ ItemConstants.KARMA));
        MapleInventoryManipulator.addFromDrop(chr.getClient(), item, show);
    }
    if (exchangeMeso > 0) {
        chr.gainMeso(exchangeMeso - getFee(exchangeMeso), show, true, show);
    }
    exchangeMeso = 0;
    if (exchangeItems != null) {
        exchangeItems.clear();
    }
    chr.getClient().announce(MaplePacketCreator.getTradeCompletion(number));
}
Also used : Item(client.inventory.Item)

Example 68 with Item

use of client.inventory.Item in project HeavenMS by ronancpl.

the class MapleTrade method cancel.

private void cancel() {
    boolean show = ServerConstants.USE_DEBUG;
    for (Item item : items) {
        MapleInventoryManipulator.addFromDrop(chr.getClient(), item, show);
    }
    if (meso > 0) {
        chr.gainMeso(meso, show, true, show);
    }
    meso = 0;
    if (items != null) {
        items.clear();
    }
    exchangeMeso = 0;
    if (exchangeItems != null) {
        exchangeItems.clear();
    }
    chr.getClient().announce(MaplePacketCreator.getTradeCancel(number));
}
Also used : Item(client.inventory.Item)

Example 69 with Item

use of client.inventory.Item in project HeavenMS by ronancpl.

the class CashShop method loadGifts.

public List<Pair<Item, String>> loadGifts() {
    List<Pair<Item, String>> gifts = new ArrayList<>();
    Connection con = null;
    try {
        con = DatabaseConnection.getConnection();
        PreparedStatement ps = con.prepareStatement("SELECT * FROM `gifts` WHERE `to` = ?");
        ps.setInt(1, characterId);
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            notes++;
            CashItem cItem = CashItemFactory.getItem(rs.getInt("sn"));
            Item item = cItem.toItem();
            Equip equip = null;
            item.setGiftFrom(rs.getString("from"));
            if (item.getInventoryType().equals(MapleInventoryType.EQUIP)) {
                equip = (Equip) item;
                equip.setRingId(rs.getInt("ringid"));
                gifts.add(new Pair<Item, String>(equip, rs.getString("message")));
            } else
                gifts.add(new Pair<>(item, rs.getString("message")));
            if (CashItemFactory.isPackage(cItem.getItemId())) {
                // Packages never contains a ring
                for (Item packageItem : CashItemFactory.getPackage(cItem.getItemId())) {
                    packageItem.setGiftFrom(rs.getString("from"));
                    addToInventory(packageItem);
                }
            } else {
                addToInventory(equip == null ? item : equip);
            }
        }
        rs.close();
        ps.close();
        ps = con.prepareStatement("DELETE FROM `gifts` WHERE `to` = ?");
        ps.setInt(1, characterId);
        ps.executeUpdate();
        ps.close();
        con.close();
    } catch (SQLException sqle) {
        sqle.printStackTrace();
    }
    return gifts;
}
Also used : Item(client.inventory.Item) Equip(client.inventory.Equip) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) DatabaseConnection(tools.DatabaseConnection) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Pair(tools.Pair)

Example 70 with Item

use of client.inventory.Item in project HeavenMS by ronancpl.

the class CashShop method save.

public void save(Connection con) throws SQLException {
    PreparedStatement ps = con.prepareStatement("UPDATE `accounts` SET `nxCredit` = ?, `maplePoint` = ?, `nxPrepaid` = ? WHERE `id` = ?");
    ps.setInt(1, nxCredit);
    ps.setInt(2, maplePoint);
    ps.setInt(3, nxPrepaid);
    ps.setInt(4, accountId);
    ps.executeUpdate();
    ps.close();
    List<Pair<Item, MapleInventoryType>> itemsWithType = new ArrayList<>();
    List<Item> inv = getInventory();
    for (Item item : inv) {
        itemsWithType.add(new Pair<>(item, item.getInventoryType()));
    }
    factory.saveItems(itemsWithType, accountId, con);
    ps = con.prepareStatement("DELETE FROM `wishlists` WHERE `charid` = ?");
    ps.setInt(1, characterId);
    ps.executeUpdate();
    ps.close();
    ps = con.prepareStatement("INSERT INTO `wishlists` VALUES (DEFAULT, ?, ?)");
    ps.setInt(1, characterId);
    for (int sn : wishList) {
        ps.setInt(2, sn);
        ps.executeUpdate();
    }
    ps.close();
}
Also used : Item(client.inventory.Item) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) Pair(tools.Pair)

Aggregations

Item (client.inventory.Item)124 MapleMapItem (server.maps.MapleMapItem)33 Equip (client.inventory.Equip)31 ArrayList (java.util.ArrayList)31 MaplePlayerShopItem (server.maps.MaplePlayerShopItem)31 Point (java.awt.Point)29 SQLException (java.sql.SQLException)25 MapleCharacter (client.MapleCharacter)21 MapleInventoryType (client.inventory.MapleInventoryType)20 PreparedStatement (java.sql.PreparedStatement)20 Connection (java.sql.Connection)19 DatabaseConnection (tools.DatabaseConnection)19 MapleInventory (client.inventory.MapleInventory)18 MapleItemInformationProvider (server.MapleItemInformationProvider)18 ResultSet (java.sql.ResultSet)16 Pair (tools.Pair)15 CashItem (server.CashShop.CashItem)13 SpecialCashItem (server.CashShop.SpecialCashItem)12 MapleShopItem (server.MapleShopItem)12 MaplePacketLittleEndianWriter (tools.data.output.MaplePacketLittleEndianWriter)11