From 6c19de82e5b27c212c4e9cbacebf4a62a87c59eb Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 24 Oct 2021 16:28:36 +0200 Subject: [PATCH] Streaming replay --- SpigotCore_Main/src/de/steamwar/sql/Fight.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/SpigotCore_Main/src/de/steamwar/sql/Fight.java b/SpigotCore_Main/src/de/steamwar/sql/Fight.java index dfc7a97..aa3b54b 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/Fight.java +++ b/SpigotCore_Main/src/de/steamwar/sql/Fight.java @@ -23,6 +23,7 @@ import java.io.InputStream; import java.sql.Blob; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.function.Consumer; public class Fight { private Fight(){} @@ -44,6 +45,7 @@ public class Fight { }); } + @Deprecated public static InputStream getReplay(int fightID) { return getReplay.select(rs -> { rs.next(); @@ -52,6 +54,15 @@ public class Fight { }, fightID); } + public static void getReplay(int fightID, Consumer reader) { + getReplay.select(rs -> { + rs.next(); + reader.accept(rs.getBinaryStream("Replay")); + return null; + }, fightID); + } + + @Deprecated public static void setReplay(int fightID, byte[] data) { Blob blob = SQL.blob(); try { @@ -61,4 +72,8 @@ public class Fight { } setReplay.update(blob, fightID); } + + public static void setReplay(int fightID, InputStream data) { + setReplay.update(data, fightID); + } } -- 2.39.5