Lock replay functionality #318
@ -41,8 +41,9 @@ Arena:
|
|||||||
BorderFromSchematic: 12 # defaults to 12 if missing
|
BorderFromSchematic: 12 # defaults to 12 if missing
|
||||||
# If ground walkable, teams can walk below the lower arena border during setup
|
# If ground walkable, teams can walk below the lower arena border during setup
|
||||||
GroundWalkable: true # defaults to true if missing
|
GroundWalkable: true # defaults to true if missing
|
||||||
# Disable snow melt
|
# Disable snow and ice melting
|
||||||
DisableSnowMelt: false
|
DisableSnowMelt: false # defaults to false if missing
|
||||||
|
|
||||||
Schematic:
|
Schematic:
|
||||||
# The size of the schematics
|
# The size of the schematics
|
||||||
Size:
|
Size:
|
||||||
@ -53,6 +54,8 @@ Schematic:
|
|||||||
Type: Normal # defaults to Normal if missing
|
Type: Normal # defaults to Normal if missing
|
||||||
# Shortcut of the schematic type
|
# Shortcut of the schematic type
|
||||||
Shortcut: "" # defaults to "" if missing
|
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
|
# If the schematics should be rotated during pasting
|
||||||
Rotate: true # defaults to true if missing
|
Rotate: true # defaults to true if missing
|
||||||
# If the schematics should be pasted aligned to the borders instead of centered
|
# If the schematics should be pasted aligned to the borders instead of centered
|
||||||
|
@ -128,7 +128,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new AkCommand();
|
new AkCommand();
|
||||||
new LeaderCommand();
|
new LeaderCommand();
|
||||||
new LockschemCommand();
|
new LockschemCommand();
|
||||||
new ReplayCommand();
|
new LockReplayCommand();
|
||||||
new StateCommand();
|
new StateCommand();
|
||||||
new SkipCommand();
|
new SkipCommand();
|
||||||
new WinCommand();
|
new WinCommand();
|
||||||
|
@ -53,7 +53,7 @@ LOCKSCHEM_LOCKED_BY=
|
|||||||
|
|
||||||
REMOVE_HELP=§8/§eremove §8[§eSpieler§8]
|
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
|
NOT_FIGHTLEADER=§cDu bist nicht Kampfleiter
|
||||||
WIN_HELP=§8/§7win §8[§eTeam §8or §etie§8]
|
WIN_HELP=§8/§7win §8[§eTeam §8or §etie§8]
|
||||||
|
@ -63,7 +63,7 @@ public class Commands {
|
|||||||
return fightPlayer;
|
return fightPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FightPlayer checkGetLeader(Player p){
|
public static FightPlayer checkGetLeader(Player p){
|
||||||
FightPlayer fightPlayer = checkGetPlayer(p);
|
FightPlayer fightPlayer = checkGetPlayer(p);
|
||||||
if(fightPlayer != null && !fightPlayer.isLeader()){
|
if(fightPlayer != null && !fightPlayer.isLeader()){
|
||||||
FightSystem.getMessage().sendPrefixless("NOT_LEADER", p, ChatMessageType.ACTION_BAR);
|
FightSystem.getMessage().sendPrefixless("NOT_LEADER", p, ChatMessageType.ACTION_BAR);
|
||||||
@ -72,7 +72,7 @@ public class Commands {
|
|||||||
return fightPlayer;
|
return fightPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FightTeam checkGetTeam(Player p){
|
public static FightTeam checkGetTeam(Player p){
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
||||||
if(fightTeam == null){
|
if(fightTeam == null){
|
||||||
errNoTeam(p);
|
errNoTeam(p);
|
||||||
|
@ -20,26 +20,19 @@
|
|||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
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.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
import de.steamwar.fightsystem.states.StateDependentCommand;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.fightsystem.utils.FightStatistics;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import de.steamwar.fightsystem.utils.FightUI;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.IOException;
|
public class LockReplayCommand implements CommandExecutor {
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class ReplayCommand implements CommandExecutor {
|
public LockReplayCommand() {
|
||||||
|
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Schem, "lockreplay", this);
|
||||||
public ReplayCommand() {
|
|
||||||
new StateDependentCommand(ArenaMode.Replayable, FightState.All, "replay", this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -49,25 +42,11 @@ public class ReplayCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if(!Config.test()){
|
if(Commands.checkGetLeader(player) == null)
|
||||||
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);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
FightStatistics.lockReplay();
|
||||||
new FileSource(FileRecorder.getFile());
|
FightUI.addSubtitle("REPLAY_LOCKED");
|
||||||
} catch (IOException e) {
|
|
||||||
FightSystem.getMessage().sendPrefixless("REPLAY_UNAVAILABLE", sender, ChatMessageType.ACTION_BAR);
|
|
||||||
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Replay could not be started", e);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,6 +38,7 @@ import org.bukkit.Bukkit;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import static de.steamwar.sql.Fight.create;
|
import static de.steamwar.sql.Fight.create;
|
||||||
@ -46,9 +47,14 @@ import static de.steamwar.sql.Fight.setReplay;
|
|||||||
public class FightStatistics {
|
public class FightStatistics {
|
||||||
|
|
||||||
private static final int K = 20;
|
private static final int K = 20;
|
||||||
|
private static boolean replayLock = false;
|
||||||
|
|
||||||
private Timestamp starttime = Timestamp.from(Instant.now());
|
private Timestamp starttime = Timestamp.from(Instant.now());
|
||||||
|
|
||||||
|
public static void lockReplay() {
|
||||||
|
replayLock = true;
|
||||||
|
}
|
||||||
|
|
||||||
public FightStatistics() {
|
public FightStatistics() {
|
||||||
new OneShotStateDependent(ArenaMode.SeriousFight, FightState.Running, this::enable);
|
new OneShotStateDependent(ArenaMode.SeriousFight, FightState.Running, this::enable);
|
||||||
new OneShotStateDependent(ArenaMode.Event, FightState.Spectate, this::setEventResult);
|
new OneShotStateDependent(ArenaMode.Event, FightState.Spectate, this::setEventResult);
|
||||||
@ -109,7 +115,7 @@ public class FightStatistics {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
int fightId = create(gameMode, Bukkit.getWorlds().get(0).getName(), starttime, remainingTime,
|
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())
|
for (FightPlayer fp : Fight.getBlueTeam().getPlayers())
|
||||||
savePlayerStats(fp, fightId);
|
savePlayerStats(fp, fightId);
|
||||||
@ -124,6 +130,7 @@ public class FightStatistics {
|
|||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to save statistics", e);
|
Bukkit.getLogger().log(Level.SEVERE, "Failed to save statistics", e);
|
||||||
}
|
}
|
||||||
|
replayLock = false;
|
||||||
|
|
||||||
if(Config.Ranked){
|
if(Config.Ranked){
|
||||||
int blueElo = Elo.getElo(blueLeader, gameMode);
|
int blueElo = Elo.getElo(blueLeader, gameMode);
|
||||||
|
@ -18,7 +18,7 @@ commands:
|
|||||||
remove:
|
remove:
|
||||||
leader:
|
leader:
|
||||||
lockschem:
|
lockschem:
|
||||||
replay:
|
lockreplay:
|
||||||
state:
|
state:
|
||||||
skip:
|
skip:
|
||||||
win:
|
win:
|
In neuem Issue referenzieren
Einen Benutzer sperren