Move chr MySQL saving to CharacterSaver

This commit is contained in:
P0nk
2024-10-05 22:31:08 +02:00
parent a4f8086da1
commit f2b8ced976
7 changed files with 678 additions and 414 deletions

View File

@@ -129,25 +129,21 @@ public class Storage {
}
}
public void saveToDB(Connection con) {
try {
try (PreparedStatement ps = con.prepareStatement("UPDATE storages SET slots = ?, meso = ? WHERE storageid = ?")) {
ps.setInt(1, slots);
ps.setInt(2, meso);
ps.setInt(3, id);
ps.executeUpdate();
}
List<Pair<Item, InventoryType>> itemsWithType = new ArrayList<>();
List<Item> list = getItems();
for (Item item : list) {
itemsWithType.add(new Pair<>(item, item.getInventoryType()));
}
ItemFactory.STORAGE.saveItems(itemsWithType, id, con);
} catch (SQLException ex) {
ex.printStackTrace();
public void saveToDB(Connection con) throws SQLException {
try (PreparedStatement ps = con.prepareStatement("UPDATE storages SET slots = ?, meso = ? WHERE storageid = ?")) {
ps.setInt(1, slots);
ps.setInt(2, meso);
ps.setInt(3, id);
ps.executeUpdate();
}
List<Pair<Item, InventoryType>> itemsWithType = new ArrayList<>();
List<Item> list = getItems();
for (Item item : list) {
itemsWithType.add(new Pair<>(item, item.getInventoryType()));
}
ItemFactory.STORAGE.saveItems(itemsWithType, id, con);
}
public Item getItem(byte slot) {