SteamWar/SpigotCore
Archiviert
13
0

Merge pull request 'Remove deprecated APIs' (#125) from removeDeprecated into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #125
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Lixfel 2022-02-01 11:24:52 +01:00
Commit 49dd120b18
28 geänderte Dateien mit 244 neuen und 829 gelöschten Zeilen

Datei anzeigen

@ -21,7 +21,6 @@ package de.steamwar.comms.packets;
import com.google.common.io.ByteArrayDataOutput;
import de.steamwar.comms.PacketIdManager;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
@ -38,13 +37,6 @@ public class PrepareSchemPacket extends SpigotPacket{
this.schematicType = schematicType;
}
@Deprecated
public PrepareSchemPacket(SteamwarUser user, Schematic schematic, SchematicType schematicType) {
this.user = user;
this.schematic = schematic.getNode();
this.schematicType = schematicType;
}
@Override
public int getName() {
return PacketIdManager.PREPARE_SCHEM;

Datei anzeigen

@ -26,7 +26,7 @@ import de.steamwar.core.events.ChattingEvent;
import de.steamwar.core.events.PlayerJoinedEvent;
import de.steamwar.core.events.WorldLoadEvent;
import de.steamwar.message.Message;
import de.steamwar.sql.SQL;
import de.steamwar.sql.Statement;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@ -94,7 +94,7 @@ public class Core extends JavaPlugin{
public void onDisable() {
TinyProtocol.instance.close();
errorHandler.unregister();
SQL.close();
Statement.close();
}
public static Core getInstance() {

Datei anzeigen

@ -19,8 +19,8 @@
package de.steamwar.core;
import de.steamwar.sql.SQL;
import de.steamwar.sql.SWException;
import de.steamwar.sql.Statement;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
@ -83,7 +83,7 @@ public class ErrorHandler extends Handler {
if(stacktrace.contains("POI data mismatch"))
return;
if(!SQL.connectionStable())
if(!Statement.connectionStable())
return;
SWException.log(message, stacktrace);

Datei anzeigen

@ -1,51 +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.core;
import java.util.concurrent.Callable;
public class VersionedCallable<T> {
private Callable<T> callable;
private int minVersion;
public VersionedCallable(Callable<T> callable, int minVersion) {
this.callable = callable;
this.minVersion = minVersion;
}
@Deprecated
public static <T> T call(VersionedCallable<T>... versionedCallables) {
for (int i = versionedCallables.length - 1; i >= 0; i--) {
VersionedCallable<T> versionedCallable = versionedCallables[i];
if (Core.getVersion() >= versionedCallable.minVersion) {
try {
return versionedCallable.callable.call();
} catch (Exception e) {
throw new RuntimeException("Could not run version dependent code", e);
}
}
}
throw new SecurityException();
}
}

Datei anzeigen

@ -1,45 +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.core;
public class VersionedRunnable {
private Runnable runnable;
private int minVersion;
public VersionedRunnable(Runnable runnable, int minVersion) {
this.runnable = runnable;
this.minVersion = minVersion;
}
@Deprecated
public static void call(VersionedRunnable... versionedRunnables) {
for (int i = versionedRunnables.length - 1; i >= 0; i--) {
VersionedRunnable versionedRunnable = versionedRunnables[i];
if (Core.getVersion() >= versionedRunnable.minVersion) {
versionedRunnable.runnable.run();
return;
}
}
}
}

Datei anzeigen

@ -19,7 +19,6 @@
package de.steamwar.inventory;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import org.bukkit.Bukkit;
@ -28,7 +27,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.*;
import java.util.stream.Collectors;
public class SWListInv<T> extends SWInventory {
@ -138,11 +136,6 @@ public class SWListInv<T> extends SWInventory {
}
return schemList;
}
@Deprecated
public static List<SWListEntry<Schematic>> getSchemList(SchematicType type, int steamwarUserId){
return getSchemnodeList(type, steamwarUserId).stream().map(schematicNodeSWListEntry -> new SWListEntry<Schematic>(schematicNodeSWListEntry.getItem(), Schematic.wrap(schematicNodeSWListEntry.getObject()))).collect(Collectors.toList());
}
private boolean sizeBiggerMax(){
return dynamicSize ? elements.size() > 54 : elements.size() > 45;

Datei anzeigen

@ -25,13 +25,13 @@ import java.util.UUID;
public class BauweltMember{
private static final SQL.Statement getMember = new SQL.Statement("SELECT * FROM BauweltMember WHERE BauweltID = ? AND MemberID = ?");
private static final SQL.Statement getMembers = new SQL.Statement("SELECT * FROM BauweltMember WHERE BauweltID = ?");
private static final Statement getMember = new Statement("SELECT * FROM BauweltMember WHERE BauweltID = ? AND MemberID = ?");
private static final Statement getMembers = new Statement("SELECT * FROM BauweltMember WHERE BauweltID = ?");
private final int bauweltID;
private final int memberID;
private boolean worldEdit;
private boolean world;
private final boolean worldEdit;
private final boolean world;
private static final List<BauweltMember> members = new ArrayList<>();
@ -39,36 +39,14 @@ public class BauweltMember{
members.clear();
}
private BauweltMember(int ownerID, int memberID, boolean worldEdit, boolean world, boolean updateDB){
private BauweltMember(int ownerID, int memberID, boolean worldEdit, boolean world) {
bauweltID = ownerID;
this.memberID = memberID;
this.worldEdit = worldEdit;
this.world = world;
if(updateDB)
updateDB();
members.add(this);
}
public BauweltMember(int ownerID, int memberID, boolean worldEdit, boolean world){
this(ownerID, memberID, worldEdit, world, true);
}
public BauweltMember(UUID ownerID, UUID memberID, boolean worldEdit, boolean world){
this(SteamwarUser.get(ownerID).getId(), SteamwarUser.get(memberID).getId(), worldEdit, world, true);
}
@Deprecated
public void remove(){
SQL.update("DELETE FROM BauweltMember WHERE BauweltID = ? AND MemberID = ?", bauweltID, memberID);
members.remove(this);
}
@Deprecated
private void updateDB(){
SQL.update("INSERT INTO BauweltMember (BauweltID, MemberID, WorldEdit, World) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE WorldEdit = VALUES(WorldEdit), World = VALUES(World)",
bauweltID, memberID, worldEdit, world);
}
public static BauweltMember getBauMember(UUID ownerID, UUID memberID){
return getBauMember(SteamwarUser.get(ownerID).getId(), SteamwarUser.get(memberID).getId());
}
@ -80,7 +58,7 @@ public class BauweltMember{
return getMember.select(rs -> {
if(!rs.next())
return null;
return new BauweltMember(ownerID, memberID, rs.getBoolean("WorldEdit"), rs.getBoolean("World"), false);
return new BauweltMember(ownerID, memberID, rs.getBoolean("WorldEdit"), rs.getBoolean("World"));
}, ownerID, memberID);
}
@ -92,7 +70,7 @@ public class BauweltMember{
return getMembers.select(rs -> {
List<BauweltMember> members = new ArrayList<>();
while(rs.next())
members.add(new BauweltMember(bauweltID, rs.getInt("MemberID"), rs.getBoolean("WorldEdit"), rs.getBoolean("World"), false));
members.add(new BauweltMember(bauweltID, rs.getInt("MemberID"), rs.getBoolean("WorldEdit"), rs.getBoolean("World")));
return members;
}, bauweltID);
}
@ -109,19 +87,7 @@ public class BauweltMember{
return worldEdit;
}
@Deprecated
public void setWorldEdit(boolean worldEdit) {
this.worldEdit = worldEdit;
updateDB();
}
public boolean isWorld() {
return world;
}
@Deprecated
public void setWorld(boolean world) {
this.world = world;
updateDB();
}
}

Datei anzeigen

@ -26,10 +26,8 @@ import java.util.UUID;
public class CheckedSchematic {
private static final SQL.Statement checkHistory = new SQL.Statement("SELECT * FROM CheckedSchematic WHERE NodeId IN (SELECT NodeId FROM SchematicNode WHERE NodeOwner = ?) AND DeclineReason != '' AND DeclineReason != 'Prüfvorgang abgebrochen' AND NodeId is not NULL ORDER BY EndTime DESC");
private static final SQL.Statement nodeHistory = new SQL.Statement("SELECT * FROM CheckedSchematic WHERE NodeId = ? AND DeclineReason != '' AND DeclineReason != 'Prüfvorgang abgebrochen' ORDER BY EndTime DESC");
private static final SQL.Statement insert = new SQL.Statement("INSERT INTO CheckedSchematic (NodeId, NodeName, NodeOwner, Validator, StartTime, EndTime, DeclineReason) VALUES (?, ?, ?, ?, ?, ?, ?)");
private static final SQL.Statement setNodeNull = new SQL.Statement("UPDATE CheckedSchematic SET NodeId = NULL WHERE NodeId = ?");
private static final Statement checkHistory = new Statement("SELECT * FROM CheckedSchematic WHERE NodeId IN (SELECT NodeId FROM SchematicNode WHERE NodeOwner = ?) AND DeclineReason != '' AND DeclineReason != 'Prüfvorgang abgebrochen' AND NodeId is not NULL ORDER BY EndTime DESC");
private static final Statement nodeHistory = new Statement("SELECT * FROM CheckedSchematic WHERE NodeId = ? AND DeclineReason != '' AND DeclineReason != 'Prüfvorgang abgebrochen' ORDER BY EndTime DESC");
private final Integer node;
private final int validator;
@ -37,40 +35,12 @@ public class CheckedSchematic {
private final Timestamp endTime;
private final String declineReason;
private CheckedSchematic(int node, int validator, Timestamp startTime, Timestamp endTime, String declineReason, boolean insertDB){
private CheckedSchematic(int node, int validator, Timestamp startTime, Timestamp endTime, String declineReason){
this.node = node;
this.validator = validator;
this.startTime = startTime;
this.endTime = endTime;
this.declineReason = declineReason;
if(insertDB) {
insertDB();
}
}
@Deprecated
public CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason){
this(Schematic.getSchemFromDB(schemName, schemOwner).getSchemID(), validator, startTime, endTime, declineReason, true);
}
@Deprecated
public CheckedSchematic(String schemName, UUID schemOwner, UUID validator, Timestamp startTime, Timestamp endTime, String declineReason){
this(Schematic.getSchemFromDB(schemName, schemOwner).getSchemID(), SteamwarUser.get(validator).getId(), startTime, endTime, declineReason, true);
}
public CheckedSchematic(int node, int validator, Timestamp startTime, Timestamp endTime, String declineReason){
this(node, validator, startTime, endTime, declineReason, true);
}
public CheckedSchematic(int node, UUID validator, Timestamp startTime, Timestamp endTime, String declineReason){
this(node, SteamwarUser.get(validator).getId(), startTime, endTime, declineReason, true);
}
private void insertDB() {
SchematicNode sNode = SchematicNode.getSchematicNode(node);
String nodeName = sNode.getName();
int nodeOwner = sNode.getOwner();
insert.update(node, nodeName, nodeOwner, validator, startTime, endTime, declineReason);
}
public static List<CheckedSchematic> getLastDeclinedOfNode(SchematicNode node){
@ -85,7 +55,7 @@ public class CheckedSchematic {
Timestamp startTime = rs.getTimestamp("StartTime");
Timestamp endTime = rs.getTimestamp("EndTime");
String declineReason = rs.getString("DeclineReason");
lastDeclined.add(new CheckedSchematic(node, validator, startTime, endTime, declineReason, false));
lastDeclined.add(new CheckedSchematic(node, validator, startTime, endTime, declineReason));
}
return lastDeclined;
}, node);
@ -99,7 +69,7 @@ public class CheckedSchematic {
return checkHistory.select(rs -> {
List<CheckedSchematic> history = new ArrayList<>();
while(rs.next())
history.add(new CheckedSchematic(rs.getInt("NodeId"), rs.getInt("Validator"), rs.getTimestamp("StartTime"), rs.getTimestamp("EndTime"), rs.getString("DeclineReason"), false));
history.add(new CheckedSchematic(rs.getInt("NodeId"), rs.getInt("Validator"), rs.getTimestamp("StartTime"), rs.getTimestamp("EndTime"), rs.getString("DeclineReason")));
return history;
}, schemOwner);
}
@ -131,8 +101,4 @@ public class CheckedSchematic {
public int getSchemOwner() {
return SchematicNode.getSchematicNode(node).getId();
}
public void remove() {
setNodeNull.update(node);
}
}

Datei anzeigen

@ -1,29 +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;
public class DownloadSchematic {
private DownloadSchematic(){}
@Deprecated
public static String getLink(Schematic schem){
return NodeDownload.getLink(schem.getNode());
}
}

Datei anzeigen

@ -22,8 +22,8 @@ package de.steamwar.sql;
public class Elo {
private Elo(){}
private static final SQL.Statement get = new SQL.Statement("SELECT Elo FROM Elo WHERE UserID = ? AND GameMode = ?");
private static final SQL.Statement set = new SQL.Statement("INSERT INTO Elo (UserID, GameMode, Elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Elo = VALUES(Elo)");
private static final Statement get = new Statement("SELECT Elo FROM Elo WHERE UserID = ? AND GameMode = ?");
private static final Statement set = new Statement("INSERT INTO Elo (UserID, GameMode, Elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Elo = VALUES(Elo)");
public static int getElo(int userId, String gameMode){
return get.select(rs -> {

Datei anzeigen

@ -25,7 +25,7 @@ import java.sql.Timestamp;
public class Event {
private static final SQL.Statement get = new SQL.Statement("SELECT * FROM Event WHERE EventID = ?");
private static final Statement get = new Statement("SELECT * FROM Event WHERE EventID = ?");
private final int eventID;
private final String eventName;

Datei anzeigen

@ -24,9 +24,9 @@ import java.sql.SQLException;
public class EventFight {
private static final SQL.Statement get = new SQL.Statement("SELECT * FROM EventFight WHERE FightID = ?");
private static final SQL.Statement setResult = new SQL.Statement("UPDATE EventFight SET Ergebnis = ? WHERE FightID = ?");
private static final SQL.Statement setFight = new SQL.Statement("UPDATE EventFight SET Fight = ? WHERE FightID = ?");
private static final Statement get = new Statement("SELECT * FROM EventFight WHERE FightID = ?");
private static final Statement setResult = new Statement("UPDATE EventFight SET Ergebnis = ? WHERE FightID = ?");
private static final Statement setFight = new Statement("UPDATE EventFight SET Fight = ? WHERE FightID = ?");
private final int eventID;
private final int fightID;

Datei anzeigen

@ -20,8 +20,6 @@
package de.steamwar.sql;
import java.io.InputStream;
import java.sql.Blob;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.function.Consumer;
@ -29,10 +27,10 @@ import java.util.function.Consumer;
public class Fight {
private Fight(){}
private static final SQL.Statement create = new SQL.Statement("INSERT INTO Fight (GameMode, Server, StartTime, Duration, BlueLeader, RedLeader, BlueSchem, RedSchem, Win, WinCondition, ReplayLock) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
private static final SQL.Statement lastId = new SQL.Statement("SELECT LAST_INSERT_ID() AS FightID");
private static final SQL.Statement getReplay = new SQL.Statement("SELECT Replay FROM Fight WHERE FightID = ?");
private static final SQL.Statement setReplay = new SQL.Statement("UPDATE Fight SET Replay = ? WHERE FightID = ?");
private static final Statement create = new Statement("INSERT INTO Fight (GameMode, Server, StartTime, Duration, BlueLeader, RedLeader, BlueSchem, RedSchem, Win, WinCondition, ReplayLock) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
private static final Statement lastId = new Statement("SELECT LAST_INSERT_ID() AS FightID");
private static final Statement getReplay = new Statement("SELECT Replay FROM Fight WHERE FightID = ?");
private static final Statement setReplay = new Statement("UPDATE Fight SET Replay = ? WHERE FightID = ?");
public static int create(String gamemode, String server, Timestamp starttime, int duration, int blueleader, int redleader, Integer blueschem, Integer redschem, int win, String wincondition){
return create(gamemode, server, starttime, duration, blueleader, redleader, blueschem, redschem, win, wincondition, Timestamp.from(Instant.now()));
@ -46,15 +44,6 @@ public class Fight {
});
}
@Deprecated
public static InputStream getReplay(int fightID) {
return getReplay.select(rs -> {
rs.next();
Blob replay = rs.getBlob("Replay");
return replay.getBinaryStream();
}, fightID);
}
public static void getReplay(int fightID, Consumer<InputStream> reader) {
getReplay.select(rs -> {
rs.next();
@ -63,17 +52,6 @@ public class Fight {
}, fightID);
}
@Deprecated
public static void setReplay(int fightID, byte[] data) {
Blob blob = SQL.blob();
try {
blob.setBytes(1, data);
} catch (SQLException e) {
throw new SecurityException(e);
}
setReplay.update(blob, fightID);
}
public static void setReplay(int fightID, InputStream data) {
setReplay.update(data, fightID);
}

Datei anzeigen

@ -22,7 +22,7 @@ package de.steamwar.sql;
public class FightPlayer {
private FightPlayer(){}
private static final SQL.Statement create = new SQL.Statement("INSERT INTO FightPlayer (FightID, UserID, Team, Kit, Kills, IsOut) VALUES (?, ?, ?, ?, ?, ?)");
private static final Statement create = new Statement("INSERT INTO FightPlayer (FightID, UserID, Team, Kit, Kills, IsOut) VALUES (?, ?, ?, ?, ?, ?)");
public static void create(int fightID, int userID, boolean blue, String kit, int kills, boolean isOut){
create.update(fightID, userID, blue ? 1 : 2, kit, kills, isOut);

Datei anzeigen

@ -27,7 +27,7 @@ import java.time.Instant;
public class NodeDownload {
private static final SQL.Statement createLink = new SQL.Statement("INSERT INTO NodeDownload (NodeId, Link) VALUES (?, ?) ON DUPLICATE KEY UPDATE Link = VALUES(Link)");
private static final Statement createLink = new Statement("INSERT INTO NodeDownload (NodeId, Link) VALUES (?, ?) ON DUPLICATE KEY UPDATE Link = VALUES(Link)");
private static final String BASE = "https://steamwar.de/download.php?schem=";

Datei anzeigen

@ -26,11 +26,11 @@ import java.util.Set;
public class NodeMember {
private static final SQL.Statement getNodeMember = new SQL.Statement("SELECT * FROM NodeMember WHERE NodeId = ? AND UserId = ?");
private static final SQL.Statement getNodeMembers = new SQL.Statement("SELECT * FROM NodeMember WHERE NodeId = ?");
private static final SQL.Statement getSchematics = new SQL.Statement("SELECT * FROM NodeMember WHERE UserId = ?");
private static final SQL.Statement createNodeMember = new SQL.Statement("INSERT INTO NodeMember (NodeId, UserId) VALUES (?, ?)");
private static final SQL.Statement deleteNodeMember = new SQL.Statement("DELETE FROM NodeMember WHERE NodeId = ? AND UserId = ?");
private static final Statement getNodeMember = new Statement("SELECT * FROM NodeMember WHERE NodeId = ? AND UserId = ?");
private static final Statement getNodeMembers = new Statement("SELECT * FROM NodeMember WHERE NodeId = ?");
private static final Statement getSchematics = new Statement("SELECT * FROM NodeMember WHERE UserId = ?");
private static final Statement createNodeMember = new Statement("INSERT INTO NodeMember (NodeId, UserId) VALUES (?, ?)");
private static final Statement deleteNodeMember = new Statement("DELETE FROM NodeMember WHERE NodeId = ? AND UserId = ?");
public static NodeMember getNodeMember(int node, int member) {
return getNodeMember.select(rs -> {

Datei anzeigen

@ -31,11 +31,11 @@ import java.util.Objects;
public class PersonalKit {
private static final SQL.Statement getKits = new SQL.Statement("SELECT * FROM PersonalKit WHERE UserID = ? AND GameMode = ?");
private static final SQL.Statement getKit = new SQL.Statement("SELECT * FROM PersonalKit WHERE UserID = ? AND GameMode = ? AND Name = ?");
private static final SQL.Statement getKitInUse = new SQL.Statement("SELECT * FROM PersonalKit WHERE UserID = ? AND GameMode = ? AND InUse = 1");
private static final SQL.Statement delete = new SQL.Statement("DELETE FROM `PersonalKit` WHERE UserID = ? AND GameMode = ? AND Name = ?");
private static final SQL.Statement update = new SQL.Statement("INSERT INTO PersonalKit (UserID, GameMode, Name, Inventory, Armor, InUse) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE Inventory = VALUES(Inventory), Armor = VALUES(Armor), Name = VALUES(Name), InUse = VALUES(InUse)");
private static final Statement getKits = new Statement("SELECT * FROM PersonalKit WHERE UserID = ? AND GameMode = ?");
private static final Statement getKit = new Statement("SELECT * FROM PersonalKit WHERE UserID = ? AND GameMode = ? AND Name = ?");
private static final Statement getKitInUse = new Statement("SELECT * FROM PersonalKit WHERE UserID = ? AND GameMode = ? AND InUse = 1");
private static final Statement delete = new Statement("DELETE FROM `PersonalKit` WHERE UserID = ? AND GameMode = ? AND Name = ?");
private static final Statement update = new Statement("INSERT INTO PersonalKit (UserID, GameMode, Name, Inventory, Armor, InUse) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE Inventory = VALUES(Inventory), Armor = VALUES(Armor), Name = VALUES(Name), InUse = VALUES(InUse)");
private final int userID;
private String name;
@ -74,8 +74,7 @@ public class PersonalKit {
if(armor == null) {
armor = new ItemStack[]{null, null, null, null};
}
SQL.update("INSERT INTO PersonalKit (UserID, GameMode, Name, Inventory, Armor) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE Inventory = VALUES(Inventory), Armor = VALUES(Armor), Name = VALUES(name)",
userID, gamemode, name, saveInvConfig("Inventory", inventory), saveInvConfig("Armor", armor));
update.update(userID, gamemode, name, saveInvConfig("Inventory", inventory), saveInvConfig("Armor", armor), true);
return get(userID, gamemode, name);
}
@ -90,18 +89,6 @@ public class PersonalKit {
}, userID, gamemode);
}
@Deprecated
public static boolean nameInUse(int userID, String gamemode, String name) {
ResultSet set = SQL.select("SELECT COUNT(*) AS Count FROM PersonalKit WHERE UserID = ? AND GameMode = ? AND Name = ?", userID, gamemode, name);
try {
if(!set.next())
return true;
return set.getInt("Count") > 0;
} catch (SQLException e) {
throw new SecurityException("Failed loading personal kit", e);
}
}
public ItemStack[] getInventory(){
YamlConfiguration config = YamlConfiguration.loadConfiguration(new StringReader(inventory));
return Objects.requireNonNull(config.getList("Inventory")).toArray(new ItemStack[0]);

Datei anzeigen

@ -31,8 +31,8 @@ import java.util.function.Consumer;
public class Punishment {
private static final SQL.Statement getPunishment = new SQL.Statement("SELECT * FROM Punishments WHERE UserId = ? AND Type = ? ORDER BY PunishmentId DESC LIMIT 1");
private static final SQL.Statement getPunishments = new SQL.Statement("SELECT * FROM Punishments WHERE PunishmentId IN (SELECT MAX(PunishmentId) FROM Punishments WHERE UserId = ? GROUP BY Type)");
private static final Statement getPunishment = new Statement("SELECT * FROM Punishments WHERE UserId = ? AND Type = ? ORDER BY PunishmentId DESC LIMIT 1");
private static final Statement getPunishments = new Statement("SELECT * FROM Punishments WHERE PunishmentId IN (SELECT MAX(PunishmentId) FROM Punishments WHERE UserId = ? GROUP BY Type)");
public static Punishment getPunishmentOfPlayer(int user, PunishmentType type) {
return getPunishment.select(rs -> {

Datei anzeigen

@ -1,201 +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 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException;
import de.steamwar.core.Core;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
public class SQL {
private SQL(){}
private static Connection con;
private static final String URL;
private static final String USER;
private static final String PASSWORD;
static {
File file = new File(Core.getInstance().getDataFolder(), "MySQL.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
if(!file.exists())
throw new SecurityException("SQL-ConfigFile not found!");
URL = "jdbc:mysql://" + config.getString("HOST") + ":" + config.getString("PORT") + "/" + config.getString("DATABASE");
USER = config.getString("USER");
PASSWORD = config.getString("PASSWORD");
connect();
}
private static void connect() {
try {
con = DriverManager.getConnection(URL + "?useServerPrepStmts=true", USER, PASSWORD);
} catch (SQLException e) {
throw new SecurityException("Could not start SQL connection", e);
}
}
public static void close() {
for (Statement statement : Statement.statements) {
try {
statement.st.close();
} catch (SQLException e) {
Core.getInstance().getLogger().log(Level.INFO, "Could not close statement", e);
}
}
try {
con.close();
} catch (SQLException e) {
Core.getInstance().getLogger().log(Level.INFO, "Could not close SQL connection", e);
}
}
private static void reset() {
close();
connect();
try {
for (Statement statement : Statement.statements) {
statement.init();
}
} catch (SQLException ex) {
throw new SecurityException("Could not reprepare SQL Statements", ex);
}
}
public static boolean connectionStable() {
try {
return !con.isClosed();
} catch (SQLException e) {
return false;
}
}
@Deprecated
static void update(String qry, Object... objects) {
try {
prepare(qry, objects).executeUpdate();
} catch (SQLException e) {
reset();
throw new SecurityException("Could not execute SQL statement", e);
}
}
@Deprecated
static ResultSet select(String qry, Object... objects) {
try {
return prepare(qry, objects).executeQuery();
} catch (SQLException e) {
reset();
throw new SecurityException("Could not execute SQL statement", e);
}
}
@Deprecated
static Blob blob() {
try {
return con.createBlob();
} catch (SQLException e) {
reset();
throw new SecurityException("Could not execute SQL statement", e);
}
}
@Deprecated
private static PreparedStatement prepare(String qry, Object... objects) throws SQLException {
PreparedStatement st = con.prepareStatement(qry);
for(int i = 0; i < objects.length; i++){
st.setObject(i+1, objects[i]);
}
return st;
}
public static class Statement {
private static final List<Statement> statements = new ArrayList<>();
private final String sql;
private PreparedStatement st;
Statement(String sql) {
this.sql = sql;
statements.add(this);
try {
init();
} catch (SQLException e) {
throw new SecurityException("Could not init statement", e);
}
}
private synchronized void init() throws SQLException {
st = con.prepareStatement(sql);
}
<T> T select(ResultSetUser<T> user, Object... objects) {
return prepare(() -> {
ResultSet rs = st.executeQuery();
T result = user.use(rs);
rs.close();
return result;
}, objects);
}
void update(Object... objects) {
prepare(st::executeUpdate, objects);
}
private synchronized <T> T prepare(SQLRunnable<T> runnable, Object... objects) {
try {
try {
setObjects(objects);
return runnable.run();
} catch (CommunicationsException e) {
reset();
setObjects(objects);
return runnable.run();
}
} catch (SQLException e) {
throw new SecurityException("Could not execute SQL statement", e);
}
}
private void setObjects(Object... objects) throws SQLException {
for (int i = 0; i < objects.length; i++) {
st.setObject(i + 1, objects[i]);
}
}
interface ResultSetUser<T> {
T use(ResultSet rs) throws SQLException;
}
private interface SQLRunnable<T> {
T run() throws SQLException;
}
}
}

Datei anzeigen

@ -25,7 +25,7 @@ import org.bukkit.entity.Player;
public class SWException {
private SWException(){}
private static final SQL.Statement insert = new SQL.Statement("INSERT INTO Exception (server, message, stacktrace) VALUES (?, ?, ?)");
private static final Statement insert = new Statement("INSERT INTO Exception (server, message, stacktrace) VALUES (?, ?, ?)");
public static void log(String message, String stacktrace){
message += "\n";

Datei anzeigen

@ -1,204 +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 com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.core.Core;
import de.steamwar.core.WorldEditWrapper;
import org.bukkit.entity.Player;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
@Deprecated
public class Schematic {
private static final SQL.Statement getSchemsOfType = new SQL.Statement("SELECT DISTINCT s.SchemID, s.SchemName, s.SchemOwner, s.Item, s.SchemType, s.Rank, s.SchemFormat FROM Schematic s LEFT JOIN SchemMember sm ON sm.SchemName = s.SchemName AND sm.SchemOwner = s.SchemOwner WHERE s.SchemType = ? AND (s.SchemOwner = ? OR sm.Member = ?) ORDER BY s.SchemName");
private final SchematicNode node;
private Schematic(SchematicNode node) {
this.node = node;
}
public static Schematic wrap(SchematicNode node) {
return new Schematic(node);
}
public static void createSchem(String schemName, UUID schemOwner, String item, SchematicType schemType){
createSchem(schemName, SteamwarUser.get(schemOwner).getId(), item, schemType);
}
public static void createSchem(String schemName, int schemOwner, String item, SchematicType schemType){
SchematicNode.createSchematicNode(schemOwner, schemName, null, schemType.toDB(), item);
}
public static Schematic getSchemFromDB(String schemName, UUID schemOwner){
return getSchemFromDB(schemName, SteamwarUser.get(schemOwner).getId());
}
public static Schematic getSchemFromDB(String schemName, int schemOwner){
SchematicNode node = SchematicNode.getSchematicNode(schemOwner, schemName, 0);
if(node != null) {
return new Schematic(node);
} else {
Optional<SchematicNode> n = SchematicNode.getSchematicsAccessibleByUser(schemOwner, 0).stream().filter(node1 -> node1.getName().equals(schemName)).findAny();
if(n.isPresent()) {
return new Schematic(n.get());
}
}
return null;
}
public static Schematic getSchemFromDB(int schemID){
SchematicNode node = SchematicNode.getSchematicNode(schemID);
if(node != null) {
return new Schematic(node);
} else {
throw new SecurityException("Failed to load Schematics");
}
}
public static List<Schematic> getSchemsAccessibleByUser(UUID schemOwner){
return getSchemsAccessibleByUser(SteamwarUser.get(schemOwner).getId());
}
public static List<Schematic> getSchemsAccessibleByUser(int schemOwner){
List<Schematic> schematics = new ArrayList<>();
SchematicNode.getSchematicsAccessibleByUser(schemOwner, null)
.forEach(node1 -> {
if (!node1.isDir()) schematics.add(new Schematic(node1));
});
return schematics;
}
public static List<Schematic> getSchemsOfType(UUID schemOwner, SchematicType schemType){
return getSchemsOfType(SteamwarUser.get(schemOwner).getId(), schemType);
}
public static List<Schematic> getSchemsOfType(int schemOwner, SchematicType schemType){
List<Schematic> schematics = new ArrayList<>();
SchematicNode.getAllAccessibleSchematicsOfType(schemOwner, schemType.toDB())
.forEach(node1 -> {
if (!node1.isDir()) schematics.add(new Schematic(node1));
});
return schematics;
}
public static List<Schematic> getAllSchemsOfType(SchematicType schemType){
List<Schematic> schematics = new ArrayList<>();
SchematicNode.getAllSchematicsOfType(schemType.toDB())
.forEach(node1 -> schematics.add(new Schematic(node1)));
return schematics;
}
public int getSchemID() {
return node.getId();
}
public String getSchemName() {
return node.getName();
}
public int getSchemOwner() {
return node.getOwner();
}
public int getRank(){
return node.getRank();
}
public String getItem() {
return node.getItem();
}
public void setItem(String item) {
node.setItem(item);
}
public void setRank(int rank){
node.setRank(rank);
}
public SchematicType getSchemType() {
return node.getSchemtype();
}
public void setSchemType(SchematicType schemType) {
node.setType(schemType.toDB());
}
public boolean availible(){
return true;
}
public InputStream schemData() throws IOException {
return node.schemData();
}
public static Clipboard clipboardFromStream(InputStream is, boolean schemFormat) {
try {
return WorldEditWrapper.impl.getClipboard(is, schemFormat);
} catch (IOException e) {
throw new SecurityException("Could not read schem", e);
}
}
public Clipboard load() throws IOException, NoClipboardException {
return clipboardFromStream(schemData(), node.getSchemFormat());
}
public void loadToPlayer(Player player) throws IOException, NoClipboardException {
InputStream is = schemData();
WorldEditWrapper.impl.setPlayerClipboard(player, is, node.getSchemFormat());
}
public void saveOldFormatFromPlayer(Player player) throws IOException, NoClipboardException {
saveFromPlayer(player, false);
}
public void saveFromPlayer(Player player) throws IOException, NoClipboardException {
saveFromPlayer(player, Core.getVersion() > 12);
}
public void saveFromBytes(byte[] bytes, boolean newFormat) {
node.saveFromBytes(bytes, newFormat);
}
private void saveFromPlayer(Player player, boolean newFormat) throws IOException, NoClipboardException {
node.saveFromPlayer(player, newFormat);
}
public void remove(){
node.delete();
}
public SchematicNode getNode() {
return node;
}
@Deprecated
public static class WrongVersionException extends Exception{}
}

Datei anzeigen

@ -1,96 +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 java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@Deprecated
public class SchematicMember {
private final NodeMember member;
private SchematicMember(NodeMember member){
this.member = member;
}
public SchematicMember(String schemName, int schemOwner, int schemMember){
this(NodeMember.createNodeMember(Schematic.getSchemFromDB(schemName, schemOwner).getSchemID(), schemMember));
}
public SchematicMember(String schemName, UUID schemOwner, UUID schemMember){
this(NodeMember.createNodeMember(Schematic.getSchemFromDB(schemName, schemOwner).getSchemID(), SteamwarUser.get(schemMember).getId()));
}
public static SchematicMember getSchemMemberFromDB(String schemName, UUID schemOwner, UUID schemMember){
return getSchemMemberFromDB(schemName, SteamwarUser.get(schemOwner).getId(), SteamwarUser.get(schemMember).getId());
}
public static SchematicMember getSchemMemberFromDB(String schemName, int schemOwner, int schemMember){
NodeMember member = NodeMember.getNodeMember(Schematic.getSchemFromDB(schemName, schemOwner).getSchemID(), schemMember);
if(member == null) {
return null;
}
return new SchematicMember(member);
}
public static SchematicMember getMemberBySchematic(String schemName, int schemMember){
Optional<NodeMember> nodeMember = NodeMember.getSchematics(schemMember)
.stream().filter(member1 -> SchematicNode.getSchematicNode(member1.getNode()).getName().equalsIgnoreCase(schemName)).findFirst();
return nodeMember.map(SchematicMember::new).orElse(null);
}
public static List<SchematicMember> getSchemMembers(String schemName, UUID schemOwner){
return getSchemMembers(schemName, SteamwarUser.get(schemOwner).getId());
}
public static List<SchematicMember> getSchemMembers(String schemName, int schemOwner){
List<SchematicMember> members = new ArrayList<>();
NodeMember.getNodeMembers(Schematic.getSchemFromDB(schemName, schemOwner).getSchemID())
.forEach(member1 -> members.add(new SchematicMember(member1)));
return members;
}
public static List<SchematicMember> getAccessibleSchems(UUID schemMember){
return getAccessibleSchems(SteamwarUser.get(schemMember).getId());
}
public static List<SchematicMember> getAccessibleSchems(int schemMember){
List<SchematicMember> members = new ArrayList<>();
NodeMember.getSchematics(schemMember)
.forEach(member1 -> members.add(new SchematicMember(member1)));
return members;
}
public int getSchemOwner() {
return SchematicNode.getSchematicNode(member.getNode()).getOwner();
}
public String getSchemName() {
return SchematicNode.getSchematicNode(member.getNode()).getName();
}
public int getMember() {
return member.getMember();
}
public void remove(){
member.delete();
}
}

Datei anzeigen

@ -39,32 +39,32 @@ import java.util.zip.GZIPInputStream;
public class SchematicNode {
private static final SQL.Statement createNode = new SQL.Statement("INSERT INTO SchematicNode (NodeName, NodeOwner, ParentNode, NodeType, NodeItem) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE NodeName = VALUES(NodeName), ParentNode = VALUES(ParentNode), NodeItem = VALUES(NodeItem), NodeType = VALUES(NodeType), NodeItem = VALUES(NodeItem)");
private static final SQL.Statement getSchematicNode_Null = new SQL.Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeName = ? AND ParentNode is NULL");
private static final SQL.Statement getSchematicNode = new SQL.Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeName = ? AND ParentNode = ?");
private static final SQL.Statement getSchematicsInNode_Null = new SQL.Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode is NULL ORDER BY NodeName");
private static final SQL.Statement getSchematicsInNode = new SQL.Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode = ? ORDER BY NodeName");
private static final SQL.Statement getDirsInNode_Null = new SQL.Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode is NULL AND NodeType is NULL ORDER BY NodeName");
private static final SQL.Statement getDirsInNode = new SQL.Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode = ? AND NodeType is NULL ORDER BY NodeName");
private static final SQL.Statement getSchematicDirectory_Null = new SQL.Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode is NULL ORDER BY NodeName");
private static final SQL.Statement getSchematicDirectory = new SQL.Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode = ? ORDER BY NodeName");
private static final SQL.Statement getSchematicNodeO_Null = new SQL.Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode is NULL ");
private static final SQL.Statement getSchematicNodeO = new SQL.Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode = ? ORDER BY NodeName");
private static final SQL.Statement getSchematicNodeId = new SQL.Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeId = ?");
private static final SQL.Statement getAllSchemsOfTypeOwner = new SQL.Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeType = ? ORDER BY NodeName");
private static final SQL.Statement getAllSchemsOfType = new SQL.Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeType = ? ORDER BY NodeName");
private static final SQL.Statement getAccessibleByUser = new SQL.Statement("SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) AND ((s.NodeOwner = ? AND s.ParentNode IS NULL) OR NOT s.NodeOwner = ?) GROUP BY s.NodeId ORDER BY s.NodeName");
private static final SQL.Statement getAccessibleByUserByTypeInNode = new SQL.Statement("WITH RECURSIVE RSNB AS (WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN WHERE NodeType = ? union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSNB WHERE SN.NodeId = RSNB.ParentNode)SELECT * FROM RSNB WHERE ParentNode = ? ORDER BY NodeName");
private static final SQL.Statement getAccessibleByUserByTypeInNode_Null = new SQL.Statement("WITH RECURSIVE RSNB AS (WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN WHERE NodeType = ? union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSNB WHERE SN.NodeId = RSNB.ParentNode)SELECT * FROM RSNB WHERE ParentNode is null ORDER BY NodeName");
private static final SQL.Statement getAccessibleByUserByType = new SQL.Statement("WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN WHERE NodeType = ? ORDER BY NodeName");
private static final SQL.Statement getAllSchematicsAccessibleByUser = new SQL.Statement("WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN ORDER BY NodeName");
private static final SQL.Statement isSchematicAccessibleForUser = new SQL.Statement("WITH RECURSIVE RSN AS (SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeId = ? union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.ParentNode, SN.NodeType, SN.NodeItem, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode SN, RSN WHERE RSN.ParentNode = SN.NodeId) SELECT COUNT(RSN.NodeId) AS `Accessible` FROM RSN LEFT Join NodeMember NM On NM.NodeId = RSN.NodeId WHERE NodeOwner = ? OR UserId = ? LIMIT 1");
private static final SQL.Statement getAllParentsOfNode = new SQL.Statement("WITH RECURSIVE RSN AS (SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeId = ? UNION SELECT SN.NodeId, SN.NodeName, SN.NodeOwner, SN.ParentNode, SN.NodeType, SN.NodeItem, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode SN, RSN WHERE RSN.ParentNode = SN.NodeId) SELECT * FROM RSN ORDER BY NodeName");
private static final SQL.Statement countNodes = new SQL.Statement("SELECT COUNT(NodeId) AS 'count' FROM SchematicNode");
private static final SQL.Statement updateDB = new SQL.Statement("UPDATE SchematicNode SET NodeName = ?, NodeOwner = ?, ParentNode = ?, NodeItem = ?, NodeType = ?, NodeRank = ? WHERE NodeId = ?");
private static final SQL.Statement updateDatabase = new SQL.Statement("UPDATE SchematicNode SET NodeData = ?, NodeFormat = ? WHERE NodeId = ?");
private static final SQL.Statement selSchemData = new SQL.Statement("SELECT NodeData FROM SchematicNode WHERE NodeId = ?");
private static final SQL.Statement deleteNode = new SQL.Statement("DELETE FROM SchematicNode WHERE NodeId = ?");
private static final Statement createNode = new Statement("INSERT INTO SchematicNode (NodeName, NodeOwner, ParentNode, NodeType, NodeItem) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE NodeName = VALUES(NodeName), ParentNode = VALUES(ParentNode), NodeItem = VALUES(NodeItem), NodeType = VALUES(NodeType), NodeItem = VALUES(NodeItem)");
private static final Statement getSchematicNode_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeName = ? AND ParentNode is NULL");
private static final Statement getSchematicNode = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeName = ? AND ParentNode = ?");
private static final Statement getSchematicsInNode_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode is NULL ORDER BY NodeName");
private static final Statement getSchematicsInNode = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode = ? ORDER BY NodeName");
private static final Statement getDirsInNode_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode is NULL AND NodeType is NULL ORDER BY NodeName");
private static final Statement getDirsInNode = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode = ? AND NodeType is NULL ORDER BY NodeName");
private static final Statement getSchematicDirectory_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode is NULL ORDER BY NodeName");
private static final Statement getSchematicDirectory = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode = ? ORDER BY NodeName");
private static final Statement getSchematicNodeO_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode is NULL ");
private static final Statement getSchematicNodeO = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode = ? ORDER BY NodeName");
private static final Statement getSchematicNodeId = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeId = ?");
private static final Statement getAllSchemsOfTypeOwner = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeType = ? ORDER BY NodeName");
private static final Statement getAllSchemsOfType = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeType = ? ORDER BY NodeName");
private static final Statement getAccessibleByUser = new Statement("SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) AND ((s.NodeOwner = ? AND s.ParentNode IS NULL) OR NOT s.NodeOwner = ?) GROUP BY s.NodeId ORDER BY s.NodeName");
private static final Statement getAccessibleByUserByTypeInNode = new Statement("WITH RECURSIVE RSNB AS (WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN WHERE NodeType = ? union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSNB WHERE SN.NodeId = RSNB.ParentNode)SELECT * FROM RSNB WHERE ParentNode = ? ORDER BY NodeName");
private static final Statement getAccessibleByUserByTypeInNode_Null = new Statement("WITH RECURSIVE RSNB AS (WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN WHERE NodeType = ? union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSNB WHERE SN.NodeId = RSNB.ParentNode)SELECT * FROM RSNB WHERE ParentNode is null ORDER BY NodeName");
private static final Statement getAccessibleByUserByType = new Statement("WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN WHERE NodeType = ? ORDER BY NodeName");
private static final Statement getAllSchematicsAccessibleByUser = new Statement("WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN ORDER BY NodeName");
private static final Statement isSchematicAccessibleForUser = new Statement("WITH RECURSIVE RSN AS (SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeId = ? union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.ParentNode, SN.NodeType, SN.NodeItem, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode SN, RSN WHERE RSN.ParentNode = SN.NodeId) SELECT COUNT(RSN.NodeId) AS `Accessible` FROM RSN LEFT Join NodeMember NM On NM.NodeId = RSN.NodeId WHERE NodeOwner = ? OR UserId = ? LIMIT 1");
private static final Statement getAllParentsOfNode = new Statement("WITH RECURSIVE RSN AS (SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeId = ? UNION SELECT SN.NodeId, SN.NodeName, SN.NodeOwner, SN.ParentNode, SN.NodeType, SN.NodeItem, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode SN, RSN WHERE RSN.ParentNode = SN.NodeId) SELECT * FROM RSN ORDER BY NodeName");
private static final Statement countNodes = new Statement("SELECT COUNT(NodeId) AS 'count' FROM SchematicNode");
private static final Statement updateDB = new Statement("UPDATE SchematicNode SET NodeName = ?, NodeOwner = ?, ParentNode = ?, NodeItem = ?, NodeType = ?, NodeRank = ? WHERE NodeId = ?");
private static final Statement updateDatabase = new Statement("UPDATE SchematicNode SET NodeData = ?, NodeFormat = ? WHERE NodeId = ?");
private static final Statement selSchemData = new Statement("SELECT NodeData FROM SchematicNode WHERE NodeId = ?");
private static final Statement deleteNode = new Statement("DELETE FROM SchematicNode WHERE NodeId = ?");
public static SchematicNode createSchematic(int owner, String name, Integer parent) {
return createSchematicNode(owner, name, parent, SchematicType.Normal.toDB(), "");
@ -117,7 +117,7 @@ public class SchematicNode {
if (parent != null && parent == 0) {
parent = null;
}
SQL.Statement.ResultSetUser<SchematicNode> user = rs -> {
Statement.ResultSetUser<SchematicNode> user = rs -> {
if (rs.next()) {
return new SchematicNode(rs);
}
@ -133,7 +133,7 @@ public class SchematicNode {
public static List<SchematicNode> getSchematicNodeInNode(Integer parent) {
if(parent != null && parent == 0)
parent = null;
SQL.Statement.ResultSetUser<List<SchematicNode>> user = rs -> {
Statement.ResultSetUser<List<SchematicNode>> user = rs -> {
List<SchematicNode> nodes = new ArrayList<>();
while (rs.next()) {
nodes.add(new SchematicNode(rs));
@ -150,7 +150,7 @@ public class SchematicNode {
public static List<SchematicNode> getSchematicDirectoryInNode(Integer parent) {
if(parent != null && parent == 0)
parent = null;
SQL.Statement.ResultSetUser<List<SchematicNode>> user = rs -> {
Statement.ResultSetUser<List<SchematicNode>> user = rs -> {
List<SchematicNode> nodes = new ArrayList<>();
while (rs.next())
nodes.add(new SchematicNode(rs));
@ -166,7 +166,7 @@ public class SchematicNode {
public static SchematicNode getSchematicDirectory(String name, Integer parent) {
if(parent != null && parent == 0)
parent = null;
SQL.Statement.ResultSetUser<SchematicNode> user = rs -> {
Statement.ResultSetUser<SchematicNode> user = rs -> {
while (rs.next()) {
SchematicNode node = new SchematicNode(rs);
if(node.isDir())
@ -185,7 +185,7 @@ public class SchematicNode {
public static SchematicNode getSchematicNode(String name, Integer parent) {
if(parent != null && parent == 0)
parent = null;
SQL.Statement.ResultSetUser<SchematicNode> user = rs -> {
Statement.ResultSetUser<SchematicNode> user = rs -> {
while (rs.next()) {
return new SchematicNode(rs);
}
@ -207,7 +207,7 @@ public class SchematicNode {
}
public static List<SchematicNode> getAccessibleSchematicsOfTypeInParent(int owner, String schemType, Integer parent) {
SQL.Statement.ResultSetUser<List<SchematicNode>> user = rs -> {
Statement.ResultSetUser<List<SchematicNode>> user = rs -> {
List<SchematicNode> nodes = new ArrayList<>();
while (rs.next()) {
nodes.add(new SchematicNode(rs));

Datei anzeigen

@ -0,0 +1,159 @@
/*
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 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException;
import de.steamwar.core.Core;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
public class Statement {
private static final String URL;
private static final String USER;
private static final String PASSWORD;
private static Connection con;
private static final List<Statement> statements = new ArrayList<>();
static {
File file = new File(Core.getInstance().getDataFolder(), "MySQL.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
if(!file.exists())
throw new SecurityException("SQL-ConfigFile not found!");
URL = "jdbc:mysql://" + config.getString("HOST") + ":" + config.getString("PORT") + "/" + config.getString("DATABASE");
USER = config.getString("USER");
PASSWORD = config.getString("PASSWORD");
Statement.connect();
}
private static void connect() {
try {
con = DriverManager.getConnection(URL + "?useServerPrepStmts=true", USER, PASSWORD);
} catch (SQLException e) {
throw new SecurityException("Could not start SQL connection", e);
}
}
public static void close() {
for (Statement statement : statements) {
try {
statement.st.close();
} catch (SQLException e) {
Core.getInstance().getLogger().log(Level.INFO, "Could not close statement", e);
}
}
try {
con.close();
} catch (SQLException e) {
Core.getInstance().getLogger().log(Level.INFO, "Could not close SQL connection", e);
}
}
private static void reset() {
close();
connect();
try {
for (Statement statement : statements) {
statement.init();
}
} catch (SQLException ex) {
throw new SecurityException("Could not reprepare SQL Statements", ex);
}
}
public static boolean connectionStable() {
try {
return !con.isClosed();
} catch (SQLException e) {
return false;
}
}
private final String sql;
private PreparedStatement st;
Statement(String sql) {
this.sql = sql;
try {
init();
} catch (SQLException e) {
throw new SecurityException("Could not init statement", e);
}
statements.add(this);
}
private synchronized void init() throws SQLException {
st = con.prepareStatement(sql);
}
<T> T select(ResultSetUser<T> user, Object... objects) {
return prepare(() -> {
ResultSet rs = st.executeQuery();
T result = user.use(rs);
rs.close();
return result;
}, objects);
}
void update(Object... objects) {
prepare(st::executeUpdate, objects);
}
private synchronized <T> T prepare(SQLRunnable<T> runnable, Object... objects) {
try {
try {
setObjects(objects);
return runnable.run();
} catch (CommunicationsException e) {
reset();
setObjects(objects);
return runnable.run();
}
} catch (SQLException e) {
throw new SecurityException("Could not execute SQL statement", e);
}
}
private void setObjects(Object... objects) throws SQLException {
for (int i = 0; i < objects.length; i++) {
st.setObject(i + 1, objects[i]);
}
}
interface ResultSetUser<T> {
T use(ResultSet rs) throws SQLException;
}
private interface SQLRunnable<T> {
T run() throws SQLException;
}
}

Datei anzeigen

@ -31,9 +31,9 @@ import java.util.UUID;
public class SteamwarUser {
private static final SQL.Statement getId = new SQL.Statement("SELECT * FROM UserData WHERE id = ?");
private static final SQL.Statement getUUID = new SQL.Statement("SELECT * FROM UserData WHERE UUID = ?");
private static final SQL.Statement getName = new SQL.Statement("SELECT * FROM UserData WHERE lower(UserName) = ?");
private static final Statement getId = new Statement("SELECT * FROM UserData WHERE id = ?");
private static final Statement getUUID = new Statement("SELECT * FROM UserData WHERE UUID = ?");
private static final Statement getName = new Statement("SELECT * FROM UserData WHERE lower(UserName) = ?");
private static final Map<UUID, SteamwarUser> byUUID = new HashMap<>();
private static final Map<String, SteamwarUser> byName = new HashMap<>();

Datei anzeigen

@ -26,8 +26,8 @@ import java.util.List;
public class Team {
private static final SQL.Statement get = new SQL.Statement("SELECT * FROM Team WHERE TeamID = ?");
private static final SQL.Statement getMembers = new SQL.Statement("SELECT id FROM UserData WHERE Team = ?");
private static final Statement get = new Statement("SELECT * FROM Team WHERE TeamID = ?");
private static final Statement getMembers = new Statement("SELECT id FROM UserData WHERE Team = ?");
private final int teamId;
private final String teamKuerzel;

Datei anzeigen

@ -26,9 +26,9 @@ import java.util.Set;
public class TeamTeilnahme {
private TeamTeilnahme(){}
private static final SQL.Statement byEventTeam = new SQL.Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?");
private static final SQL.Statement byEvent = new SQL.Statement("SELECT * FROM TeamTeilnahme WHERE EventID = ?");
private static final SQL.Statement byTeam = new SQL.Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ?");
private static final Statement byEventTeam = new Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?");
private static final Statement byEvent = new Statement("SELECT * FROM TeamTeilnahme WHERE EventID = ?");
private static final Statement byTeam = new Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ?");
public static boolean nimmtTeil(int teamID, int eventID){
return byEventTeam.select(ResultSet::next, teamID, eventID);

Datei anzeigen

@ -24,9 +24,9 @@ import java.util.UUID;
public class UserConfig {
private UserConfig() {}
private static final SQL.Statement get = new SQL.Statement("SELECT Value FROM UserConfig WHERE User = ? AND Config = ?");
private static final SQL.Statement set = new SQL.Statement("INSERT INTO UserConfig (User, Config, Value) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Value = VALUES(Value)");
private static final SQL.Statement delete = new SQL.Statement("DELETE FROM UserConfig WHERE User = ? AND Config = ?");
private static final Statement get = new Statement("SELECT Value FROM UserConfig WHERE User = ? AND Config = ?");
private static final Statement set = new Statement("INSERT INTO UserConfig (User, Config, Value) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Value = VALUES(Value)");
private static final Statement delete = new Statement("DELETE FROM UserConfig WHERE User = ? AND Config = ?");
public static String getConfig(UUID player, String config) {
return getConfig(SteamwarUser.get(player).getId(), config);