SteamWar/FightSystem
Archiviert
13
1

Unranking option #340

Zusammengeführt
Lixfel hat 1 Commits von unrank nach master 2022-03-20 16:11:33 +01:00 zusammengeführt
5 geänderte Dateien mit 63 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -140,6 +140,7 @@ public class FightSystem extends JavaPlugin {
new LockschemCommand(); new LockschemCommand();
new StateCommand(); new StateCommand();
new SkipCommand(); new SkipCommand();
new UnrankCommand();
new WinCommand(); new WinCommand();
new LiveRecorder(); new LiveRecorder();

Datei anzeigen

@ -173,6 +173,7 @@ TPS_WARNING=
UI_PRE_RUNNING=§7Kits verteilt UI_PRE_RUNNING=§7Kits verteilt
UI_RUNNING=§aArena freigegeben UI_RUNNING=§aArena freigegeben
UI_SKIP=§7Sprung zum nächsten Ereignis UI_SKIP=§7Sprung zum nächsten Ereignis
UI_UNRANKED=§7Ungewerteter Kampf
UI_PLAYER_JOINS=§a§l» {0}{1} UI_PLAYER_JOINS=§a§l» {0}{1}
UI_PLAYER_LEAVES=§c§l« {0}{1} UI_PLAYER_LEAVES=§c§l« {0}{1}
UI_LEADER_JOINS=§a§l» {0}Leader {1} UI_LEADER_JOINS=§a§l» {0}Leader {1}

Datei anzeigen

@ -0,0 +1,49 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2022 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.fightsystem.utils.FightStatistics;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class UnrankCommand implements CommandExecutor {
public UnrankCommand () {
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "unrank", this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
return false;
Player player = (Player) sender;
if(Commands.checkGetLeader(player) == null)
return false;
FightStatistics.unrank();
return false;
}
}

Datei anzeigen

@ -47,6 +47,13 @@ import static de.steamwar.sql.Fight.setReplay;
public class FightStatistics { public class FightStatistics {
private static boolean unranked = false;
public static void unrank() {
unranked = true;
FightUI.addSubtitle("UI_UNRANKED");
}
private Timestamp starttime = Timestamp.from(Instant.now()); private Timestamp starttime = Timestamp.from(Instant.now());
public FightStatistics() { public FightStatistics() {
@ -124,10 +131,12 @@ public class FightStatistics {
Bukkit.getLogger().log(Level.SEVERE, "Failed to save statistics", e); Bukkit.getLogger().log(Level.SEVERE, "Failed to save statistics", e);
} }
if (!Bukkit.getOnlinePlayers().isEmpty()) { if (!Bukkit.getOnlinePlayers().isEmpty() && !unranked) {
Player p = Bukkit.getOnlinePlayers().iterator().next(); Player p = Bukkit.getOnlinePlayers().iterator().next();
new FightEndsPacket((byte) win, blueSchem == null ? 0 : blueSchem, redSchem == null ? 0 : redSchem, Fight.getBlueTeam().getPlayers().stream().map(FightPlayer::getPlayer).map(SteamwarUser::get).map(SteamwarUser::getId).collect(Collectors.toList()), Fight.getRedTeam().getPlayers().stream().map(FightPlayer::getPlayer).map(SteamwarUser::get).map(SteamwarUser::getId).collect(Collectors.toList()), gameMode).send(p); new FightEndsPacket((byte) win, blueSchem == null ? 0 : blueSchem, redSchem == null ? 0 : redSchem, Fight.getBlueTeam().getPlayers().stream().map(FightPlayer::getPlayer).map(SteamwarUser::get).map(SteamwarUser::getId).collect(Collectors.toList()), Fight.getRedTeam().getPlayers().stream().map(FightPlayer::getPlayer).map(SteamwarUser::get).map(SteamwarUser::getId).collect(Collectors.toList()), gameMode).send(p);
} }
unranked = false;
} }
private int getLeader(FightTeam team) { private int getLeader(FightTeam team) {

Datei anzeigen

@ -22,4 +22,5 @@ commands:
skip: skip:
win: win:
resetwg: resetwg:
resettb: resettb:
unrank: