Update UserConfig
Dieser Commit ist enthalten in:
Ursprung
c62c2990c0
Commit
83cc566558
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.sql;
|
package de.steamwar.sql;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -31,52 +29,40 @@ public class UserConfig {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getConfig(Player player, String configType) {
|
public static String getConfig(UUID player, String config) {
|
||||||
return getConfig(player.getUniqueId(), configType);
|
return getConfig(SteamwarUser.get(player).getId(), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getConfig(UUID player, String configType) {
|
public static String getConfig(int player, String config) {
|
||||||
return getConfig(SteamwarUser.get(player).getId(), configType);
|
ResultSet configResult = SQL.select("SELECT * FROM UserConfig WHERE User = ? AND Config = ?", player, config);
|
||||||
}
|
|
||||||
|
|
||||||
public static String getConfig(int player, String configType) {
|
|
||||||
ResultSet config = SQL.select("SELECT * FROM UserConfig WHERE User = ? AND Config = ?", player, configType);
|
|
||||||
try {
|
try {
|
||||||
if (!config.next()) {
|
if (!configResult.next()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return config.getString("Value");
|
return configResult.getString("Value");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new SecurityException();
|
throw new SecurityException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updatePlayerConfig(Player player, String configType, String config) {
|
public static void updatePlayerConfig(UUID uuid, String config, String value) {
|
||||||
updatePlayerConfig(player.getUniqueId(), configType, config);
|
updatePlayerConfig(SteamwarUser.get(uuid).getId(), config, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updatePlayerConfig(UUID uuid, String configType, String config) {
|
public static void updatePlayerConfig(int id, String config, String value) {
|
||||||
updatePlayerConfig(SteamwarUser.get(uuid).getId(), configType, config);
|
if (value == null) {
|
||||||
}
|
removePlayerConfig(id, config);
|
||||||
|
|
||||||
public static void updatePlayerConfig(int id, String configType, String config) {
|
|
||||||
if (config == null) {
|
|
||||||
removePlayerConfig(id, configType);
|
|
||||||
return;
|
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) {
|
public static void removePlayerConfig(UUID uuid, String config) {
|
||||||
removePlayerConfig(player.getUniqueId(), configType);
|
removePlayerConfig(SteamwarUser.get(uuid).getId(), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removePlayerConfig(UUID uuid, String configType) {
|
public static void removePlayerConfig(int id, String config) {
|
||||||
removePlayerConfig(SteamwarUser.get(uuid).getId(), configType);
|
SQL.update("DELETE FROM UserConfig WHERE User = ? AND Config = ?", id, config);
|
||||||
}
|
|
||||||
|
|
||||||
public static void removePlayerConfig(int id, String configType) {
|
|
||||||
SQL.update("DELETE FROM UserConfig WHERE User = ? AND Config = ?", id, configType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren