Lixfel
4f2d1cb41d
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
77 Zeilen
2.2 KiB
Java
77 Zeilen
2.2 KiB
Java
/*
|
|
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.fightsystem.record;
|
|
|
|
import de.steamwar.fightsystem.Config;
|
|
|
|
import java.io.*;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.StandardCopyOption;
|
|
import java.util.zip.GZIPInputStream;
|
|
|
|
public class FileSource extends PacketSource {
|
|
|
|
public static void startReplay() {
|
|
if(Config.replayserver()) {
|
|
try {
|
|
new LiveServer();
|
|
} catch (IOException e) {
|
|
throw new SecurityException("Could not start replayserver", e);
|
|
}
|
|
return;
|
|
}
|
|
|
|
de.steamwar.sql.Fight.getReplay(Config.ReplayID, input -> {
|
|
try {
|
|
Files.copy(
|
|
input,
|
|
FileRecorder.getFile().toPath(),
|
|
StandardCopyOption.REPLACE_EXISTING);
|
|
} catch (IOException e) {
|
|
throw new SecurityException("Could not start replay", e);
|
|
}
|
|
});
|
|
|
|
try {
|
|
new FileSource(FileRecorder.getFile());
|
|
} catch (IOException e) {
|
|
throw new SecurityException("Could not start replay", e);
|
|
}
|
|
}
|
|
|
|
public FileSource(File fightFile) throws IOException {
|
|
super(new GZIPInputStream(new FileInputStream(fightFile)));
|
|
}
|
|
|
|
@Override
|
|
boolean isClosed() {
|
|
try{
|
|
return available() == 0;
|
|
}catch (IOException e){
|
|
return true;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
boolean async() {
|
|
return false;
|
|
}
|
|
}
|