From a6a5499d0c55bbc880fb9db3e6adc27eef16ffcb Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 23 Aug 2021 18:52:40 +0200 Subject: [PATCH] Schematic inputstream api --- .../src/de/steamwar/sql/Schematic.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/Schematic.java b/SpigotCore_Main/src/de/steamwar/sql/Schematic.java index dbdee0f..417fb1e 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/Schematic.java +++ b/SpigotCore_Main/src/de/steamwar/sql/Schematic.java @@ -182,21 +182,28 @@ public class Schematic { return true; } - public Clipboard load() throws IOException, NoClipboardException { + public InputStream schemData() throws IOException { ResultSet rs = SQL.select("SELECT SchemData FROM Schematic WHERE SchemID = ?", schemID); try { rs.next(); Blob schemData = rs.getBlob("SchemData"); if(schemData == null) throw new IOException("SchemData is null"); - InputStream is = schemData.getBinaryStream(); - return VersionedCallable.call(new VersionedCallable<>(() -> Schematic_8.getClipboard(is, schemFormat), 8), - new VersionedCallable<>(() -> Schematic_14.getClipboard(is, schemFormat), 14)); + return schemData.getBinaryStream(); } catch (SQLException e) { throw new IOException(e); } } + public static Clipboard clipboardFromStream(InputStream is, boolean schemFormat) { + return VersionedCallable.call(new VersionedCallable<>(() -> Schematic_8.getClipboard(is, schemFormat), 8), + new VersionedCallable<>(() -> Schematic_14.getClipboard(is, schemFormat), 14)); + } + + public Clipboard load() throws IOException, NoClipboardException { + return clipboardFromStream(schemData(), schemFormat); + } + public void loadToPlayer(Player player) throws IOException, NoClipboardException { ResultSet rs = SQL.select("SELECT SchemData FROM Schematic WHERE SchemID = ?", schemID); try { -- 2.39.2