Changed updateUserPoints to be settings points instead of adding to existing points and doing it for all points a user has in one go

This commit is contained in:
Teriuihi 2021-12-22 20:58:50 +01:00
parent 51fb4758d5
commit bd46ce7df7

View File

@ -45,14 +45,14 @@ public class Queries {
* Add a specified amount of points to the user for the given villager type * Add a specified amount of points to the user for the given villager type
* *
* @param uuid Uuid for the user you want to add the points to * @param uuid Uuid for the user you want to add the points to
* @param villagerType Type of villager you want to add the points to * @param pointsMap Contains all (villagerType, points) entries for user
* @param points The amount of points to add
* @return success * @return success
*/ */
public static boolean updateUserPoints(UUID uuid, String villagerType, int points) { public static boolean updateUserPoints(UUID uuid, Object2ObjectArrayMap<String, Integer> pointsMap) {
String sql = "UPDATE user_points SET points = points + ? " + String sql = "INSERT INTO user_points " +
"WHERE UUID = ? " + "(uuid, villager_type, points) " +
"AND villager_type = ?;"; "VALUES (?, ?, ?) " +
"ON DUPLICATE KEY UPDATE points = ?";
try { try {
PreparedStatement preparedStatement = Database.connection.prepareStatement(sql); PreparedStatement preparedStatement = Database.connection.prepareStatement(sql);