diff --git a/SpigotCore_Main/src/de/steamwar/sql/UserConfig.java b/SpigotCore_Main/src/de/steamwar/sql/UserConfig.java index df199ed..50d8ad3 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/UserConfig.java +++ b/SpigotCore_Main/src/de/steamwar/sql/UserConfig.java @@ -19,8 +19,6 @@ package de.steamwar.sql; -import org.bukkit.entity.Player; - import java.sql.ResultSet; import java.sql.SQLException; import java.util.UUID; @@ -31,52 +29,40 @@ public class UserConfig { } - public static String getConfig(Player player, String configType) { - return getConfig(player.getUniqueId(), configType); + public static String getConfig(UUID player, String config) { + return getConfig(SteamwarUser.get(player).getId(), config); } - public static String getConfig(UUID player, String configType) { - return getConfig(SteamwarUser.get(player).getId(), configType); - } - - public static String getConfig(int player, String configType) { - ResultSet config = SQL.select("SELECT * FROM UserConfig WHERE User = ? AND Config = ?", player, configType); + public static String getConfig(int player, String config) { + ResultSet configResult = SQL.select("SELECT * FROM UserConfig WHERE User = ? AND Config = ?", player, config); try { - if (!config.next()) { + if (!configResult.next()) { return null; } - return config.getString("Value"); + return configResult.getString("Value"); } catch (SQLException e) { throw new SecurityException(); } } - public static void updatePlayerConfig(Player player, String configType, String config) { - updatePlayerConfig(player.getUniqueId(), configType, config); + public static void updatePlayerConfig(UUID uuid, String config, String value) { + updatePlayerConfig(SteamwarUser.get(uuid).getId(), config, value); } - public static void updatePlayerConfig(UUID uuid, String configType, String config) { - updatePlayerConfig(SteamwarUser.get(uuid).getId(), configType, config); - } - - public static void updatePlayerConfig(int id, String configType, String config) { - if (config == null) { - removePlayerConfig(id, configType); + public static void updatePlayerConfig(int id, String config, String value) { + if (value == null) { + removePlayerConfig(id, config); return; } - SQL.update("INSERT INTO UserConfig (User, Config, Value) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Value = VALUES(Value)", id, configType, config); + SQL.update("INSERT INTO UserConfig (User, Config, Value) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Value = VALUES(Value)", id, config, value); } - public static void removePlayerConfig(Player player, String configType) { - removePlayerConfig(player.getUniqueId(), configType); + public static void removePlayerConfig(UUID uuid, String config) { + removePlayerConfig(SteamwarUser.get(uuid).getId(), config); } - public static void removePlayerConfig(UUID uuid, String configType) { - removePlayerConfig(SteamwarUser.get(uuid).getId(), configType); - } - - public static void removePlayerConfig(int id, String configType) { - SQL.update("DELETE FROM UserConfig WHERE User = ? AND Config = ?", id, configType); + public static void removePlayerConfig(int id, String config) { + SQL.update("DELETE FROM UserConfig WHERE User = ? AND Config = ?", id, config); } }