Log error when shop can't be saved.

This commit is contained in:
Len 2022-10-03 20:36:49 +02:00
parent 76c68f6bfa
commit 69d90e16b5
2 changed files with 35 additions and 17 deletions

View File

@ -355,4 +355,14 @@ public class PlayerShop {
updateSign();
}
@Override
public String toString() {
return "Shop: " + this.getShopID()
+ "type :" + this.type
+ "server :" + this.server
+ "price :" + this.price
+ "amount :" + this.amount
+ "balance :" + this.balance
+ "lastTransaction :" + this.lastTransaction;
}
}

View File

@ -171,7 +171,9 @@ public record DatabaseHelper(PlayerShops plugin, DatabaseManager databaseManager
"container_location = ?, sign_location = ?, price = ?, amount = ?, balance = ?, " +
"item = ?, last_transaction = ? WHERE id = ?";
databaseManager().addDatabaseQuery(
new DatabaseQuery(query, ps -> {
new DatabaseQuery(query, new DatabaseQuery.DatabaseTask() {
@Override
public void edit(PreparedStatement ps) throws SQLException {
ps.setString(1, shop.getOwnerName());
ps.setString(2, shop.getOwnerUUID().toString());
ps.setString(3, shop.getType().toString());
@ -189,6 +191,12 @@ public record DatabaseHelper(PlayerShops plugin, DatabaseManager databaseManager
}
ps.setLong(11, shop.getLastTransaction());
ps.setString(12, shop.getShopID().toString());
}
@Override
public void onFailure(SQLException e) {
Logger.error("Could not save shop to database " + shop.toString() + "\n" + e);
}
}), queue
);
}