SteamWar/FightSystem
Archiviert
13
1

Merge pull request 'New Fight UI' (#288) from newFightUI into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #288
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Lixfel 2021-10-01 17:25:55 +02:00
Commit c3aca89836
37 geänderte Dateien mit 554 neuen und 228 gelöschten Zeilen

Datei anzeigen

@ -24,6 +24,7 @@ import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.SoundCategory; import org.bukkit.SoundCategory;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
public class WorldOfColorWrapper12 implements WorldOfColorWrapper.IWorldOfColorWrapper { public class WorldOfColorWrapper12 implements WorldOfColorWrapper.IWorldOfColorWrapper {
@ -41,4 +42,9 @@ public class WorldOfColorWrapper12 implements WorldOfColorWrapper.IWorldOfColorW
public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) { public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) {
location.getWorld().playSound(location, sound, SoundCategory.valueOf(soundCategory), volume, pitch); location.getWorld().playSound(location, sound, SoundCategory.valueOf(soundCategory), volume, pitch);
} }
@Override
public void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop) {
player.sendTitle(title, subtitle, start, hold, stop);
}
} }

Datei anzeigen

@ -20,28 +20,32 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.listener.Recording; import de.steamwar.fightsystem.listener.Recording;
import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.record.REntity; import de.steamwar.fightsystem.record.REntity;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.minecraft.server.v1_8_R3.ChatComponentText; import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
import net.royawesome.jlibnoise.MathHelper; import net.royawesome.jlibnoise.MathHelper;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
import java.util.HashMap; import java.util.*;
import java.util.Map;
import java.util.UUID;
public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper { public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
public BountifulWrapper8() {
EntityEnderDragon dragon = new EntityEnderDragon(null);
dragon.setLocation(Config.ArenaRegion.centerX(), -100, Config.ArenaRegion.centerZ(), 0, 0);
this.spawnDragonId = dragon.getId();
this.spawnDragon = new PacketPlayOutSpawnEntityLiving(dragon);
}
@Override @Override
public boolean mainHand(Object packet) { public boolean mainHand(Object packet) {
return true; return true;
@ -157,4 +161,50 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
equipmentSlot.set(packet, 0); equipmentSlot.set(packet, 0);
} }
} }
private final Map<FightUI.BossBarType, PacketPlayOutEntityMetadata> barMap = new HashMap<>();
@Override
public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
barMap.clear();
barMap.put(FightUI.BossBarType.BLUE_LEFT, createPacket(leftBlueProgress, leftBlueText));
barMap.put(FightUI.BossBarType.RED_LEFT, createPacket(leftRedProgress, leftRedText));
}
private PacketPlayOutEntityMetadata createPacket(double progress, String text) {
DataWatcher watcher = new DataWatcher(null);
watcher.a(0, (byte) 0x20);
watcher.a(2, text);
watcher.a(3, (byte) 1);
watcher.a(4, (byte) 1);
watcher.a(6, (float)(progress * 200));
//watcher.a(10, text);
//watcher.a(11, (byte) 1);
return new PacketPlayOutEntityMetadata(spawnDragonId, watcher, true);
}
@Override
public void removeFromBar(Player player, FightUI.BossBarType type) {
// not used
}
@Override
public void addToBar(Player player, FightUI.BossBarType type) {
// not used
}
private final Set<Player> seesDragon = new HashSet<>();
private final PacketPlayOutSpawnEntityLiving spawnDragon;
private final int spawnDragonId;
@Override
public void broadcastBossbar() {
seesDragon.removeIf(player -> !player.isOnline());
Bukkit.getOnlinePlayers().forEach(player -> {
if(!seesDragon.contains(player)) {
((CraftPlayer)player).getHandle().playerConnection.sendPacket(spawnDragon);
seesDragon.add(player);
}
((CraftPlayer) player).getHandle().playerConnection.sendPacket(barMap.get(FightUI.getInstance().bossBarType(player)));
});
}
} }

Datei anzeigen

@ -23,6 +23,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
public class WorldOfColorWrapper8 implements WorldOfColorWrapper.IWorldOfColorWrapper { public class WorldOfColorWrapper8 implements WorldOfColorWrapper.IWorldOfColorWrapper {
@ -40,4 +41,10 @@ public class WorldOfColorWrapper8 implements WorldOfColorWrapper.IWorldOfColorWr
public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) { public void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch) {
location.getWorld().playSound(location, sound, volume, pitch); location.getWorld().playSound(location, sound, volume, pitch);
} }
@SuppressWarnings("deprecation")
@Override
public void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop) {
player.sendTitle(title, subtitle);
}
} }

Datei anzeigen

@ -20,16 +20,19 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.listener.Recording; import de.steamwar.fightsystem.listener.Recording;
import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.record.REntity; import de.steamwar.fightsystem.record.REntity;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.Material; import org.bukkit.*;
import org.bukkit.Particle;
import org.bukkit.World;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance; import org.bukkit.attribute.AttributeInstance;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -40,6 +43,8 @@ import org.bukkit.scoreboard.Team;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
@ -48,6 +53,12 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
private static final Object mainHand = enumHand.getEnumConstants()[0]; private static final Object mainHand = enumHand.getEnumConstants()[0];
private static final Reflection.FieldAccessor<?> blockPlaceHand = Reflection.getField(Recording.blockPlacePacket, enumHand, 0); private static final Reflection.FieldAccessor<?> blockPlaceHand = Reflection.getField(Recording.blockPlacePacket, enumHand, 0);
public BountifulWrapper9() {
for(FightUI.BossBarType type : FightUI.BossBarType.values()) {
barMap.put(type, Bukkit.createBossBar(type.name(), BarColor.WHITE, BarStyle.SOLID));
}
}
@Override @Override
public boolean mainHand(Object packet) { public boolean mainHand(Object packet) {
return blockPlaceHand.get(packet) == mainHand; return blockPlaceHand.get(packet) == mainHand;
@ -193,4 +204,66 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
equipmentSlot.set(packet, itemSlots[0]); equipmentSlot.set(packet, itemSlots[0]);
} }
} }
private final Map<FightUI.BossBarType, BossBar> barMap = new HashMap<>();
@Override
public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
setupTeamBar(Fight.getBlueTeam(), barMap.get(FightUI.BossBarType.BLUE_LEFT), leftBlueProgress, leftBlueText);
setupTeamBar(Fight.getRedTeam(), barMap.get(FightUI.BossBarType.RED_LEFT), leftRedProgress, leftRedText);
}
private void setupTeamBar(FightTeam team, BossBar bar, double progress, String title) {
BarColor color = chat2bar(team.getColor());
if(bar.getColor() != color)
bar.setColor(color);
if(bar.getProgress() != progress)
bar.setProgress(progress);
bar.setTitle(title);
}
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;
}
}
@Override
public void removeFromBar(Player player, FightUI.BossBarType type) {
barMap.get(type).removePlayer(player);
}
@Override
public void addToBar(Player player, FightUI.BossBarType type) {
barMap.get(type).addPlayer(player);
}
@Override
public void broadcastBossbar() {
// Handled by Spigot BossBarAPI
}
} }

Datei anzeigen

@ -33,6 +33,7 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.utils.EnterHandler; import de.steamwar.fightsystem.utils.EnterHandler;
import de.steamwar.fightsystem.utils.FightStatistics; import de.steamwar.fightsystem.utils.FightStatistics;
import de.steamwar.fightsystem.utils.FightUI;
import de.steamwar.fightsystem.utils.TechHider; import de.steamwar.fightsystem.utils.TechHider;
import de.steamwar.fightsystem.winconditions.*; import de.steamwar.fightsystem.winconditions.*;
import de.steamwar.sql.EventFight; import de.steamwar.sql.EventFight;
@ -80,13 +81,13 @@ public class FightSystem extends JavaPlugin {
new NormalJoin(); new NormalJoin();
new RankedJoin(); new RankedJoin();
new PersonalKitCreator(); new PersonalKitCreator();
new FightScoreboard();
new ArrowStopper(); new ArrowStopper();
new ArrowPickup(); new ArrowPickup();
new EnterHandler(); new EnterHandler();
new TechHider(); new TechHider();
new FightWorld(); new FightWorld();
new FightUI();
new WinconditionAllDead(); new WinconditionAllDead();
new WinconditionCaptainDead(); new WinconditionCaptainDead();
@ -129,8 +130,8 @@ public class FightSystem extends JavaPlugin {
new LiveRecorder(); new LiveRecorder();
new FileRecorder(); new FileRecorder();
new OneShotStateDependent(ArenaMode.AntiReplay, FightState.PreRunning, () -> FightSystem.broadcast("§aDer Kampf beginnt!")); new OneShotStateDependent(ArenaMode.AntiReplay, FightState.PreRunning, () -> FightUI.addSubtitle("§7Kits verteilt"));
new OneShotStateDependent(ArenaMode.AntiReplay, FightState.Running, () -> FightSystem.broadcast("§aArena freigegeben!")); new OneShotStateDependent(ArenaMode.AntiReplay, FightState.Running, () -> FightUI.addSubtitle("§aArena freigegeben"));
new OneShotStateDependent(ArenaMode.AntiTest, FightState.Running, FightStatistics::start); new OneShotStateDependent(ArenaMode.AntiTest, FightState.Running, FightStatistics::start);
try { try {
@ -182,12 +183,12 @@ public class FightSystem extends JavaPlugin {
FightState.setFightState(FightState.RUNNING); 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(!PacketProcessor.isReplaying()){
if(winFightTeam != null) { if(winFightTeam != null) {
FightSystem.broadcast("§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!"); FightUI.printWin(winFightTeam.getPrefix() + "Sieg " + winFightTeam.getName(), subtitle);
} else { } else {
FightSystem.broadcast("§aKein Team hat gewonnen!"); FightUI.printWin("§7Unentschieden", subtitle);
} }
} }

Datei anzeigen

@ -112,7 +112,6 @@ public class Commands {
return; return;
p.sendMessage(FightSystem.PREFIX + "§aDu bist Team " + team.getColoredName() + " §abeigetreten!"); p.sendMessage(FightSystem.PREFIX + "§aDu bist Team " + team.getColoredName() + " §abeigetreten!");
team.broadcast(FightSystem.PREFIX + "§aDer Spieler §e" + p.getName() + " §aist dem Team beigetreten!");
team.addMember(p); team.addMember(p);
} }
@ -125,7 +124,7 @@ public class Commands {
return; return;
p.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von " + team.getColoredName() + " §aabgelehnt!"); p.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von " + team.getColoredName() + " §aabgelehnt!");
team.broadcast(FightSystem.PREFIX + "§cDer Spieler §e" + p.getName() + " §chat die Einladung abgelehnt!"); team.broadcast("§e" + p.getName() + " §chat die Einladung abgelehnt");
team.getInvited().remove(p); team.getInvited().remove(p);
} }

Datei anzeigen

@ -74,9 +74,9 @@ public class GUI {
inv.setItem(2, Material.GLASS, "§7POST_SCHEM_SETUP", (ClickType click) -> FightSystem.setPostSchemState()); 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(3, Material.GLASS, "§ePRE_RUNNING", (ClickType click) -> FightSystem.setPreRunningState());
inv.setItem(4, Material.GLASS, "§eRUNNING", (ClickType click) -> FightSystem.setRunningState()); 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(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")); 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")); inv.setItem(7, Material.GLASS, "§7SPECTATE Tie", (ClickType click) -> FightSystem.setSpectateState(null, "operator", null));
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open(); inv.open();
} }

Datei anzeigen

@ -70,7 +70,7 @@ public class LockschemCommand implements CommandExecutor {
} }
Schematic.getSchemFromDB(fightTeam.getSchematic()).setSchemType(SchematicType.Normal); Schematic.getSchemFromDB(fightTeam.getSchematic()).setSchemType(SchematicType.Normal);
player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + " §cgesperrt!"); player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + " §cgesperrt!");
fightTeam.broadcast(FightSystem.PREFIX + "§cDie Schematic wurde von " + player.getName() + " gesperrt!"); fightTeam.broadcast("§cDie Schematic wurde von " + player.getName() + " gesperrt");
return false; return false;
} }

Datei anzeigen

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

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.listener.BasicListener; import de.steamwar.fightsystem.listener.BasicListener;
import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.utils.FightUI;
import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.utils.SWSound;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
@ -86,7 +87,7 @@ public abstract class Countdown {
countdown.show(); 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){ private void broadcast(String message){

Datei anzeigen

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

Datei anzeigen

@ -72,7 +72,7 @@ public class FightSchematic extends StateDependent {
try { try {
clipboard = schem.load(); clipboard = schem.load();
} catch (IOException e) { } catch (IOException e) {
team.broadcast(FightSystem.PREFIX + "§cSchematic konnte nicht geladen werden!"); team.broadcast("§cSchematic konnte nicht geladen werden");
Bukkit.getLogger().log(Level.SEVERE, e, () -> "Couldn't load Schematic " + schem.getSchemName()); Bukkit.getLogger().log(Level.SEVERE, e, () -> "Couldn't load Schematic " + schem.getSchemName());
} }
} }

Datei anzeigen

@ -34,6 +34,8 @@ import de.steamwar.fightsystem.utils.*;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -42,6 +44,7 @@ import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
import java.util.*; import java.util.*;
import java.util.logging.Level;
public class FightTeam { public class FightTeam {
@ -184,7 +187,14 @@ public class FightTeam {
} }
public void broadcast(String message) { public void broadcast(String message) {
players.forEach((player, fp) -> player.sendMessage(message)); BaseComponent[] msg = TextComponent.fromLegacyText(message);
players.forEach((player, fp) -> BountifulWrapper.impl.toActionbar(player, msg));
}
public void broadcastChat(String message) {
FightSystem.getPlugin().getLogger().log(Level.INFO, message);
BaseComponent[] msg = TextComponent.fromLegacyText(message);
players.forEach((player, fp) -> BountifulWrapper.impl.toChat(player, msg));
} }
public void addMember(Player player) { public void addMember(Player player) {
@ -210,6 +220,8 @@ public class FightTeam {
if(isLeaderless()) if(isLeaderless())
setLeader(fightPlayer); setLeader(fightPlayer);
else
FightUI.addSubtitle("§a§l» " + prefix + player.getName());
} }
public void removePlayer(Player player) { public void removePlayer(Player player) {
@ -220,8 +232,10 @@ public class FightTeam {
players.remove(player); players.remove(player);
team.removeEntry(player.getName()); team.removeEntry(player.getName());
FightUI.addSubtitle("§c§l« " + prefix + player.getName());
if(fightPlayer.equals(leader)) if(fightPlayer.equals(leader))
setLeader(null); removeLeader();
GlobalRecorder.getInstance().entityDespawns(player); GlobalRecorder.getInstance().entityDespawns(player);
Fight.setPlayerGamemode(player, GameMode.SPECTATOR); Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
@ -247,17 +261,16 @@ public class FightTeam {
return leader; return leader;
} }
private void setLeader(FightPlayer leader) { private void removeLeader() {
if (leader == null) { this.leader = null;
this.leader = null; if(!players.isEmpty()) {
if(!players.isEmpty()) { setLeader(players.values().iterator().next());
setLeader(players.values().iterator().next()); }else if(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){
FightSystem.broadcast("§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!"); Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightSystem::setPreLeaderState, 1);
}else if(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightSystem::setPreLeaderState, 1);
}
return;
} }
}
private void setLeader(FightPlayer leader) {
PersonalKitCreator.closeIfInKitCreator(leader.getPlayer()); PersonalKitCreator.closeIfInKitCreator(leader.getPlayer());
this.leader = leader; this.leader = leader;
@ -265,6 +278,8 @@ public class FightTeam {
if(ready) if(ready)
setReady(false); setReady(false);
FightUI.addSubtitle("§a§l» " + prefix + "Leader " + leader.getPlayer().getName());
Optional<Integer> maxRank = Schematic.getSchemsOfType(leader.getPlayer().getUniqueId(), Config.SchematicType).stream().map(Schematic::getRank).max(Integer::compare); Optional<Integer> maxRank = Schematic.getSchemsOfType(leader.getPlayer().getUniqueId(), Config.SchematicType).stream().map(Schematic::getRank).max(Integer::compare);
if(Config.RanksEnabled) if(Config.RanksEnabled)
schemRank = maxRank.orElse(1); schemRank = maxRank.orElse(1);
@ -329,40 +344,40 @@ public class FightTeam {
public void setSchem(Schematic schematic){ public void setSchem(Schematic schematic){
this.schematic.setSchematic(schematic); this.schematic.setSchematic(schematic);
broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!"); broadcast("§e" + Config.GameName + " " + schematic.getSchemName() + " §7gewählt");
} }
public void setReady(boolean ready) { public void setReady(boolean ready) {
Player l = leader.getPlayer(); Player l = leader.getPlayer();
if(!schematic.hasSchematic()){ if(!schematic.hasSchematic()){
l.sendMessage(FightSystem.PREFIX + "§cZuerst muss eine Schematic gewählt sein!"); BountifulWrapper.impl.toActionbar(l, TextComponent.fromLegacyText("§cZuerst muss eine Schematic gewählt sein!"));
return; return;
} }
this.ready = ready; this.ready = ready;
if(ready) { if(ready) {
l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build()); l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build());
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!"); broadcast("§aTeam bereit");
if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode)) if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode))
FightSystem.setPreRunningState(); FightSystem.setPreRunningState();
} else { } else {
l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build()); l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!"); broadcast("§c§mTeam bereit");
} }
} }
public void skip(){ public void skip(){
this.skip = !skip; this.skip = !skip;
if(skip){ if(skip){
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit, zum nächsten Event zu beschleunigen!"); broadcast("§aBeschleunigung zum nächsten Event");
if(Fight.getOpposite(this).skip || Config.test()){ if(Fight.getOpposite(this).skip || Config.test()){
skip = false; skip = false;
Fight.getOpposite(this).skip = false; Fight.getOpposite(this).skip = false;
Countdown.skip(); Countdown.skip();
} }
}else{ }else{
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit, zum nächsten Event zu beschleunigen!"); broadcast("§c§mBeschleunigung zum nächsten Event");
} }
} }
@ -390,19 +405,21 @@ public class FightTeam {
return spawn; return spawn;
} }
public double getCurrentHearts() {
return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getPlayer().getHealth()).sum();
}
public double getHeartRatio(){ public double getHeartRatio(){
int maximumHearts = 0; int maximumHearts = players.size() * 20;
double currentHearts = 0; return maximumHearts != 0 ? getCurrentHearts() / maximumHearts : 0;
for(FightPlayer fightPlayer : players.values()){ }
maximumHearts += 20;
if(!fightPlayer.isLiving())
continue;
currentHearts += fightPlayer.getPlayer().getHealth(); public int getPlayerCount() {
} return players.size();
}
assert maximumHearts != 0; public int getAlivePlayers() {
return currentHearts / maximumHearts; return (int) players.values().stream().filter(FightPlayer::isLiving).count();
} }
public ChatColor getColor() { public ChatColor getColor() {

Datei anzeigen

@ -36,6 +36,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.logging.Level;
public class Chat implements Listener { public class Chat implements Listener {
public Chat(){ public Chat(){
@ -51,7 +53,7 @@ public class Chat implements Listener {
if(fightTeam != null) { if(fightTeam != null) {
String teamName = fightTeam.getColoredName(); String teamName = fightTeam.getColoredName();
if(message.startsWith(Config.TeamChatDetection)) { if(message.startsWith(Config.TeamChatDetection)) {
fightTeam.broadcast(teamName + " " + player.getName() + "» " + message.substring(1)); fightTeam.broadcastChat(teamName + " " + player.getName() + "» " + message.substring(1));
} else { } else {
broadcastChat(teamName + " " + player.getName() + "§8» §7" + message); broadcastChat(teamName + " " + player.getName() + "§8» §7" + message);
} }
@ -66,6 +68,7 @@ public class Chat implements Listener {
private void broadcastChat(String message) { private void broadcastChat(String message) {
GlobalRecorder.getInstance().chat(message); GlobalRecorder.getInstance().chat(message);
FightSystem.getPlugin().getLogger().log(Level.INFO, message);
BaseComponent[] msg = TextComponent.fromLegacyText(message); BaseComponent[] msg = TextComponent.fromLegacyText(message);
for(Player p : Bukkit.getOnlinePlayers()) for(Player p : Bukkit.getOnlinePlayers())
BountifulWrapper.impl.toChat(p, msg); BountifulWrapper.impl.toChat(p, msg);

Datei anzeigen

@ -19,18 +19,9 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import de.steamwar.core.TPSWatcher;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.record.PacketProcessor;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.winconditions.PrintableWincondition;
import de.steamwar.fightsystem.winconditions.Wincondition;
import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.SWScoreboard;
import de.steamwar.scoreboard.ScoreboardCallback; import de.steamwar.scoreboard.ScoreboardCallback;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -40,7 +31,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
import java.util.*; import java.util.HashMap;
import java.util.Objects;
public class FightScoreboard implements Listener, ScoreboardCallback { public class FightScoreboard implements Listener, ScoreboardCallback {
@ -48,23 +40,21 @@ public class FightScoreboard implements Listener, ScoreboardCallback {
return Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard(); return Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
} }
private static final Set<FightState> fullScoreboard = EnumSet.of(FightState.RUNNING, FightState.SPECTATE);
private static FightScoreboard scoreboard; private static FightScoreboard scoreboard;
public static FightScoreboard getScoreboard(){ public static FightScoreboard getScoreboard(){
if(scoreboard == null)
scoreboard = new FightScoreboard();
return scoreboard; return scoreboard;
} }
private int index = 0;
private String title = ""; private String title = "";
private final HashMap<String, Integer> scores = new HashMap<>(); private final HashMap<String, Integer> scores = new HashMap<>();
public FightScoreboard(){ private FightScoreboard(){
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this); new StateDependentListener(ArenaMode.Replay, FightState.All, this);
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::updateScoreboard, 0, 20); Bukkit.getOnlinePlayers().forEach(player -> SWScoreboard.createScoreboard(player, this));
scoreboard = this;
} }
@EventHandler @EventHandler
@ -77,63 +67,13 @@ public class FightScoreboard implements Listener, ScoreboardCallback {
SWScoreboard.removeScoreboard(event.getPlayer()); SWScoreboard.removeScoreboard(event.getPlayer());
} }
private void generalScoreboard(){
setTitle("§eKampf");
List<String> scoreList = new ArrayList<>();
Countdown timeOverCountdown = Wincondition.getTimeOverCountdown();
if(timeOverCountdown != null){
int fightTime = timeOverCountdown.getTimeLeft();
if (fightTime >= 60)
scoreList.add("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s");
else
scoreList.add("§7Zeit: §a" + fightTime + "s");
}
scoreList.add("§7TPS: §e" + TPSWatcher.getTPS());
if(fullScoreboard.contains(FightState.getFightState())){
for(PrintableWincondition wincondition : Wincondition.getPrintableWinconditions()){
scoreList.add(wincondition.getDisplay(Fight.getRedTeam()));
scoreList.add(wincondition.getDisplay(Fight.getBlueTeam()));
}
}
int value = scoreList.size();
for(String score : scoreList){
addScore(score, value--);
}
}
private void teamScoreboard(FightTeam fightTeam){
fightTeam.getPlayers().forEach(fp -> {
if(fp.isLiving())
addScore(fightTeam.getPrefix() + fp.getPlayer().getName(), (int) Math.ceil(fp.getPlayer().getHealth()));
});
}
private void updateScoreboard() {
if(PacketProcessor.isReplaying())
return;
if ((index++ / 5) % 2 == 0) {
generalScoreboard();
} else {
setTitle(Fight.getBlueTeam().getColoredName() + " " + Fight.getRedTeam().getColoredName());
teamScoreboard(Fight.getBlueTeam());
teamScoreboard(Fight.getRedTeam());
}
}
public void setTitle(String t) { public void setTitle(String t) {
scores.clear(); scores.clear();
title = t; title = t;
GlobalRecorder.getInstance().scoreboardTitle(t);
} }
public void addScore(String string, int i) { public void addScore(String string, int i) {
scores.put(string, i); scores.put(string, i);
GlobalRecorder.getInstance().scoreboardData(string, i);
} }
@Override @Override

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -30,10 +30,7 @@ import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.FreezeWorld; import de.steamwar.fightsystem.fight.FreezeWorld;
import de.steamwar.fightsystem.listener.BasicListener; import de.steamwar.fightsystem.listener.BasicListener;
import de.steamwar.fightsystem.listener.FightScoreboard; import de.steamwar.fightsystem.listener.FightScoreboard;
import de.steamwar.fightsystem.utils.BlockIdWrapper; import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.utils.BountifulWrapper;
import de.steamwar.fightsystem.utils.TechHider;
import de.steamwar.fightsystem.utils.WorldOfColorWrapper;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import de.steamwar.sql.Team; import de.steamwar.sql.Team;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
@ -112,6 +109,9 @@ public class PacketProcessor {
packetDecoder[0xb4] = () -> pasteEmbeddedSchem(Fight.getRedTeam()); packetDecoder[0xb4] = () -> pasteEmbeddedSchem(Fight.getRedTeam());
packetDecoder[0xc0] = this::scoreboardTitle; packetDecoder[0xc0] = this::scoreboardTitle;
packetDecoder[0xc1] = this::scoreboardData; packetDecoder[0xc1] = this::scoreboardData;
packetDecoder[0xc2] = this::bossBar;
packetDecoder[0xc3] = this::subtitle;
packetDecoder[0xc4] = this::printWin;
packetDecoder[0xef] = source::readUTF; packetDecoder[0xef] = source::readUTF;
packetDecoder[0xff] = this::tick; packetDecoder[0xff] = this::tick;
@ -373,11 +373,33 @@ public class PacketProcessor {
FightScoreboard.getScoreboard().addScore(key, value); FightScoreboard.getScoreboard().addScore(key, value);
} }
private void bossBar() throws IOException {
double leftBlueProgress = source.readDouble();
double leftRedProgress = source.readDouble();
String leftBlueText = source.readUTF();
String leftRedText = source.readUTF();
FightUI.getInstance().setBossbar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
}
private void subtitle() throws IOException {
String subtitle = source.readUTF();
FightUI.addSubtitle(subtitle);
}
private void printWin() throws IOException {
String title = source.readUTF();
String subtitle = source.readUTF();
FightUI.printWin(title, subtitle);
}
private void endReplay(){ private void endReplay(){
REntity.dieAll(); REntity.dieAll();
freezer.disable(); freezer.disable();
if(Config.replayserver() || ArenaMode.AntiReplay.contains(Config.mode)) { if(Config.replayserver() || ArenaMode.AntiReplay.contains(Config.mode)) {
FightSystem.setSpectateState(null, "Replay ends"); FightSystem.setSpectateState(null, "Replay ends", null);
}else{ }else{
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cReplay beendet"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cReplay beendet");
new EventSpectateCountdown().enable(); new EventSpectateCountdown().enable();

Datei anzeigen

@ -102,7 +102,7 @@ public interface Recorder {
* BlockPacket (0x30) + pos int, byte, int + int BlockState * BlockPacket (0x30) + pos int, byte, int + int BlockState
* ParticlePacket (0x31) + double x, y, z + string particleType * ParticlePacket (0x31) + double x, y, z + string particleType
* SoundPacket (0x32) + int x, y, z + string soundType + string soundCategory + float volume, pitch * SoundPacket (0x32) + int x, y, z + string soundType + string soundCategory + float volume, pitch
* ShortBlockPacket (0x33) + pos relative to ArenaMinX,ArenaMinZ byte, byte, byte + short BlockState * DEPRECATED ShortBlockPacket (0x33) + pos relative to ArenaMinX,ArenaMinZ byte, byte, byte + short BlockState
* SoundAtPlayerPacket (0x34) + string (soundType, soundCategory) + float volume, pitch * SoundAtPlayerPacket (0x34) + string (soundType, soundCategory) + float volume, pitch
* ShortBlockPacket (0x35) + pos relative to ArenaMinX,BluePasteY,ArenaMinZ byte, byte, byte + short BlockState * ShortBlockPacket (0x35) + pos relative to ArenaMinX,BluePasteY,ArenaMinZ byte, byte, byte + short BlockState
* *
@ -117,8 +117,11 @@ public interface Recorder {
* BlueEmbeddedSchemPacket (0xB3) + int blueSchemId + gzipt NBT blob * BlueEmbeddedSchemPacket (0xB3) + int blueSchemId + gzipt NBT blob
* RedEmbeddedSchemPacket (0xB4) + int redSchemId + gzipt NBT blob * RedEmbeddedSchemPacket (0xB4) + int redSchemId + gzipt NBT blob
* *
* ScoreboardTitlePacket (0xC0) + String scoreboardTitle * DEPRECATED ScoreboardTitlePacket (0xC0) + String scoreboardTitle
* ScoreboardDataPacket (0xC1) + String key + int value * DEPRECATED ScoreboardDataPacket (0xC1) + String key + int value
* BossBarPacket (0xC2) + double leftBlueProgress, leftRedProgress + String leftBlueText, leftRedText
* SubtitlePacket (0xC3) + String subtitle
* PrintWinPacket (0xC4) + String title, subtitle
* *
* CommentPacket (0xfe) + String comment * CommentPacket (0xfe) + String comment
* TickPacket (0xff) * TickPacket (0xff)
@ -265,12 +268,16 @@ public interface Recorder {
write(embedId, schemId, buffer.toByteArray()); write(embedId, schemId, buffer.toByteArray());
} }
default void scoreboardTitle(String title){ default void bossBar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
write(0xc0, title); write(0xc2, leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
} }
default void scoreboardData(String key, int value){ default void subtitle(String subtitle) {
write(0xc1, key, value); write(0xc3, subtitle);
}
default void printWin(String title, String subtitle) {
write(0xc4, title, subtitle);
} }
default void tick(){ default void tick(){

Datei anzeigen

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

Datei anzeigen

@ -57,5 +57,10 @@ public class BountifulWrapper {
void setTeleportPacketPosition(Object packet, double x, double y, double z); void setTeleportPacketPosition(Object packet, double x, double y, double z);
void setSpawnPacketUUID(Object packet, UUID uuid); void setSpawnPacketUUID(Object packet, UUID uuid);
void setEquipmentPacketSlot(Object packet, String slot); void setEquipmentPacketSlot(Object packet, String slot);
void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText);
void removeFromBar(Player player, FightUI.BossBarType type);
void addToBar(Player player, FightUI.BossBarType type);
void broadcastBossbar();
} }
} }

Datei anzeigen

@ -0,0 +1,213 @@
/*
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.core.TPSWatcher;
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.record.GlobalRecorder;
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 net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.logging.Level;
import java.util.stream.Collectors;
public class FightUI {
private static FightUI instance;
public static FightUI getInstance() {
return instance;
}
private final Map<Player, BossBarType> currentBarType = new HashMap<>();
public FightUI() {
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::tpsWatcher, 20, 20);
instance = this;
}
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(redHearts == 0.0 || blueHearts == 0.0) {
blueHearts = 0.5;
redHearts = 0.5;
totalHearts = 1.0;
}
int timeLeft = StateDependentCountdown.getMainCountdown() != null ? StateDependentCountdown.getMainCountdown().getTimeLeft() : 0;
String time = "§7" + (timeLeft/60) + "§8:§7" + (timeLeft%60<10 ? "0" : "") + (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;
}
setBossbar(
blueHearts / totalHearts, redHearts / totalHearts,
generator.gen(blue, red, bluePlayers, redPlayers, blueAdditional, redAdditional),
generator.gen(red, blue, redPlayers, bluePlayers, redAdditional, blueAdditional)
);
}
private interface Generator {
String gen(FightTeam l, FightTeam r, String lPlayers, String rPlayers, String lWinconditions, String rWinconditions);
}
public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
GlobalRecorder.getInstance().bossBar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
BountifulWrapper.impl.setBossbar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
}
public BossBarType bossBarType(Player player) {
return currentBarType.get(player);
}
private void sendToPlayers() {
Bukkit.getOnlinePlayers().forEach(player -> {
BossBarType type = BossBarType.byAngle(CraftbukkitWrapper.impl.headRotation(player));
BossBarType current = currentBarType.get(player);
if(type != current) {
if(current != null)
BountifulWrapper.impl.removeFromBar(player, current);
BountifulWrapper.impl.addToBar(player, type);
currentBarType.put(player, type);
}
});
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 {
BLUE_LEFT(345, 165),
RED_LEFT(165, 345);
private static final boolean blueNegZ = Config.blueNegZ();
private final double minAngle;
private final double maxAngle;
BossBarType(double minAngle, double maxAngle) {
this.minAngle = minAngle;
this.maxAngle = maxAngle;
}
private static BossBarType byAngle(double angle) {
if(blueNegZ)
angle += 180;
angle = ((angle % 360) + 360) % 360;
for(BossBarType type : values()) {
if(type.minAngle < type.maxAngle ? type.minAngle <= angle && angle < type.maxAngle : type.minAngle < angle || angle <= type.maxAngle)
return type;
}
throw new SecurityException("No boss bar for angle " + angle + " found");
}
}
private static final Queue<String> queue = new LinkedList<>();
private static boolean subtitleScheduled = false;
public static void printWin(String title, String winreason) {
queue.clear();
FightSystem.getPlugin().getLogger().log(Level.INFO, title + " " + winreason);
GlobalRecorder.getInstance().printWin(title, winreason);
Bukkit.getOnlinePlayers().forEach(p -> {
p.resetTitle();
WorldOfColorWrapper.impl.sendTitle(p, title, winreason, 5, 40, 5);
});
}
public static void addSubtitle(String message) {
if(FightState.Spectate.contains(FightState.getFightState()))
return;
queue.add(message);
GlobalRecorder.getInstance().subtitle(message);
FightSystem.getPlugin().getLogger().log(Level.INFO, message);
if(!subtitleScheduled)
printSubtitle();
}
private static void printSubtitle() {
if(queue.isEmpty()) {
subtitleScheduled = false;
return;
}
String message = queue.poll();
Bukkit.getOnlinePlayers().forEach(p -> WorldOfColorWrapper.impl.sendTitle(p, "", message, 5, 40, 5));
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightUI::printSubtitle, 100);
subtitleScheduled = true;
}
}

Datei anzeigen

@ -24,6 +24,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
public class WorldOfColorWrapper { public class WorldOfColorWrapper {
@ -36,5 +37,7 @@ public class WorldOfColorWrapper {
boolean isInBlock(Arrow e); boolean isInBlock(Arrow e);
void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch); void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch);
void sendTitle(Player player, String title, String subtitle, int start, int hold, int stop);
} }
} }

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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