SteamWar/FightSystem
Archiviert
13
1

Add TPS watcher, fix tie
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-10-01 14:51:00 +02:00
Ursprung e8e6b5fcfd
Commit 65e1315cca
3 geänderte Dateien mit 16 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -33,12 +33,12 @@ public class WinCommand implements CommandExecutor {
return false; return false;
} }
if(args[0].equalsIgnoreCase(Fight.getBlueTeam().getName())){ if(args[0].equalsIgnoreCase("tie")){
FightSystem.setSpectateState(null, "Referee", "§7Kampfleiterentscheidung");
}else if(args[0].equalsIgnoreCase(Fight.getBlueTeam().getName())){
FightSystem.setSpectateState(Fight.getBlueTeam(), "Referee", "§7Kampfleiterentscheidung"); FightSystem.setSpectateState(Fight.getBlueTeam(), "Referee", "§7Kampfleiterentscheidung");
}else if(args[0].equalsIgnoreCase(Fight.getRedTeam().getName())){ }else if(args[0].equalsIgnoreCase(Fight.getRedTeam().getName())){
FightSystem.setSpectateState(Fight.getRedTeam(), "Referee", "§7Kampfleiterentscheidung"); FightSystem.setSpectateState(Fight.getRedTeam(), "Referee", "§7Kampfleiterentscheidung");
}else if(args[0].equalsIgnoreCase("tie")){
FightSystem.setSpectateState(null, "Referee", "§7Kampfleiterentscheidung");
} }
return false; return false;
} }

Datei anzeigen

@ -406,7 +406,7 @@ public class FightTeam {
} }
public double getCurrentHearts() { public double getCurrentHearts() {
return players.values().stream().filter(FightPlayer::isLiving).map(fp -> fp.getPlayer().getHealth()).reduce(Double::sum).orElse(0.0); return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getPlayer().getHealth()).sum();
} }
public double getHeartRatio(){ public double getHeartRatio(){

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import de.steamwar.core.TPSWatcher;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
@ -29,6 +30,8 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.winconditions.Wincondition; import de.steamwar.fightsystem.winconditions.Wincondition;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -51,6 +54,7 @@ public class FightUI {
public FightUI() { public FightUI() {
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20); new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20);
new StateDependentTask(ArenaMode.All, FightState.All, this::sendToPlayers, 5, 5); new StateDependentTask(ArenaMode.All, FightState.All, this::sendToPlayers, 5, 5);
new StateDependentTask(ArenaMode.All, FightState.All, this::tpsWatcher, 20, 20);
instance = this; instance = this;
} }
@ -132,6 +136,14 @@ public class FightUI {
BountifulWrapper.impl.broadcastBossbar(); BountifulWrapper.impl.broadcastBossbar();
} }
private void tpsWatcher() {
double tps = TPSWatcher.getTPS();
if(tps < 15.0) {
BaseComponent[] message = TextComponent.fromLegacyText("§c" + tps + " §7TPS");
Bukkit.getOnlinePlayers().forEach(player -> BountifulWrapper.impl.toActionbar(player, message));
}
}
public enum BossBarType { public enum BossBarType {
BLUE_LEFT(345, 165), BLUE_LEFT(345, 165),
RED_LEFT(165, 345); RED_LEFT(165, 345);