SteamWar/SpigotCore
Archiviert
13
0

Add BauweltMemberConfig #102

Manuell gemergt
Lixfel hat 9 Commits von BauweltMemberConfig nach master 2021-05-14 15:45:59 +02:00 zusammengeführt
Nur Änderungen aus Commit c91571f63d werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -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(e.getMessage(), e);
YoyoNow markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

Ungeil, da geht der ursprüngliche Fehler verloren => Stacktrace hat keine aussagekraft mehr. Pack noch einen String mit kurzbeschreibung und daran anhängend die Exception dran aka. new SecException("Bla", e);

Ungeil, da geht der ursprüngliche Fehler verloren => Stacktrace hat keine aussagekraft mehr. Pack noch einen String mit kurzbeschreibung und daran anhängend die Exception dran aka. new SecException("Bla", e);
}
}
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);
YoyoNow markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

Können wir konsistent zu den Spalten bleiben und das durchgehend config und value nennen?

Können wir konsistent zu den Spalten bleiben und das durchgehend config und value nennen?
Veraltet
Review

Ja habe ich.

Ja habe ich.
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);
}
}