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;
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||||
|
|
||||||
new SWStreamInv<>(player, Message.parse("REPLAY_TITLE", player), (click, fight) -> {
|
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);
|
Message.send("REPLAY_UNAVAILABLE", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ArenaMode mode = fight.getGameMode();
|
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();
|
}, 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(Message.parse("REPLAY_TIME", player, fight.getStartTime()));
|
||||||
lore.add("");
|
lore.add("");
|
||||||
lore.add(Message.parse("REPLAY_SERVER", player, fight.getServer()));
|
lore.add(Message.parse("REPLAY_SERVER", player, fight.getServer()));
|
||||||
if(!fight.isReplayAvailable())
|
if(!fight.replayAllowed())
|
||||||
lore.add(Message.parse("REPLAY_UNAVAILABLE", player));
|
lore.add(Message.parse("REPLAY_UNAVAILABLE", player));
|
||||||
item.setLore(lore);
|
item.setLore(lore);
|
||||||
|
|
||||||
if(fight.isReplayAvailable())
|
if(fight.replayAllowed())
|
||||||
item.setEnchanted(true);
|
item.setEnchanted(true);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
@ -5,30 +5,25 @@ import de.steamwar.bungeecore.ArenaMode;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Fight {
|
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 int fightID;
|
||||||
private final String gameMode;
|
private final String gameMode;
|
||||||
private final String server;
|
private final String server;
|
||||||
private final Timestamp startTime;
|
private final Timestamp startTime;
|
||||||
private final int duration;
|
|
||||||
|
|
||||||
private final int blueLeader;
|
private final int blueLeader;
|
||||||
private final int redLeader;
|
private final int redLeader;
|
||||||
private final int blueSchem;
|
|
||||||
private final int redSchem;
|
|
||||||
private final int win;
|
private final int win;
|
||||||
private final String winCondition;
|
|
||||||
|
|
||||||
private final Timestamp replayLock;
|
private final boolean replayExists;
|
||||||
private final boolean replayAvailable;
|
private final boolean replayAllowed;
|
||||||
|
|
||||||
private final List<FightPlayer> bluePlayers = new ArrayList<>();
|
private final List<FightPlayer> bluePlayers = new ArrayList<>();
|
||||||
private final List<FightPlayer> redPlayers = new ArrayList<>();
|
private final List<FightPlayer> redPlayers = new ArrayList<>();
|
||||||
@ -38,15 +33,11 @@ public class Fight {
|
|||||||
gameMode = rs.getString("GameMode");
|
gameMode = rs.getString("GameMode");
|
||||||
server = rs.getString("Server");
|
server = rs.getString("Server");
|
||||||
startTime = rs.getTimestamp("StartTime");
|
startTime = rs.getTimestamp("StartTime");
|
||||||
duration = rs.getInt("Duration");
|
|
||||||
blueLeader = rs.getInt("BlueLeader");
|
blueLeader = rs.getInt("BlueLeader");
|
||||||
redLeader = rs.getInt("RedLeader");
|
redLeader = rs.getInt("RedLeader");
|
||||||
blueSchem = rs.getInt("BlueSchem");
|
replayAllowed = rs.getBoolean("ReplayAllowed");
|
||||||
redSchem = rs.getInt("RedSchem");
|
|
||||||
win = rs.getInt("Win");
|
win = rs.getInt("Win");
|
||||||
winCondition = rs.getString("WinCondition");
|
replayExists = rs.getBoolean("ReplayExists");
|
||||||
replayLock = rs.getTimestamp("ReplayLock");
|
|
||||||
replayAvailable = rs.getBoolean("ReplayAvailable");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initPlayers(List<FightPlayer> fightPlayers) {
|
private void initPlayers(List<FightPlayer> fightPlayers) {
|
||||||
@ -122,7 +113,11 @@ public class Fight {
|
|||||||
return redPlayers;
|
return redPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReplayAvailable() {
|
public boolean replayAllowed() {
|
||||||
return replayAvailable && replayLock.before(Timestamp.from(Instant.now())) && getGameMode() != null;
|
return replayExists() && replayAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean replayExists() {
|
||||||
|
return replayExists && getGameMode() != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren