SteamWar/SpigotCore
Archiviert
13
0
Dieser Commit ist enthalten in:
yoyosource 2021-04-30 17:56:08 +02:00
Ursprung e880c796e3
Commit c62c2990c0
2 geänderte Dateien mit 82 neuen und 78 gelöschten Zeilen

Datei anzeigen

@ -1,78 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.sql;
import org.bukkit.entity.Player;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.UUID;
public final class BauweltMemberConfig {
private BauweltMemberConfig() {
}
public static String getPlayerConfig(Player player) {
return getPlayerConfig(player.getUniqueId());
}
public static String getPlayerConfig(UUID uuid) {
return getPlayerConfig(SteamwarUser.get(uuid).getId());
}
public static String getPlayerConfig(int id) {
ResultSet config = SQL.select("SELECT * FROM MemberConfig WHERE UserID = ?", id);
try {
if (!config.next()) {
return null;
}
return config.getString("BauConfig");
} catch (SQLException e) {
throw new SecurityException();
}
}
public static void updatePlayerConfig(Player player, String config) {
updatePlayerConfig(player.getUniqueId(), config);
}
public static void updatePlayerConfig(UUID uuid, String config) {
updatePlayerConfig(SteamwarUser.get(uuid).getId(), config);
}
public static void updatePlayerConfig(int id, String config) {
SQL.update("INSERT INTO MemberConfig (UserID, BauConfig) VALUES (?, ?) ON DUPLICATE KEY UPDATE BauConfig = VALUES(BauConfig)", id, config);
}
public static void removePlayerConfig(Player player) {
removePlayerConfig(player.getUniqueId());
}
public static void removePlayerConfig(UUID uuid) {
removePlayerConfig(SteamwarUser.get(uuid).getId());
}
public static void removePlayerConfig(int id) {
updatePlayerConfig(id, null);
}
}

Datei anzeigen

@ -0,0 +1,82 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.sql;
import org.bukkit.entity.Player;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.UUID;
public class UserConfig {
private UserConfig() {
}
public static String getConfig(Player player, String configType) {
return getConfig(player.getUniqueId(), configType);
}
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);
try {
if (!config.next()) {
return null;
}
return config.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 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);
return;
}
SQL.update("INSERT INTO UserConfig (User, Config, Value) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Value = VALUES(Value)", id, configType, config);
}
public static void removePlayerConfig(Player player, String configType) {
removePlayerConfig(player.getUniqueId(), configType);
}
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);
}
}