From 724246e48e0dcff7a363e3e5b9bfb1bb91d2213b Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 23 Feb 2023 17:33:30 +0100 Subject: [PATCH] Update to CommonDB --- CommonCore | 2 +- .../bot/listeners/PrivateMessageListener.java | 4 +- src/de/steamwar/sql/SchematicData.java | 47 ------------------- 3 files changed, 3 insertions(+), 50 deletions(-) delete mode 100644 src/de/steamwar/sql/SchematicData.java diff --git a/CommonCore b/CommonCore index 95b46f3..d22bb36 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit 95b46f3a9a83eb63f5770552134967a1921ae159 +Subproject commit d22bb36fc348fae373713b83235cef67010cf020 diff --git a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java b/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java index d6ef0d4..08726e4 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java @@ -19,8 +19,8 @@ package de.steamwar.bungeecore.bot.listeners; import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.sql.NodeData; import de.steamwar.sql.Punishment; -import de.steamwar.sql.SchematicData; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; import net.dv8tion.jda.api.entities.Message; @@ -67,7 +67,7 @@ public class PrivateMessageListener extends BasicDiscordListener { try { InputStream in = attachment.retrieveInputStream().get(); - new SchematicData(node).saveFromStream(in, newFormat); + NodeData.get(node).saveFromStream(in, newFormat); in.close(); event.getMessage().reply("`" + name + "` wurde erfolgreich hochgeladen").queue(); } catch (Exception e) { diff --git a/src/de/steamwar/sql/SchematicData.java b/src/de/steamwar/sql/SchematicData.java deleted file mode 100644 index 6152ad9..0000000 --- a/src/de/steamwar/sql/SchematicData.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2023 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 . - */ - -package de.steamwar.sql; - -import de.steamwar.sql.internal.SqlTypeMapper; -import de.steamwar.sql.internal.Statement; - -import java.io.BufferedInputStream; -import java.io.InputStream; -import java.sql.PreparedStatement; - -public class SchematicData { - - static { - new SqlTypeMapper<>(BufferedInputStream.class, "BLOB", (rs, identifier) -> { throw new SecurityException("PipedInputStream is write only datatype"); }, PreparedStatement::setBinaryStream); - } - - private static final Statement updateDatabase = new Statement("UPDATE SchematicNode SET NodeData = ?, NodeFormat = ? WHERE NodeId = ?"); - - private final SchematicNode node; - - public SchematicData(SchematicNode node) { - this.node = node; - } - - public void saveFromStream(InputStream blob, boolean newFormat) { - updateDatabase.update(new BufferedInputStream(blob), newFormat, node.getId()); - node.setNodeFormat(newFormat); - } -} \ No newline at end of file