SteamWar/FightSystem
Archiviert
13
1

Merge pull request 'Lock replay functionality' (#318) from lockreplay into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #318
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Lixfel 2021-12-27 13:33:49 +01:00
Commit e6a9d13ea1
7 geänderte Dateien mit 26 neuen und 37 gelöschten Zeilen

Datei anzeigen

@ -41,8 +41,9 @@ Arena:
BorderFromSchematic: 12 # defaults to 12 if missing
# If ground walkable, teams can walk below the lower arena border during setup
GroundWalkable: true # defaults to true if missing
# Disable snow melt
DisableSnowMelt: false
# Disable snow and ice melting
DisableSnowMelt: false # defaults to false if missing
Schematic:
# The size of the schematics
Size:
@ -53,6 +54,8 @@ Schematic:
Type: Normal # defaults to Normal if missing
# Shortcut of the schematic type
Shortcut: "" # defaults to "" if missing
# Spigot (1.8) material for GUIs
Material: STONE_BUTTON # defaults to STONE_BUTTON if missing
# If the schematics should be rotated during pasting
Rotate: true # defaults to true if missing
# If the schematics should be pasted aligned to the borders instead of centered

Datei anzeigen

@ -128,7 +128,7 @@ public class FightSystem extends JavaPlugin {
new AkCommand();
new LeaderCommand();
new LockschemCommand();
new ReplayCommand();
new LockReplayCommand();
new StateCommand();
new SkipCommand();
new WinCommand();

Datei anzeigen

@ -53,7 +53,7 @@ LOCKSCHEM_LOCKED_BY=
REMOVE_HELP=§8/§eremove §8[§eSpieler§8]
REPLAY_UNAVAILABLE=§cReplay derzeit nicht verfügbar
REPLAY_LOCKED=§7Replaywiedergabe für 1 Monat gesperrt
NOT_FIGHTLEADER=§cDu bist nicht Kampfleiter
WIN_HELP=§8/§7win §8[§eTeam §8or §etie§8]

Datei anzeigen

@ -63,7 +63,7 @@ public class Commands {
return fightPlayer;
}
private static FightPlayer checkGetLeader(Player p){
public static FightPlayer checkGetLeader(Player p){
FightPlayer fightPlayer = checkGetPlayer(p);
if(fightPlayer != null && !fightPlayer.isLeader()){
FightSystem.getMessage().sendPrefixless("NOT_LEADER", p, ChatMessageType.ACTION_BAR);
@ -72,7 +72,7 @@ public class Commands {
return fightPlayer;
}
private static FightTeam checkGetTeam(Player p){
public static FightTeam checkGetTeam(Player p){
FightTeam fightTeam = Fight.getPlayerTeam(p);
if(fightTeam == null){
errNoTeam(p);

Datei anzeigen

@ -20,26 +20,19 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.record.FileRecorder;
import de.steamwar.fightsystem.record.FileSource;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatMessageType;
import de.steamwar.fightsystem.utils.FightStatistics;
import de.steamwar.fightsystem.utils.FightUI;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.io.IOException;
import java.util.logging.Level;
public class LockReplayCommand implements CommandExecutor {
public class ReplayCommand implements CommandExecutor {
public ReplayCommand() {
new StateDependentCommand(ArenaMode.Replayable, FightState.All, "replay", this);
public LockReplayCommand() {
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Schem, "lockreplay", this);
}
@Override
@ -49,25 +42,11 @@ public class ReplayCommand implements CommandExecutor {
}
Player player = (Player) sender;
if(!Config.test()){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(!user.getUserGroup().isTeamGroup()){
FightSystem.getMessage().sendPrefixless("REPLAY_UNAVAILABLE", sender, ChatMessageType.ACTION_BAR);
return false;
}
}
if(!FileRecorder.getFile().exists()){
FightSystem.getMessage().sendPrefixless("REPLAY_UNAVAILABLE", sender, ChatMessageType.ACTION_BAR);
if(Commands.checkGetLeader(player) == null)
return false;
}
try {
new FileSource(FileRecorder.getFile());
} catch (IOException e) {
FightSystem.getMessage().sendPrefixless("REPLAY_UNAVAILABLE", sender, ChatMessageType.ACTION_BAR);
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Replay could not be started", e);
}
FightStatistics.lockReplay();
FightUI.addSubtitle("REPLAY_LOCKED");
return false;
}
}

Datei anzeigen

@ -38,6 +38,7 @@ import org.bukkit.Bukkit;
import java.io.FileInputStream;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.logging.Level;
import static de.steamwar.sql.Fight.create;
@ -46,9 +47,14 @@ import static de.steamwar.sql.Fight.setReplay;
public class FightStatistics {
private static final int K = 20;
private static boolean replayLock = false;
private Timestamp starttime = Timestamp.from(Instant.now());
public static void lockReplay() {
replayLock = true;
}
public FightStatistics() {
new OneShotStateDependent(ArenaMode.SeriousFight, FightState.Running, this::enable);
new OneShotStateDependent(ArenaMode.Event, FightState.Spectate, this::setEventResult);
@ -109,7 +115,7 @@ public class FightStatistics {
try {
int fightId = create(gameMode, Bukkit.getWorlds().get(0).getName(), starttime, remainingTime,
blueLeader, redLeader, blueSchem, redSchem, win, windescription);
blueLeader, redLeader, blueSchem, redSchem, win, windescription, Timestamp.from(Instant.now().plus(replayLock ? 1 : 0, ChronoUnit.MONTHS)));
for (FightPlayer fp : Fight.getBlueTeam().getPlayers())
savePlayerStats(fp, fightId);
@ -124,6 +130,7 @@ public class FightStatistics {
}catch(Exception e){
Bukkit.getLogger().log(Level.SEVERE, "Failed to save statistics", e);
}
replayLock = false;
if(Config.Ranked){
int blueElo = Elo.getElo(blueLeader, gameMode);

Datei anzeigen

@ -18,7 +18,7 @@ commands:
remove:
leader:
lockschem:
replay:
lockreplay:
state:
skip:
win: