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