SteamWar/FightSystem
Archiviert
13
1

Omni-Replay #280

Manuell gemergt
Lixfel hat 15 Commits von spectate2.0 nach master 2021-08-27 22:12:03 +02:00 zusammengeführt
5 geänderte Dateien mit 49 neuen und 23 gelöschten Zeilen
Nur Änderungen aus Commit 20f3b609cb werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -30,10 +30,7 @@ import de.steamwar.fightsystem.fight.FightWorld;
import de.steamwar.fightsystem.fight.IFight;
import de.steamwar.fightsystem.listener.Shutdown;
import de.steamwar.fightsystem.listener.*;
import de.steamwar.fightsystem.record.FileRecorder;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.record.LiveRecorder;
import de.steamwar.fightsystem.record.PacketProcessor;
import de.steamwar.fightsystem.record.*;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.utils.EnterHandler;
@ -109,7 +106,6 @@ public class FightSystem extends JavaPlugin {
new RankedPlayerLeftWincondition();
new WinconditionPercentTimeout();
//noinspection InstantiationOfUtilityClass
new HellsBells();
new NoPlayersOnlineCountdown();
@ -160,6 +156,7 @@ public class FightSystem extends JavaPlugin {
}
}else if(Config.mode == ArenaMode.REPLAY) {
FightWorld.forceLoad();
FileSource.startReplay();
}
}
@ -192,16 +189,17 @@ public class FightSystem extends JavaPlugin {
}
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
FightState.setFightState(FightState.SPECTATE);
if(PacketProcessor.isReplaying())
return;
if(!PacketProcessor.isReplaying()){
if(winFightTeam != null) {
Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
} else {
Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
}
}
FightState.setFightState(FightState.SPECTATE);
if(!Config.test() && !PacketProcessor.isReplaying()){
if(Config.mode == ArenaMode.EVENT) {
if (winFightTeam == null)
getEventFight().setErgebnis(0);
@ -211,7 +209,6 @@ public class FightSystem extends JavaPlugin {
getEventFight().setErgebnis(2);
}
if(!Config.test()){
FightStatistics.saveStats(winFightTeam, windescription);
}
}

Datei anzeigen

@ -37,7 +37,7 @@ public class FileRecorder extends StateDependent implements Recorder {
}
public FileRecorder(){
super(ArenaMode.AntiReplay, FightState.Schem);
super(ArenaMode.AntiReplay, FightState.Recording);
}
@Override

Datei anzeigen

@ -19,17 +19,35 @@
package de.steamwar.fightsystem.record;
import de.steamwar.fightsystem.Config;
import org.bukkit.Bukkit;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.logging.Level;
import java.util.zip.GZIPInputStream;
public class FileSource extends PacketSource {
public static void startReplay() {
if(Config.replayserver())
return;
try {
Files.copy(
de.steamwar.sql.Fight.getReplay(Config.ReplayID),
FileRecorder.getFile().toPath(),
StandardCopyOption.REPLACE_EXISTING);
new FileSource(FileRecorder.getFile());
} catch (IOException e) {
throw new SecurityException("Could not start replay", e);
}
}
public FileSource(File fightFile) throws IOException {
super(new DataInputStream(new GZIPInputStream(new FileInputStream(fightFile))));
}

Datei anzeigen

@ -42,6 +42,7 @@ public enum FightState {
public static final Set<FightState> Ingame = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING, RUNNING));
public static final Set<FightState> TeamFix = Collections.unmodifiableSet(EnumSet.of(PRE_RUNNING, RUNNING, SPECTATE));
public static final Set<FightState> Schem = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP)));
public static final Set<FightState> Recording = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_LEADER_SETUP, PRE_SCHEM_SETUP, SPECTATE)));
public static final Set<FightState> AntiRunning = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RUNNING)));
public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE)));

Datei anzeigen

@ -19,23 +19,27 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.record.FileRecorder;
import de.steamwar.fightsystem.winconditions.Wincondition;
import de.steamwar.sql.Elo;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import java.nio.file.Files;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.logging.Level;
import static de.steamwar.sql.Fight.create;
import static de.steamwar.sql.Fight.setReplay;
public class FightStatistics {
private FightStatistics(){}
@ -92,6 +96,12 @@ public class FightStatistics {
savePlayerStats(fp, fightId);
for (FightPlayer fp : Fight.getRedTeam().getPlayers())
savePlayerStats(fp, fightId);
setReplay(fightId, Files.readAllBytes(FileRecorder.getFile().toPath()));
if(ArenaMode.Event.contains(Config.mode)){
FightSystem.getEventFight().setFight(fightId);
}
}catch(Exception e){
Bukkit.getLogger().log(Level.SEVERE, "Failed to save statistics", e);
}