geforkt von SteamWar/BungeeCore
New replay available calc + admin replay
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
0964ca78ab
Commit
9bf2e6e354
@ -29,13 +29,17 @@ public class ReplayCommand extends BasicCommand {
|
||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||
|
||||
new SWStreamInv<>(player, Message.parse("REPLAY_TITLE", player), (click, fight) -> {
|
||||
if(!fight.isReplayAvailable()) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
boolean adminReplay = false;
|
||||
if (user.getUserGroup().isAdminGroup() && click.isShiftClick() && fight.replayExists()) {
|
||||
adminReplay = true;
|
||||
} else if(!fight.replayAllowed()) {
|
||||
Message.send("REPLAY_UNAVAILABLE", player);
|
||||
return;
|
||||
}
|
||||
ArenaMode mode = fight.getGameMode();
|
||||
|
||||
SubserverSystem.sendPlayer(SubserverSystem.startArena(mode, mode.getRandomMap(), 0, 0, 0, fight.getFightID(), null, null, null, null), player);
|
||||
SubserverSystem.sendPlayer(SubserverSystem.startArena(mode, mode.getRandomMap(), adminReplay ? -1 : 0, 0, 0, fight.getFightID(), null, null, null, null), player);
|
||||
}, page -> Fight.getPage(page, 45).stream().map(fight -> new SWListInv.SWListEntry<>(getFightItem(player, fight), fight)).collect(Collectors.toList())).open();
|
||||
}
|
||||
|
||||
@ -48,11 +52,11 @@ public class ReplayCommand extends BasicCommand {
|
||||
lore.add(Message.parse("REPLAY_TIME", player, fight.getStartTime()));
|
||||
lore.add("");
|
||||
lore.add(Message.parse("REPLAY_SERVER", player, fight.getServer()));
|
||||
if(!fight.isReplayAvailable())
|
||||
if(!fight.replayAllowed())
|
||||
lore.add(Message.parse("REPLAY_UNAVAILABLE", player));
|
||||
item.setLore(lore);
|
||||
|
||||
if(fight.isReplayAvailable())
|
||||
if(fight.replayAllowed())
|
||||
item.setEnchanted(true);
|
||||
|
||||
return item;
|
||||
|
@ -5,30 +5,25 @@ import de.steamwar.bungeecore.ArenaMode;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Fight {
|
||||
|
||||
private static final Statement getPage = new Statement("SELECT FightID, GameMode, Server, StartTime, Duration, BlueLeader, RedLeader, BlueSchem, RedSchem, Win, WinCondition, ReplayLock, Replay is not NULL AS ReplayAvailable FROM Fight ORDER BY FightID DESC LIMIT ?, ?");
|
||||
private static final Statement getPage = new Statement("SELECT f.FightID, f.GameMode, f.Server, f.StartTime, f.BlueLeader, f.RedLeader, (b.NodeId IS NULL OR b.AllowReplay) AND (r.NodeId IS NULL OR r.AllowReplay) AS ReplayAllowed, f.Win, f.Replay IS NOT NULL AS ReplayExists FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId ORDER BY FightID DESC LIMIT ?, ?");
|
||||
|
||||
private final int fightID;
|
||||
private final String gameMode;
|
||||
private final String server;
|
||||
private final Timestamp startTime;
|
||||
private final int duration;
|
||||
|
||||
private final int blueLeader;
|
||||
private final int redLeader;
|
||||
private final int blueSchem;
|
||||
private final int redSchem;
|
||||
private final int win;
|
||||
private final String winCondition;
|
||||
|
||||
private final Timestamp replayLock;
|
||||
private final boolean replayAvailable;
|
||||
private final boolean replayExists;
|
||||
private final boolean replayAllowed;
|
||||
|
||||
private final List<FightPlayer> bluePlayers = new ArrayList<>();
|
||||
private final List<FightPlayer> redPlayers = new ArrayList<>();
|
||||
@ -38,15 +33,11 @@ public class Fight {
|
||||
gameMode = rs.getString("GameMode");
|
||||
server = rs.getString("Server");
|
||||
startTime = rs.getTimestamp("StartTime");
|
||||
duration = rs.getInt("Duration");
|
||||
blueLeader = rs.getInt("BlueLeader");
|
||||
redLeader = rs.getInt("RedLeader");
|
||||
blueSchem = rs.getInt("BlueSchem");
|
||||
redSchem = rs.getInt("RedSchem");
|
||||
replayAllowed = rs.getBoolean("ReplayAllowed");
|
||||
win = rs.getInt("Win");
|
||||
winCondition = rs.getString("WinCondition");
|
||||
replayLock = rs.getTimestamp("ReplayLock");
|
||||
replayAvailable = rs.getBoolean("ReplayAvailable");
|
||||
replayExists = rs.getBoolean("ReplayExists");
|
||||
}
|
||||
|
||||
private void initPlayers(List<FightPlayer> fightPlayers) {
|
||||
@ -122,7 +113,11 @@ public class Fight {
|
||||
return redPlayers;
|
||||
}
|
||||
|
||||
public boolean isReplayAvailable() {
|
||||
return replayAvailable && replayLock.before(Timestamp.from(Instant.now())) && getGameMode() != null;
|
||||
public boolean replayAllowed() {
|
||||
return replayExists() && replayAllowed;
|
||||
}
|
||||
|
||||
public boolean replayExists() {
|
||||
return replayExists && getGameMode() != null;
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren