New Fight UI #288
@ -24,6 +24,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.SoundCategory;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -20,28 +20,32 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.listener.Recording;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.record.REntity;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.minecraft.server.v1_8_R3.ChatComponentText;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
||||
import net.minecraft.server.v1_8_R3.*;
|
||||
import net.royawesome.jlibnoise.MathHelper;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
|
||||
|
||||
public BountifulWrapper8() {
|
||||
EntityEnderDragon dragon = new EntityEnderDragon(null);
|
||||
dragon.setLocation(Config.ArenaRegion.centerX(), 0, Config.ArenaRegion.centerZ(), 0, 0);
|
||||
this.spawnDragonId = dragon.getId();
|
||||
this.spawnDragon = new PacketPlayOutSpawnEntityLiving(dragon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mainHand(Object packet) {
|
||||
return true;
|
||||
@ -157,4 +161,54 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
|
||||
equipmentSlot.set(packet, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private PacketPlayOutEntityMetadata leftBlue;
|
||||
private PacketPlayOutEntityMetadata leftRed;
|
||||
|
||||
@Override
|
||||
public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
|
||||
DataWatcher leftBlueWatcher = new DataWatcher(null);
|
||||
leftBlueWatcher.a(0, (byte) 0x20);
|
||||
leftBlueWatcher.a(6, (float)(leftBlueProgress * 200));
|
||||
leftBlueWatcher.a(10, leftBlueText);
|
||||
leftBlueWatcher.a(2, leftBlueText);
|
||||
leftBlueWatcher.a(11, (byte) 1);
|
||||
leftBlueWatcher.a(3, (byte) 1);
|
||||
leftBlue = new PacketPlayOutEntityMetadata(spawnDragonId, leftBlueWatcher, true);
|
||||
|
||||
DataWatcher leftRedWatcher = new DataWatcher(null);
|
||||
leftRedWatcher.a(0, (byte) 0x20);
|
||||
leftRedWatcher.a(6, (float)(leftRedProgress * 200));
|
||||
leftRedWatcher.a(10, leftRedText);
|
||||
leftRedWatcher.a(2, leftRedText);
|
||||
leftRedWatcher.a(11, (byte) 1);
|
||||
leftRedWatcher.a(3, (byte) 1);
|
||||
leftRed = new PacketPlayOutEntityMetadata(spawnDragonId, leftRedWatcher, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFromBar(Player player, boolean leftBlueBar) {
|
||||
// not used
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToBar(Player player, boolean leftBlueBar) {
|
||||
// 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(FightUI.getInstance().hasBlueLeft(player) ? leftBlue : leftRed);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -20,16 +20,19 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
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.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.record.REntity;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
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.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -193,4 +196,68 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
||||
equipmentSlot.set(packet, itemSlots[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private final BossBar leftBlue = Bukkit.createBossBar("Blue", BarColor.BLUE, BarStyle.SOLID);
|
||||
private final BossBar leftRed = Bukkit.createBossBar("Red", BarColor.RED, BarStyle.SOLID);
|
||||
@Override
|
||||
public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
|
||||
setupTeamBar(Fight.getBlueTeam(), leftBlue, leftBlueProgress);
|
||||
setupTeamBar(Fight.getRedTeam(), leftRed, leftRedProgress);
|
||||
|
||||
leftBlue.setTitle(leftBlueText);
|
||||
leftRed.setTitle(leftRedText);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
Lixfel markierte diese Unterhaltung als gelöst
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFromBar(Player player, boolean leftBlueBar) {
|
||||
(leftBlueBar ? leftBlue : leftRed).removePlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToBar(Player player, boolean leftBlueBar) {
|
||||
(leftBlueBar ? leftBlue : leftRed).addPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastBossbar() {
|
||||
// Handled by Spigot BossBarAPI
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,6 @@ public class FightSystem extends JavaPlugin {
|
||||
new NormalJoin();
|
||||
new RankedJoin();
|
||||
new PersonalKitCreator();
|
||||
new FightScoreboard();
|
||||
new ArrowStopper();
|
||||
new ArrowPickup();
|
||||
|
||||
|
@ -112,7 +112,6 @@ public class Commands {
|
||||
return;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -125,7 +124,7 @@ public class Commands {
|
||||
return;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class LockschemCommand implements CommandExecutor {
|
||||
}
|
||||
Schematic.getSchemFromDB(fightTeam.getSchematic()).setSchemType(SchematicType.Normal);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class FightSchematic extends StateDependent {
|
||||
try {
|
||||
clipboard = schem.load();
|
||||
} 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());
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ import de.steamwar.fightsystem.utils.*;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.sql.Schematic;
|
||||
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.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -42,6 +44,7 @@ import org.bukkit.scoreboard.NameTagVisibility;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
public class FightTeam {
|
||||
@ -184,7 +187,14 @@ public class FightTeam {
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -210,6 +220,8 @@ public class FightTeam {
|
||||
|
||||
if(isLeaderless())
|
||||
setLeader(fightPlayer);
|
||||
else
|
||||
FightUI.addSubtitle("§a§l» " + prefix + player.getName());
|
||||
}
|
||||
|
||||
public void removePlayer(Player player) {
|
||||
@ -220,8 +232,10 @@ public class FightTeam {
|
||||
players.remove(player);
|
||||
team.removeEntry(player.getName());
|
||||
|
||||
FightUI.addSubtitle("§c§l« " + prefix + player.getName());
|
||||
|
||||
if(fightPlayer.equals(leader))
|
||||
setLeader(null);
|
||||
removeLeader();
|
||||
|
||||
GlobalRecorder.getInstance().entityDespawns(player);
|
||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||
@ -247,17 +261,16 @@ public class FightTeam {
|
||||
return leader;
|
||||
}
|
||||
|
||||
private void setLeader(FightPlayer leader) {
|
||||
if (leader == null) {
|
||||
private void removeLeader() {
|
||||
this.leader = null;
|
||||
if(!players.isEmpty()) {
|
||||
setLeader(players.values().iterator().next());
|
||||
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);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private void setLeader(FightPlayer leader) {
|
||||
PersonalKitCreator.closeIfInKitCreator(leader.getPlayer());
|
||||
|
||||
this.leader = leader;
|
||||
@ -265,6 +278,8 @@ public class FightTeam {
|
||||
if(ready)
|
||||
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);
|
||||
if(Config.RanksEnabled)
|
||||
schemRank = maxRank.orElse(1);
|
||||
@ -329,40 +344,40 @@ public class FightTeam {
|
||||
|
||||
public void setSchem(Schematic 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) {
|
||||
Player l = leader.getPlayer();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
this.ready = ready;
|
||||
if(ready) {
|
||||
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))
|
||||
FightSystem.setPreRunningState();
|
||||
} else {
|
||||
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(){
|
||||
this.skip = !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()){
|
||||
skip = false;
|
||||
Fight.getOpposite(this).skip = false;
|
||||
Countdown.skip();
|
||||
}
|
||||
}else{
|
||||
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit, zum nächsten Event zu beschleunigen!");
|
||||
broadcast("§c§mBeschleunigung zum nächsten Event");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,8 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Chat implements Listener {
|
||||
|
||||
public Chat(){
|
||||
@ -51,7 +53,7 @@ public class Chat implements Listener {
|
||||
if(fightTeam != null) {
|
||||
String teamName = fightTeam.getColoredName();
|
||||
if(message.startsWith(Config.TeamChatDetection)) {
|
||||
fightTeam.broadcast(teamName + " " + player.getName() + "» " + message.substring(1));
|
||||
fightTeam.broadcastChat(teamName + " " + player.getName() + "» " + message.substring(1));
|
||||
} else {
|
||||
broadcastChat(teamName + " " + player.getName() + "§8» §7" + message);
|
||||
}
|
||||
@ -66,6 +68,7 @@ public class Chat implements Listener {
|
||||
|
||||
private void broadcastChat(String message) {
|
||||
GlobalRecorder.getInstance().chat(message);
|
||||
FightSystem.getPlugin().getLogger().log(Level.INFO, message);
|
||||
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
||||
for(Player p : Bukkit.getOnlinePlayers())
|
||||
BountifulWrapper.impl.toChat(p, msg);
|
||||
|
@ -19,18 +19,9 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.core.TPSWatcher;
|
||||
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.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.ScoreboardCallback;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -40,7 +31,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
public class FightScoreboard implements Listener, ScoreboardCallback {
|
||||
|
||||
@ -48,23 +40,21 @@ public class FightScoreboard implements Listener, ScoreboardCallback {
|
||||
return Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
|
||||
}
|
||||
|
||||
private static final Set<FightState> fullScoreboard = EnumSet.of(FightState.RUNNING, FightState.SPECTATE);
|
||||
private static FightScoreboard scoreboard;
|
||||
|
||||
public static FightScoreboard getScoreboard(){
|
||||
if(scoreboard == null)
|
||||
scoreboard = new FightScoreboard();
|
||||
return scoreboard;
|
||||
}
|
||||
|
||||
private int index = 0;
|
||||
|
||||
private String title = "";
|
||||
private final HashMap<String, Integer> scores = new HashMap<>();
|
||||
|
||||
|
||||
public FightScoreboard(){
|
||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this);
|
||||
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::updateScoreboard, 0, 20);
|
||||
scoreboard = this;
|
||||
private FightScoreboard(){
|
||||
new StateDependentListener(ArenaMode.Replay, FightState.All, this);
|
||||
Bukkit.getOnlinePlayers().forEach(player -> SWScoreboard.createScoreboard(player, this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -77,63 +67,13 @@ public class FightScoreboard implements Listener, ScoreboardCallback {
|
||||
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) {
|
||||
scores.clear();
|
||||
title = t;
|
||||
GlobalRecorder.getInstance().scoreboardTitle(t);
|
||||
}
|
||||
|
||||
public void addScore(String string, int i) {
|
||||
scores.put(string, i);
|
||||
GlobalRecorder.getInstance().scoreboardData(string, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,10 +30,7 @@ import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.fight.FreezeWorld;
|
||||
import de.steamwar.fightsystem.listener.BasicListener;
|
||||
import de.steamwar.fightsystem.listener.FightScoreboard;
|
||||
import de.steamwar.fightsystem.utils.BlockIdWrapper;
|
||||
import de.steamwar.fightsystem.utils.BountifulWrapper;
|
||||
import de.steamwar.fightsystem.utils.TechHider;
|
||||
import de.steamwar.fightsystem.utils.WorldOfColorWrapper;
|
||||
import de.steamwar.fightsystem.utils.*;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import de.steamwar.sql.Team;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
@ -112,6 +109,9 @@ public class PacketProcessor {
|
||||
packetDecoder[0xb4] = () -> pasteEmbeddedSchem(Fight.getRedTeam());
|
||||
packetDecoder[0xc0] = this::scoreboardTitle;
|
||||
packetDecoder[0xc1] = this::scoreboardData;
|
||||
packetDecoder[0xc2] = this::bossBar;
|
||||
packetDecoder[0xc3] = this::subtitle;
|
||||
packetDecoder[0xc4] = this::printWin;
|
||||
packetDecoder[0xef] = source::readUTF;
|
||||
packetDecoder[0xff] = this::tick;
|
||||
|
||||
@ -373,6 +373,28 @@ public class PacketProcessor {
|
||||
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(){
|
||||
REntity.dieAll();
|
||||
freezer.disable();
|
||||
|
@ -102,7 +102,7 @@ public interface Recorder {
|
||||
* BlockPacket (0x30) + pos int, byte, int + int BlockState
|
||||
* ParticlePacket (0x31) + double x, y, z + string particleType
|
||||
* 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
|
||||
* 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
|
||||
* RedEmbeddedSchemPacket (0xB4) + int redSchemId + gzipt NBT blob
|
||||
*
|
||||
* ScoreboardTitlePacket (0xC0) + String scoreboardTitle
|
||||
* ScoreboardDataPacket (0xC1) + String key + int value
|
||||
* DEPRECATED ScoreboardTitlePacket (0xC0) + String scoreboardTitle
|
||||
* 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
|
||||
* TickPacket (0xff)
|
||||
@ -265,12 +268,16 @@ public interface Recorder {
|
||||
write(embedId, schemId, buffer.toByteArray());
|
||||
}
|
||||
|
||||
default void scoreboardTitle(String title){
|
||||
write(0xc0, title);
|
||||
default void bossBar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
|
||||
write(0xc2, leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
|
||||
}
|
||||
|
||||
default void scoreboardData(String key, int value){
|
||||
write(0xc1, key, value);
|
||||
default void subtitle(String subtitle) {
|
||||
write(0xc3, subtitle);
|
||||
}
|
||||
|
||||
default void printWin(String title, String subtitle) {
|
||||
write(0xc4, title, subtitle);
|
||||
}
|
||||
|
||||
default void tick(){
|
||||
|
@ -57,5 +57,10 @@ public class BountifulWrapper {
|
||||
void setTeleportPacketPosition(Object packet, double x, double y, double z);
|
||||
void setSpawnPacketUUID(Object packet, UUID uuid);
|
||||
void setEquipmentPacketSlot(Object packet, String slot);
|
||||
|
||||
void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText);
|
||||
void removeFromBar(Player player, boolean leftBlueBar);
|
||||
void addToBar(Player player, boolean leftBlueBar);
|
||||
void broadcastBossbar();
|
||||
}
|
||||
}
|
||||
|
@ -24,31 +24,34 @@ 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 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.logging.Level;
|
||||
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<>();
|
||||
private static FightUI instance;
|
||||
public static FightUI getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final boolean blueNegZ = Config.blueNegZ();
|
||||
private final Map<Player, Boolean> hasBlueLeft = new HashMap<>();
|
||||
|
||||
public FightUI() {
|
||||
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20);
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void update() {
|
||||
@ -60,8 +63,6 @@ public class FightUI {
|
||||
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<10 ? "0" : "") + (timeLeft%60);
|
||||
@ -92,87 +93,62 @@ public class FightUI {
|
||||
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) % 360;
|
||||
if(headRot < 0)
|
||||
headRot += 360;
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
sendToPlayers();
|
||||
}
|
||||
|
||||
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;
|
||||
public boolean hasBlueLeft(Player player) {
|
||||
return hasBlueLeft.get(player);
|
||||
}
|
||||
|
||||
private void sendToPlayers() {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
float headRot = CraftbukkitWrapper.impl.headRotation(player) % 360;
|
||||
if(headRot < 0)
|
||||
headRot += 360;
|
||||
|
||||
//TODO: Rotation did not work
|
||||
boolean useNegZ = headRot >= 180;
|
||||
Boolean current = hasBlueLeft.get(player);
|
||||
boolean flip = current == null || useNegZ == (current == blueNegZ);
|
||||
|
||||
if(flip) {
|
||||
if(current != null)
|
||||
BountifulWrapper.impl.removeFromBar(player, current);
|
||||
current = (useNegZ == blueNegZ);
|
||||
BountifulWrapper.impl.addToBar(player, current);
|
||||
hasBlueLeft.put(player, current);
|
||||
}
|
||||
});
|
||||
BountifulWrapper.impl.broadcastBossbar();
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
p.sendTitle(title, winreason, 10, 80, 10);
|
||||
WorldOfColorWrapper.impl.sendTitle(p, title, winreason, 5, 40, 5);
|
||||
});
|
||||
}
|
||||
|
||||
@ -181,6 +157,9 @@ public class FightUI {
|
||||
return;
|
||||
|
||||
queue.add(message);
|
||||
GlobalRecorder.getInstance().subtitle(message);
|
||||
FightSystem.getPlugin().getLogger().log(Level.INFO, message);
|
||||
|
||||
if(!subtitleScheduled)
|
||||
printSubtitle();
|
||||
}
|
||||
@ -192,8 +171,7 @@ public class FightUI {
|
||||
}
|
||||
String message = queue.poll();
|
||||
|
||||
//TODO: Sendtitle so nicht in <1.10 verfügbar!
|
||||
Bukkit.getOnlinePlayers().forEach(p -> p.sendTitle("", message, 10, 80, 10));
|
||||
Bukkit.getOnlinePlayers().forEach(p -> WorldOfColorWrapper.impl.sendTitle(p, "", message, 5, 40, 5));
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightUI::printSubtitle, 100);
|
||||
subtitleScheduled = true;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
public class WorldOfColorWrapper {
|
||||
@ -36,5 +37,7 @@ public class WorldOfColorWrapper {
|
||||
boolean isInBlock(Arrow e);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Gibt es keine BarColor.Black?
Nein.