SteamWar/BungeeCore
Archiviert
13
2

Fix performance and bugs

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-09-16 12:43:22 +02:00
Ursprung 71e89fb44a
Commit 39ccff44a5
3 geänderte Dateien mit 14 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -26,6 +26,10 @@ public class ReplayCommand extends BasicCommand {
//TODO Translate
ProxiedPlayer player = (ProxiedPlayer) sender;
new SWStreamInv<>(player, "Letzte Kämpfe", (click, fight) -> {
if(!fight.isReplayAvailable()) {
player.sendMessage("Replay nicht möglich");
return;
}
ArenaMode mode = fight.getGameMode();
if(mode == null){
player.sendMessage("Replay kann aufgrund deaktivertem Spielmodus nicht gestartet werden");
@ -38,7 +42,7 @@ public class ReplayCommand extends BasicCommand {
private SWItem getFightItem(ProxiedPlayer player, Fight fight) {
String title = "§3" + (fight.getWin() == 1 ? "§l" : "") + fight.getBlueLeader().getUserName() + " §r§8vs §c" + (fight.getWin() == 2 ? "§l" : "") + fight.getRedLeader().getUserName();
SWItem item = new SWItem("JUKEBOX", title);
SWItem item = new SWItem(fight.isReplayAvailable() ? "JUKEBOX" : "STONE", title);
item.setLore(Arrays.asList(
"§7" + fight.getStartTime().toString(),
"§7" + fight.getServer(),

Datei anzeigen

@ -29,13 +29,13 @@ public class SWStreamInv<T> extends SWInventory {
else
addItem(45, new SWItem("§7Seite zurück", 8), (InvCallback.ClickType click) -> {});
if(entries.size() < 45)
if(entries.size() == 45)
addItem(53, new SWItem("§eSeite vor", 10), (InvCallback.ClickType click) -> {
page++;
open();
});
else
addItem(53, new SWItem("§eSeite vor", 8), (InvCallback.ClickType click) -> {});
addItem(53, new SWItem("§7Seite vor", 8), (InvCallback.ClickType click) -> {});
for(int i = 0; i < entries.size(); i++) {
SWListInv.SWListEntry<T> item = entries.get(i);

Datei anzeigen

@ -11,7 +11,7 @@ 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 FROM Fight WHERE Replay is not NULL ORDER BY FightID DESC LIMIT ?, ?");
private static final Statement getPage = new Statement("SELECT FightID, GameMode, Server, StartTime, Duration, BlueLeader, RedLeader, BlueSchem, RedSchem, Win, WinCondition, Replay is not NULL AS ReplayAvailable FROM Fight ORDER BY FightID DESC LIMIT ?, ?");
private final int fightID;
private final String gameMode;
@ -25,6 +25,7 @@ public class Fight {
private final int redSchem;
private final int win;
private final String winCondition;
private final boolean replayAvailable;
private final List<FightPlayer> bluePlayers = new ArrayList<>();
private final List<FightPlayer> redPlayers = new ArrayList<>();
@ -41,6 +42,7 @@ public class Fight {
redSchem = rs.getInt("RedSchem");
win = rs.getInt("Win");
winCondition = rs.getString("WinCondition");
replayAvailable = rs.getBoolean("ReplayAvailable");
}
private void initPlayers(List<FightPlayer> fightPlayers) {
@ -123,4 +125,8 @@ public class Fight {
public List<FightPlayer> getRedPlayers() {
return redPlayers;
}
public boolean isReplayAvailable() {
return replayAvailable;
}
}