SteamWar/FightSystem
Archiviert
13
1

WIP new fight ui

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-09-03 17:32:00 +02:00
Ursprung fe19c1656d
Commit 5264bb0256
25 geänderte Dateien mit 296 neuen und 115 gelöschten Zeilen

Datei anzeigen

@ -33,6 +33,7 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.utils.EnterHandler;
import de.steamwar.fightsystem.utils.FightStatistics;
import de.steamwar.fightsystem.utils.FightUI;
import de.steamwar.fightsystem.utils.TechHider;
import de.steamwar.fightsystem.winconditions.*;
import de.steamwar.sql.EventFight;
@ -87,6 +88,7 @@ public class FightSystem extends JavaPlugin {
new EnterHandler();
new TechHider();
new FightWorld();
new FightUI();
new WinconditionAllDead();
new WinconditionCaptainDead();
@ -129,8 +131,8 @@ public class FightSystem extends JavaPlugin {
new LiveRecorder();
new FileRecorder();
new OneShotStateDependent(ArenaMode.AntiReplay, FightState.PreRunning, () -> FightSystem.broadcast("§aDer Kampf beginnt!"));
new OneShotStateDependent(ArenaMode.AntiReplay, FightState.Running, () -> FightSystem.broadcast("§aArena freigegeben!"));
new OneShotStateDependent(ArenaMode.AntiReplay, FightState.PreRunning, () -> FightUI.addSubtitle("§7Kits verteilt"));
new OneShotStateDependent(ArenaMode.AntiReplay, FightState.Running, () -> FightUI.addSubtitle("§aArena freigegeben"));
new OneShotStateDependent(ArenaMode.AntiTest, FightState.Running, FightStatistics::start);
try {
@ -180,12 +182,12 @@ public class FightSystem extends JavaPlugin {
FightState.setFightState(FightState.RUNNING);
}
public static void setSpectateState(FightTeam winFightTeam, String windescription) {
public static void setSpectateState(FightTeam winFightTeam, String windescription, String subtitle) {
if(!PacketProcessor.isReplaying()){
if(winFightTeam != null) {
FightSystem.broadcast("§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!");
FightUI.printWin(winFightTeam.getPrefix() + "Sieg " + winFightTeam.getName(), subtitle);
} else {
FightSystem.broadcast("§aKein Team hat gewonnen!");
FightUI.printWin("§7Unentschieden", subtitle);
}
}

Datei anzeigen

@ -74,9 +74,9 @@ public class GUI {
inv.setItem(2, Material.GLASS, "§7POST_SCHEM_SETUP", (ClickType click) -> FightSystem.setPostSchemState());
inv.setItem(3, Material.GLASS, "§ePRE_RUNNING", (ClickType click) -> FightSystem.setPreRunningState());
inv.setItem(4, Material.GLASS, "§eRUNNING", (ClickType click) -> FightSystem.setRunningState());
inv.setItem(5, Material.GLASS, "§7SPECTATE Blue", (ClickType click) -> FightSystem.setSpectateState(Fight.getBlueTeam(), "operator"));
inv.setItem(6, Material.GLASS, "§7SPECTATE Red", (ClickType click) -> FightSystem.setSpectateState(Fight.getRedTeam(), "operator"));
inv.setItem(7, Material.GLASS, "§7SPECTATE Tie", (ClickType click) -> FightSystem.setSpectateState(null, "operator"));
inv.setItem(5, Material.GLASS, "§7SPECTATE Blue", (ClickType click) -> FightSystem.setSpectateState(Fight.getBlueTeam(), "operator", null));
inv.setItem(6, Material.GLASS, "§7SPECTATE Red", (ClickType click) -> FightSystem.setSpectateState(Fight.getRedTeam(), "operator", null));
inv.setItem(7, Material.GLASS, "§7SPECTATE Tie", (ClickType click) -> FightSystem.setSpectateState(null, "operator", null));
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open();
}

Datei anzeigen

@ -34,14 +34,11 @@ public class WinCommand implements CommandExecutor {
}
if(args[0].equalsIgnoreCase(Fight.getBlueTeam().getName())){
FightSystem.broadcast("§cDer Kampfleiter hat den Kampf entschieden!");
FightSystem.setSpectateState(Fight.getBlueTeam(), "Referee");
FightSystem.setSpectateState(Fight.getBlueTeam(), "Referee", "§7Kampfleiterentscheidung");
}else if(args[0].equalsIgnoreCase(Fight.getRedTeam().getName())){
FightSystem.broadcast("§cDer Kampfleiter hat den Kampf entschieden!");
FightSystem.setSpectateState(Fight.getRedTeam(), "Referee");
FightSystem.setSpectateState(Fight.getRedTeam(), "Referee", "§7Kampfleiterentscheidung");
}else if(args[0].equalsIgnoreCase("tie")){
FightSystem.broadcast("§cDer Kampfleiter hat den Kampf entschieden!");
FightSystem.setSpectateState(null, "Referee");
FightSystem.setSpectateState(null, "Referee", "§7Kampfleiterentscheidung");
}
return false;
}

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.listener.BasicListener;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.utils.FightUI;
import de.steamwar.fightsystem.utils.SWSound;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
@ -86,7 +87,7 @@ public abstract class Countdown {
countdown.show();
}
FightSystem.broadcast("§aBeide Teams waren damit einverstanden, zum nächsten Event zu beschleunigen!");
FightUI.addSubtitle("§7Sprung zum nächsten Ereignis");
}
private void broadcast(String message){

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.utils.SWSound;
public class TimeOverCountdown extends Countdown {
@ -39,7 +38,6 @@ public class TimeOverCountdown extends Countdown {
@Override
public void countdownFinished() {
FightSystem.broadcast("§aZeit abgelaufen!");
timeOver.run();
}
}

Datei anzeigen

@ -245,7 +245,7 @@ public class FightTeam {
this.leader = null;
if(!players.isEmpty()) {
setLeader(players.values().iterator().next());
FightSystem.broadcast("§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!");
FightUI.addSubtitle(getPrefix() + "Neuer Leader: " + this.leader.getPlayer().getName());
}else if(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightSystem::setPreLeaderState, 1);
}
@ -377,19 +377,21 @@ public class FightTeam {
return spawn;
}
public double getCurrentHearts() {
return players.values().stream().filter(FightPlayer::isLiving).map(fp -> fp.getPlayer().getHealth()).reduce(Double::sum).orElse(0.0);
}
public double getHeartRatio(){
int maximumHearts = 0;
double currentHearts = 0;
for(FightPlayer fightPlayer : players.values()){
maximumHearts += 20;
if(!fightPlayer.isLiving())
continue;
int maximumHearts = players.size() * 20;
return maximumHearts != 0 ? getCurrentHearts() / maximumHearts : 0;
}
currentHearts += fightPlayer.getPlayer().getHealth();
}
public int getPlayerCount() {
return players.size();
}
assert maximumHearts != 0;
return currentHearts / maximumHearts;
public int getAlivePlayers() {
return (int) players.values().stream().filter(FightPlayer::isLiving).count();
}
public ChatColor getColor() {

Datei anzeigen

@ -24,10 +24,11 @@ import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.FightUI;
import de.steamwar.fightsystem.utils.SWSound;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -51,9 +52,9 @@ public class IngameDeath implements Listener {
if(team == null)
return;
FightSystem.broadcast("§cDer Spieler " + team.getPrefix() + player.getName() + " §cist gestorben!");
FightUI.addSubtitle(team.getPrefix() + player.getName() + " §7ist gestorben");
Fight.playSound(SWSound.ENTITY_WITHER_DEATH.getSound(), 100.0F, 1.0F);
team.getFightPlayer(player).setOut();
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> team.getFightPlayer(player).setOut());
}
@EventHandler(priority = EventPriority.HIGH)
@ -66,10 +67,10 @@ public class IngameDeath implements Listener {
return;
FightPlayer fightPlayer = team.getFightPlayer(player);
if(fightPlayer.isLiving()) {
FightSystem.broadcast("§cDer Spieler " + team.getPrefix() + player.getName() + " §chat den Kampf verlassen!");
team.getFightPlayer(player).setOut();
GlobalRecorder.getInstance().entityDespawns(player);
}
if(!fightPlayer.isLiving())
return;
FightUI.addSubtitle(team.getPrefix() + player.getName() + " §7hat den Kampf verlassen");
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> team.getFightPlayer(player).setOut());
}
}

Datei anzeigen

@ -149,7 +149,7 @@ public class Recording implements Listener {
GlobalRecorder.getInstance().entityMoves(e.getPlayer());
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerDeath(PlayerDeathEvent e){
if(isNotSent(e.getEntity()))
return;
@ -157,6 +157,14 @@ public class Recording implements Listener {
GlobalRecorder.getInstance().entityDespawns(e.getEntity());
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerQuit(PlayerQuitEvent e){
if(isNotSent(e.getPlayer()))
return;
GlobalRecorder.getInstance().entityDespawns(e.getPlayer());
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent e){
if(FlatteningWrapper.impl.doRecord(e))

Datei anzeigen

@ -377,7 +377,7 @@ public class PacketProcessor {
REntity.dieAll();
freezer.disable();
if(Config.replayserver() || ArenaMode.AntiReplay.contains(Config.mode)) {
FightSystem.setSpectateState(null, "Replay ends");
FightSystem.setSpectateState(null, "Replay ends", null);
}else{
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cReplay beendet");
new EventSpectateCountdown().enable();

Datei anzeigen

@ -28,6 +28,12 @@ import java.util.Set;
public class StateDependentCountdown extends StateDependent {
private static Countdown mainCountdown = null;
public static Countdown getMainCountdown() {
return mainCountdown;
}
private final Countdown countdown;
public StateDependentCountdown(Set<ArenaMode> mode, Set<FightState> states, Countdown countdown) {
@ -48,11 +54,14 @@ public class StateDependentCountdown extends StateDependent {
@Override
public void enable() {
mainCountdown = countdown;
countdown.enable();
}
@Override
public void disable() {
countdown.disable();
if(mainCountdown == countdown)
mainCountdown = null;
}
}

Datei anzeigen

@ -0,0 +1,197 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2021 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.utils;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.winconditions.Wincondition;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.stream.Collectors;
public class FightUI {
private final BossBar leftBlue = Bukkit.createBossBar("Blue", BarColor.BLUE, BarStyle.SOLID);
private final BossBar leftRed = Bukkit.createBossBar("Red", BarColor.RED, BarStyle.SOLID);
private final Map<Player, BossBar> players = new HashMap<>();
public FightUI() {
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20);
}
private void update() {
final FightTeam blue = Fight.getBlueTeam();
final FightTeam red = Fight.getRedTeam();
double blueHearts = blue.getCurrentHearts();
double redHearts = red.getCurrentHearts();
double totalHearts = blueHearts + redHearts;
if(totalHearts == 0.0)
totalHearts = 1.0;
setupTeamBar(blue, leftBlue, blueHearts / totalHearts);
setupTeamBar(red, leftRed, redHearts / totalHearts);
int timeLeft = StateDependentCountdown.getMainCountdown() != null ? StateDependentCountdown.getMainCountdown().getTimeLeft() : 0;
String time = "§7" + (timeLeft/60) + "§8:§7" + (timeLeft%60);
String bluePlayers = blue.getPrefix() + blue.getAlivePlayers() + "§8/§7" + blue.getPlayerCount();
String redPlayers = red.getPrefix() + red.getAlivePlayers() + "§8/§7" + red.getPlayerCount();
String redAdditional = Wincondition.getPrintableWinconditions().stream().map(w -> w.getDisplay(red)).collect(Collectors.joining(" "));
String blueAdditional = Wincondition.getPrintableWinconditions().stream().map(w -> w.getDisplay(blue)).collect(Collectors.joining(" "));
Generator generator;
switch(FightState.getFightState()){
case PRE_LEADER_SETUP:
generator = (l, r, lP, rP, lW, rW) -> "§7Warten auf Teamleader";
break;
case PRE_SCHEM_SETUP:
generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " §7Schemauswahl " + time + " " + r.getColoredName();
break;
case POST_SCHEM_SETUP:
generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " " + lP + " §7Vorbereitung " + time + " " + rP + " " + r.getColoredName();
break;
case PRE_RUNNING:
generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " " + lP + " §7Kampfbeginn in " + time + " " + rP + " " + r.getColoredName();
break;
case RUNNING:
generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " " + lP + " " + lW + " " + time + " " + rW + " " + rP + " " + r.getColoredName();
break;
case SPECTATE:
default:
generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " §7Kampf vorbei " + time + " " + r.getColoredName();
break;
}
leftBlue.setTitle(generator.gen(blue, red, bluePlayers, redPlayers, blueAdditional, redAdditional));
leftRed.setTitle(generator.gen(red, blue, redPlayers, bluePlayers, redAdditional, blueAdditional));
BossBar negZ = Config.blueNegZ() ? leftBlue : leftRed;
BossBar posZ = Config.blueNegZ() ? leftRed : leftBlue;
for(Player player : Bukkit.getOnlinePlayers()) {
float headRot = CraftbukkitWrapper.impl.headRotation(player);
BossBar current = players.remove(player);
if(headRot >= 180){ //negZ links
if(negZ != current){
if(current != null)
current.removePlayer(player);
negZ.addPlayer(player);
current = negZ;
}
}else{ //posZ links
if(posZ != current){
if(current != null)
current.removePlayer(player);
posZ.addPlayer(player);
current = posZ;
}
}
players.put(player, current);
}
}
private interface Generator {
String gen(FightTeam l, FightTeam r, String lPlayers, String rPlayers, String lWinconditions, String rWinconditions);
}
private void setupTeamBar(FightTeam team, BossBar bar, double progress) {
BarColor color = chat2bar(team.getColor());
if(bar.getColor() != color)
bar.setColor(color);
if(bar.getProgress() != progress)
bar.setProgress(progress);
}
private BarColor chat2bar(ChatColor color) {
switch(color) {
case DARK_BLUE:
case DARK_AQUA:
case BLUE:
case AQUA:
return BarColor.BLUE;
case GREEN:
case DARK_GREEN:
return BarColor.GREEN;
case DARK_RED:
case RED:
return BarColor.RED;
case DARK_PURPLE:
return BarColor.PURPLE;
case GOLD:
case YELLOW:
return BarColor.YELLOW;
case LIGHT_PURPLE:
return BarColor.PINK;
case BLACK:
case WHITE:
case GRAY:
case DARK_GRAY:
default:
return BarColor.WHITE;
}
}
private static final Queue<String> queue = new LinkedList<>();
private static boolean subtitleScheduled = false;
public static void printWin(String title, String winreason) {
queue.clear();
Bukkit.getOnlinePlayers().forEach(p -> {
p.resetTitle();
p.sendTitle(title, winreason, 10, 80, 10);
});
}
public static void addSubtitle(String message) {
if(FightState.Spectate.contains(FightState.getFightState()))
return;
queue.add(message);
if(!subtitleScheduled)
printSubtitle();
}
private static void printSubtitle() {
if(queue.isEmpty()) {
subtitleScheduled = false;
return;
}
String message = queue.poll();
Bukkit.getOnlinePlayers().forEach(p -> p.sendTitle(null, message, 10, 80, 10));
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightUI::printSubtitle, 100);
subtitleScheduled = true;
}
}

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
@ -34,8 +33,7 @@ public class EventTeamOffWincondition extends Wincondition{
@Override
public void enable() {
if(Fight.getBlueTeam().allPlayersOut() && Fight.getRedTeam().allPlayersOut()){
FightSystem.broadcast("§cBeide Teams sind offline!");
win(null);
win(null, "§7Beide Teams offline");
}else{
teamOff(Fight.getBlueTeam());
teamOff(Fight.getRedTeam());
@ -51,8 +49,7 @@ public class EventTeamOffWincondition extends Wincondition{
private void teamOff(FightTeam team){
if(team.allPlayersOut()){
FightSystem.broadcast("§cDas Team " + team.getColoredName() + " §cist offline!");
win(Fight.getOpposite(team));
win(Fight.getOpposite(team), team.getColoredName() + " §7offline");
}
}
}

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
@ -45,8 +44,7 @@ public class RankedPlayerLeftWincondition extends Wincondition implements Listen
return;
if(team.isPlayerLeader(player)) {
FightSystem.broadcast("§cDer Leader von " + team.getColoredName() + " §chat den Kampf verlassen!");
win(Fight.getOpposite(team));
win(Fight.getOpposite(team), team.getPrefix() + team.getLeader().getPlayer().getName() + " §7hat den Kampf verlassen");
}
}
}

Datei anzeigen

@ -47,17 +47,12 @@ public abstract class Wincondition {
return timeOverCountdown.getCountdown();
}
protected void win(FightTeam team){
FightSystem.setSpectateState(team, windescription);
protected void win(FightTeam team, String subtitle){
FightSystem.setSpectateState(team, windescription, subtitle);
}
protected FightTeam isTarget(Player player){
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(fightTeam == null)
return null;
fightTeam.getFightPlayer(player).setOut();
return fightTeam;
return Fight.getPlayerTeam(player);
}
public static List<PrintableWincondition> getPrintableWinconditions(){

Datei anzeigen

@ -19,8 +19,8 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
@ -39,22 +39,24 @@ public class WinconditionAllDead extends Wincondition implements Listener {
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
handleDeath(event.getEntity().getPlayer(), " §cist gestorben!");
handleDeath(event.getEntity().getPlayer());
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
handleDeath(event.getPlayer(), " §chat den Kampf verlassen!");
handleDeath(event.getPlayer());
}
private void handleDeath(Player player, String message){
private void handleDeath(Player player){
FightTeam team = isTarget(player);
if(team == null)
return;
if(team.allPlayersOut()) {
FightSystem.broadcast("§cDer letzte Spieler aus " + team.getColoredName() + message);
win(Fight.getOpposite(team));
for(FightPlayer fp : team.getPlayers()) {
if(fp.isLiving() && fp.getPlayer() != player)
return;
}
win(Fight.getOpposite(team), team.getPrefix() + "Alle Spieler kampfunfähig");
}
}

Datei anzeigen

@ -19,7 +19,6 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
@ -39,22 +38,21 @@ public class WinconditionCaptainDead extends Wincondition implements Listener {
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
handleDeath(event.getEntity().getPlayer(), " §cist gestorben!");
handleDeath(event.getEntity().getPlayer());
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
handleDeath(event.getPlayer(), " §chat den Kampf verlassen!");
handleDeath(event.getPlayer());
}
private void handleDeath(Player player, String message){
private void handleDeath(Player player){
FightTeam team = isTarget(player);
if(team == null)
return;
if(team.isPlayerLeader(player)) {
FightSystem.broadcast("§cDer Leader von " + team.getColoredName() + message);
win(Fight.getOpposite(team));
win(Fight.getOpposite(team), team.getPrefix() + team.getLeader().getPlayer().getName() + " kampfunfähig");
}
}
}

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
@ -40,14 +39,11 @@ public class WinconditionHeartRatioTimeout extends Wincondition {
double redHeartRatio = Fight.getRedTeam().getHeartRatio();
if(blueHeartRatio > redHeartRatio) {
FightSystem.broadcast("§cDie Zeit ist abgelaufen, und Team " + Fight.getBlueTeam().getColoredName() + " §chatte mehr verbleibende Leben!");
win(Fight.getBlueTeam());
win(Fight.getBlueTeam(), Fight.getBlueTeam().getPrefix() + "Mehr verbleibende Leben");
}else if(blueHeartRatio < redHeartRatio){
FightSystem.broadcast("§cDie Zeit ist abgelaufen, und Team " + Fight.getRedTeam().getColoredName() + " §chatte mehr verbleibende Leben!");
win(Fight.getRedTeam());
win(Fight.getRedTeam(), Fight.getRedTeam().getPrefix() + "Mehr verbleibende Leben");
}else{
FightSystem.broadcast("§cDie Zeit ist abgelaufen, und beide Teams hatten die gleiche Anzahl an verbleibenden Leben!");
win(null);
win(null, "§7Zeit abgelaufen");
}
}
}

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
@ -64,7 +63,7 @@ public class WinconditionPercentSystem extends Wincondition implements Listener,
@Override
public String getDisplay(FightTeam team) {
return team.getPrefix() + "Schaden: " + (Math.round(100.0 * getPercent(team)) / 100.0) + "%";
return team.getPrefix() + (Math.round(100.0 * getPercent(team)) / 100.0) + "§8%";
}
@Override
@ -92,8 +91,7 @@ public class WinconditionPercentSystem extends Wincondition implements Listener,
destroyedBlocks += event.blockList().size();
percent = (double)destroyedBlocks * 100 / volume;
if(percent >= Config.PercentWin) {
FightSystem.broadcast("§cTeam " + team.getColoredName() + " §chat zu viel Schaden erlitten!");
win(Fight.getOpposite(team));
win(Fight.getOpposite(team), team.getColoredName() + " §7zu beschädigt");
}
}
}

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
@ -40,14 +39,11 @@ public class WinconditionPercentTimeout extends Wincondition {
double redPercent = Wincondition.percentWincondition.getPercent(Fight.getRedTeam());
if(bluePercent > redPercent) {
FightSystem.broadcast("§cDie Zeit ist abgelaufen, und Team " + Fight.getRedTeam().getColoredName() + " §chat weniger Schaden erlitten!");
win(Fight.getRedTeam());
win(Fight.getRedTeam(), Fight.getRedTeam().getColoredName() + " §7weniger beschädigt");
}else if(bluePercent < redPercent){
FightSystem.broadcast("§cDie Zeit ist abgelaufen, und Team " + Fight.getBlueTeam().getColoredName() + " §chat weniger Schaden erlitten!");
win(Fight.getBlueTeam());
win(Fight.getBlueTeam(), Fight.getBlueTeam().getColoredName() + " §7weniger beschädigt");
}else{
FightSystem.broadcast("§cDie Zeit ist abgelaufen, und beide Teams hatten gleichen Schaden erlitten!");
win(null);
win(null, "§7Zeit abgelaufen");
}
}
}

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
@ -70,28 +69,25 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond
int bluePoints = teamMap.get(Fight.getBlueTeam()).getPoints();
if(bluePoints < redPoints) {
FightSystem.broadcast("§cDas Team " + Fight.getRedTeam().getColoredName() + " §chat mehr Punkte!");
win(Fight.getRedTeam());
win(Fight.getRedTeam(), Fight.getRedTeam().getPrefix() + " hat mehr Punkte");
}else if(bluePoints > redPoints){
FightSystem.broadcast("§cDas Team " + Fight.getBlueTeam().getColoredName() + " §chat mehr Punkte!");
win(Fight.getBlueTeam());
win(Fight.getBlueTeam(), Fight.getBlueTeam().getPrefix() + " hat mehr Punkte");
}else{
FightSystem.broadcast("§cBeide Teams haben gleich viele Punkte!");
win(null);
win(null, "§7Gleicher Punktestand");
}
}
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
handleDeath(event.getEntity().getPlayer(), " §cist gestorben!");
handleDeath(event.getEntity().getPlayer());
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
handleDeath(event.getPlayer(), " §chat den Kampf verlassen!");
handleDeath(event.getPlayer());
}
private void handleDeath(Player player, String message){
private void handleDeath(Player player){
FightTeam team = isTarget(player);
if(team == null)
return;
@ -99,7 +95,6 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond
TeamPoints enemy = teamMap.get(Fight.getOpposite(team));
if(team.isPlayerLeader(player)) {
enemy.points += 500;
FightSystem.broadcast("§cDer Leader von " + team.getColoredName() + message);
timeOver();
}else if(team.getPlayers().size() <= 5)
enemy.points += 300;
@ -110,7 +105,7 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond
@Override
public String getDisplay(FightTeam team) {
return team.getPrefix() + "Punkte: " + teamMap.get(team).getPoints();
return team.getPrefix() + teamMap.get(team).getPoints() + "§8Punkte";
}
private class TeamPoints {

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
@ -57,7 +56,7 @@ public class WinconditionPumpkinTechKO extends Wincondition implements Printable
@Override
public String getDisplay(FightTeam team) {
return team.getPrefix() + "Kanonen: " + teamMap.get(team).pumpkins;
return team.getPrefix() + teamMap.get(team).pumpkins + "§8Kanonen";
}
private class TeamPumpkin {
@ -77,8 +76,7 @@ public class WinconditionPumpkinTechKO extends Wincondition implements Printable
});
if(pumpkins == 0) {
FightSystem.broadcast("§cDas Team " + team.getColoredName() + " §cist Tech K.O.!");
win(Fight.getOpposite(team));
win(Fight.getOpposite(team), team.getColoredName() + " ist Tech K.O.");
}
}
}

Datei anzeigen

@ -64,7 +64,7 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
@Override
public String getDisplay(FightTeam team) {
return team.getPrefix() + "Schaden: " + (Math.round(100.0 * getPercent(team)) / 100.0) + "%";
return team.getPrefix() + (Math.round(100.0 * getPercent(team)) / 100.0) + "§8%";
}
public static class TeamPercent extends StateDependent {
@ -99,8 +99,7 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
return;
if(getPercent() >= Config.PercentWin){
FightSystem.broadcast("§cTeam " + team.getColoredName() + " §chat zu viel Schaden erlitten!");
FightSystem.setSpectateState(Fight.getOpposite(team), "RelativePercent");
FightSystem.setSpectateState(Fight.getOpposite(team), "RelativePercent", team.getColoredName() + " §7zu beschädigt");
}
}

Datei anzeigen

@ -20,13 +20,12 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.utils.SWSound;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.TNTPrimed;
@ -121,8 +120,7 @@ public class WinconditionTimeTechKO extends Wincondition {
@Override
public void countdownFinished() {
FightSystem.broadcast("§cTeam " + team.getColoredName() + " §chat zu lange nicht geschossen!");
win(Fight.getOpposite(team));
win(Fight.getOpposite(team), team.getColoredName() + " ist Tech K.O.");
}
}
}

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCountdown;
@ -35,7 +34,6 @@ public class WinconditionTimeout extends Wincondition {
}
protected void timeOver() {
FightSystem.broadcast("§cDie Zeit ist abgelaufen!");
win(null);
win(null, "§7Zeit abgelaufen");
}
}

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
@ -55,7 +54,7 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi
@Override
public String getDisplay(FightTeam team) {
return team.getPrefix() + "Wasser: " + teamMap.get(team).water;
return team.getPrefix() + teamMap.get(team).water + "§8Wasser";
}
private class TeamWater {
@ -74,8 +73,7 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi
});
if(water == 0){
FightSystem.broadcast("§cTeam " + team.getColoredName() + " §cwurde Tech K.O. gesetzt!");
win(Fight.getOpposite(team));
win(Fight.getOpposite(team), team.getColoredName() + " ist Tech K.O.");
}
}
}