Multiling (nur Multling) #294
@ -21,6 +21,7 @@ package de.steamwar.fightsystem.utils;
|
|||||||
|
|
||||||
import com.comphenix.tinyprotocol.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
|
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;
|
||||||
@ -150,49 +151,24 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<FightUI.BossBarType, PacketPlayOutEntityMetadata> barMap = new HashMap<>();
|
private final Set<Player> seesDragon = new HashSet<>();
|
||||||
|
private final PacketPlayOutSpawnEntityLiving spawnDragon;
|
||||||
|
private final int spawnDragonId;
|
||||||
@Override
|
@Override
|
||||||
public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
|
public void sendBar(Player player, FightTeam team, double progress, String text) {
|
||||||
barMap.clear();
|
seesDragon.removeIf(p -> !p.isOnline());
|
||||||
barMap.put(FightUI.BossBarType.BLUE_LEFT, createPacket(leftBlueProgress, leftBlueText));
|
|
||||||
barMap.put(FightUI.BossBarType.RED_LEFT, createPacket(leftRedProgress, leftRedText));
|
if(!seesDragon.contains(player)) {
|
||||||
}
|
((CraftPlayer)player).getHandle().playerConnection.sendPacket(spawnDragon);
|
||||||
|
seesDragon.add(player);
|
||||||
|
}
|
||||||
|
|
||||||
private PacketPlayOutEntityMetadata createPacket(double progress, String text) {
|
|
||||||
DataWatcher watcher = new DataWatcher(null);
|
DataWatcher watcher = new DataWatcher(null);
|
||||||
watcher.a(0, (byte) 0x20);
|
watcher.a(0, (byte) 0x20);
|
||||||
watcher.a(2, text);
|
watcher.a(2, text);
|
||||||
watcher.a(3, (byte) 1);
|
watcher.a(3, (byte) 1);
|
||||||
watcher.a(4, (byte) 1);
|
watcher.a(4, (byte) 1);
|
||||||
watcher.a(6, (float)(progress * 200));
|
watcher.a(6, (float)(progress * 200));
|
||||||
//watcher.a(10, text);
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(spawnDragonId, watcher, true));
|
||||||
//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)));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
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.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;
|
||||||
@ -51,12 +50,6 @@ 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,14 +186,15 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<FightUI.BossBarType, BossBar> barMap = new HashMap<>();
|
private final Map<Player, BossBar> barMap = new HashMap<>();
|
||||||
@Override
|
@Override
|
||||||
public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
|
public void sendBar(Player player, FightTeam team, double progress, String text) {
|
||||||
setupTeamBar(Fight.getBlueTeam(), barMap.get(FightUI.BossBarType.BLUE_LEFT), leftBlueProgress, leftBlueText);
|
barMap.keySet().removeIf(p -> !p.isOnline());
|
||||||
setupTeamBar(Fight.getRedTeam(), barMap.get(FightUI.BossBarType.RED_LEFT), leftRedProgress, leftRedText);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupTeamBar(FightTeam team, BossBar bar, double progress, String title) {
|
if(!barMap.containsKey(player))
|
||||||
|
barMap.put(player, Bukkit.createBossBar(player.getName(), BarColor.WHITE, BarStyle.SOLID));
|
||||||
|
|
||||||
|
BossBar bar = barMap.get(player);
|
||||||
BarColor color = chat2bar(team.getColor());
|
BarColor color = chat2bar(team.getColor());
|
||||||
if(bar.getColor() != color)
|
if(bar.getColor() != color)
|
||||||
bar.setColor(color);
|
bar.setColor(color);
|
||||||
@ -208,7 +202,8 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
|||||||
if(bar.getProgress() != progress)
|
if(bar.getProgress() != progress)
|
||||||
bar.setProgress(progress);
|
bar.setProgress(progress);
|
||||||
|
|
||||||
bar.setTitle(title);
|
if(!bar.getTitle().equals(text))
|
||||||
|
bar.setTitle(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BarColor chat2bar(ChatColor color) {
|
private BarColor chat2bar(ChatColor color) {
|
||||||
@ -239,19 +234,4 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
|||||||
return BarColor.WHITE;
|
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -184,6 +184,20 @@ UI_ELO=
|
|||||||
UI_WIN={0}Sieg {1}
|
UI_WIN={0}Sieg {1}
|
||||||
UI_DRAW=§7Unentschieden
|
UI_DRAW=§7Unentschieden
|
||||||
|
|
||||||
|
BAR_PRE_LEADER=§7Warten auf Teamleader
|
||||||
|
BAR_PRE_SCHEM={1} §7Schemauswahl {0} {2}
|
||||||
|
BAR_PREPARE={1} {3} §7Vorbereitung {0} {4} {2}
|
||||||
|
BAR_PRE_RUNNING={1} {3} §7Kampfbeginn in {0} {4} {2}
|
||||||
|
BAR_RUNNING0={1} {3} lW {0} rW {4} {2}
|
||||||
|
BAR_RUNNING1={1} {3} {5} {0} {6} {4} {2}
|
||||||
|
BAR_RUNNING2={1} {3} {5} {7} {0} {6} {8} {4} {2}
|
||||||
|
BAR_RUNNING3={1} {3} {5} {7} {9} {0} {6} {8} {10} {4} {2}
|
||||||
|
BAR_SPECTATE={1} §7Kampf vorbei {0} {2}
|
||||||
|
BAR_POINTS={0} §8Punkte
|
||||||
|
BAR_PERCENT={0}§8%
|
||||||
|
BAR_CANNONS={0} §8Kanonen
|
||||||
|
BAR_WATER={0} §8Wasser
|
||||||
|
|
||||||
|
|
||||||
# Winconditions
|
# Winconditions
|
||||||
HELLS_BELLS_COUNTDOWN=bis die Bomben fallen
|
HELLS_BELLS_COUNTDOWN=bis die Bomben fallen
|
||||||
|
@ -120,6 +120,7 @@ public class PacketProcessor {
|
|||||||
packetDecoder[0xc4] = this::printWin;
|
packetDecoder[0xc4] = this::printWin;
|
||||||
packetDecoder[0xc5] = this::messageSubtitle;
|
packetDecoder[0xc5] = this::messageSubtitle;
|
||||||
packetDecoder[0xc6] = this::winMessage;
|
packetDecoder[0xc6] = this::winMessage;
|
||||||
|
packetDecoder[0xc7] = this::bossBarMessage;
|
||||||
packetDecoder[0xef] = source::readUTF;
|
packetDecoder[0xef] = source::readUTF;
|
||||||
packetDecoder[0xff] = this::tick;
|
packetDecoder[0xff] = this::tick;
|
||||||
|
|
||||||
@ -421,6 +422,15 @@ public class PacketProcessor {
|
|||||||
FightUI.getInstance().setBossbar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
|
FightUI.getInstance().setBossbar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void bossBarMessage() throws IOException {
|
||||||
|
double leftBlueProgress = source.readDouble();
|
||||||
|
double leftRedProgress = source.readDouble();
|
||||||
|
Message leftBlueText = readMessage();
|
||||||
|
Message leftRedText = readMessage();
|
||||||
|
|
||||||
|
FightUI.getInstance().setBossbar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
|
||||||
|
}
|
||||||
|
|
||||||
private void subtitle() throws IOException {
|
private void subtitle() throws IOException {
|
||||||
String subtitle = source.readUTF();
|
String subtitle = source.readUTF();
|
||||||
|
|
||||||
@ -534,6 +544,9 @@ public class PacketProcessor {
|
|||||||
case 0x07:
|
case 0x07:
|
||||||
params.add(source.readUTF());
|
params.add(source.readUTF());
|
||||||
break;
|
break;
|
||||||
|
case 0x08:
|
||||||
|
params.add(readMessage());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IOException("Unknown message param type " + type);
|
throw new IOException("Unknown message param type " + type);
|
||||||
}
|
}
|
||||||
|
@ -123,11 +123,12 @@ public interface Recorder {
|
|||||||
*
|
*
|
||||||
* DEPRECATED ScoreboardTitlePacket (0xc0) + String scoreboardTitle
|
* DEPRECATED ScoreboardTitlePacket (0xc0) + String scoreboardTitle
|
||||||
* DEPRECATED ScoreboardDataPacket (0xc1) + String key + int value
|
* DEPRECATED ScoreboardDataPacket (0xc1) + String key + int value
|
||||||
* BossBarPacket (0xc2) + double leftBlueProgress, leftRedProgress + String leftBlueText, leftRedText
|
* DEPRECATED BossBarPacket (0xc2) + double leftBlueProgress, leftRedProgress + String leftBlueText, leftRedText
|
||||||
* DEPRECATED SubtitlePacket (0xc3) + String subtitle
|
* DEPRECATED SubtitlePacket (0xc3) + String subtitle
|
||||||
* DEPRECATED PrintWinPacket (0xc4) + String title, subtitle
|
* DEPRECATED PrintWinPacket (0xc4) + String title, subtitle
|
||||||
* SubtitlePacket (0xc5) + Message
|
* SubtitlePacket (0xc5) + Message
|
||||||
* WinPacket (0xc6) + byte team + Message subtitle
|
* WinPacket (0xc6) + byte team + Message subtitle
|
||||||
|
* BossBarPacket (0xc7) + double leftBlueProgress, leftRedProgress + Message leftBlueText, leftRedText
|
||||||
*
|
*
|
||||||
* CommentPacket (0xfe) + String comment
|
* CommentPacket (0xfe) + String comment
|
||||||
* TickPacket (0xff)
|
* TickPacket (0xff)
|
||||||
@ -142,6 +143,7 @@ public interface Recorder {
|
|||||||
* 0x05: float following
|
* 0x05: float following
|
||||||
* 0x06: double following
|
* 0x06: double following
|
||||||
* 0x07: String following
|
* 0x07: String following
|
||||||
|
* 0x08: Message following
|
||||||
* */
|
* */
|
||||||
|
|
||||||
default void playerJoins(Player p){
|
default void playerJoins(Player p){
|
||||||
@ -292,8 +294,8 @@ public interface Recorder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default void bossBar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
|
default void bossBar(double leftBlueProgress, double leftRedProgress, Message leftBlueText, Message leftRedText) {
|
||||||
write(0xc2, leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
|
write(0xc7, leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void subtitle(Message subtitle) {
|
default void subtitle(Message subtitle) {
|
||||||
@ -366,6 +368,8 @@ public interface Recorder {
|
|||||||
stream.writeByte(0x06);
|
stream.writeByte(0x06);
|
||||||
else if(o instanceof String)
|
else if(o instanceof String)
|
||||||
stream.writeByte(0x07);
|
stream.writeByte(0x07);
|
||||||
|
else if(o instanceof Message)
|
||||||
|
stream.writeByte(0x08);
|
||||||
else
|
else
|
||||||
throw new SecurityException("Undefined message serialization for: " + o.getClass().getName());
|
throw new SecurityException("Undefined message serialization for: " + o.getClass().getName());
|
||||||
writeObject(stream, o);
|
writeObject(stream, o);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.VersionDependent;
|
import de.steamwar.fightsystem.VersionDependent;
|
||||||
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -54,9 +55,6 @@ public class BountifulWrapper {
|
|||||||
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 sendBar(Player player, FightTeam team, double progress, String text);
|
||||||
void removeFromBar(Player player, FightUI.BossBarType type);
|
|
||||||
void addToBar(Player player, FightUI.BossBarType type);
|
|
||||||
void broadcastBossbar();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,9 @@ import de.steamwar.fightsystem.winconditions.Wincondition;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -47,8 +47,6 @@ public class FightUI {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<Player, BossBarType> currentBarType = new HashMap<>();
|
|
||||||
|
|
||||||
public FightUI() {
|
public FightUI() {
|
||||||
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20);
|
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20);
|
||||||
new StateDependentTask(ArenaMode.All, FightState.All, this::sendToPlayers, 5, 5);
|
new StateDependentTask(ArenaMode.All, FightState.All, this::sendToPlayers, 5, 5);
|
||||||
@ -73,29 +71,41 @@ public class FightUI {
|
|||||||
String time = "§7" + (timeLeft/60) + "§8:§7" + (timeLeft%60<10 ? "0" : "") + (timeLeft%60);
|
String time = "§7" + (timeLeft/60) + "§8:§7" + (timeLeft%60<10 ? "0" : "") + (timeLeft%60);
|
||||||
String bluePlayers = blue.getPrefix() + blue.getAlivePlayers() + "§8/§7" + blue.getPlayerCount();
|
String bluePlayers = blue.getPrefix() + blue.getAlivePlayers() + "§8/§7" + blue.getPlayerCount();
|
||||||
String redPlayers = red.getPrefix() + red.getAlivePlayers() + "§8/§7" + red.getPlayerCount();
|
String redPlayers = red.getPrefix() + red.getAlivePlayers() + "§8/§7" + red.getPlayerCount();
|
||||||
String redAdditional = Wincondition.getPrintableWinconditions().stream().map(w -> w.getDisplay(red)).collect(Collectors.joining(" "));
|
List<Message> redAdditional = Wincondition.getPrintableWinconditions().stream().map(w -> w.getDisplay(red)).collect(Collectors.toList());
|
||||||
String blueAdditional = Wincondition.getPrintableWinconditions().stream().map(w -> w.getDisplay(blue)).collect(Collectors.joining(" "));
|
List<Message> blueAdditional = Wincondition.getPrintableWinconditions().stream().map(w -> w.getDisplay(blue)).collect(Collectors.toList());
|
||||||
|
|
||||||
Generator generator;
|
Generator generator;
|
||||||
switch(FightState.getFightState()){
|
switch(FightState.getFightState()){
|
||||||
case PRE_LEADER_SETUP:
|
case PRE_LEADER_SETUP:
|
||||||
generator = (l, r, lP, rP, lW, rW) -> "§7Warten auf Teamleader";
|
generator = (l, r, lP, rP, lW, rW) -> new Message("BAR_PRE_LEADER");
|
||||||
break;
|
break;
|
||||||
case PRE_SCHEM_SETUP:
|
case PRE_SCHEM_SETUP:
|
||||||
generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " §7Schemauswahl " + time + " " + r.getColoredName();
|
generator = (l, r, lP, rP, lW, rW) -> new Message("BAR_PRE_SCHEM", time, l.getColoredName(), r.getColoredName());
|
||||||
break;
|
break;
|
||||||
case POST_SCHEM_SETUP:
|
case POST_SCHEM_SETUP:
|
||||||
generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " " + lP + " §7Vorbereitung " + time + " " + rP + " " + r.getColoredName();
|
generator = (l, r, lP, rP, lW, rW) -> new Message("BAR_PREPARE", time, l.getColoredName(), r.getColoredName(), lP, rP);
|
||||||
break;
|
break;
|
||||||
case PRE_RUNNING:
|
case PRE_RUNNING:
|
||||||
generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " " + lP + " §7Kampfbeginn in " + time + " " + rP + " " + r.getColoredName();
|
generator = (l, r, lP, rP, lW, rW) -> new Message("BAR_PRE_RUNNING", time, l.getColoredName(), r.getColoredName(), lP, rP);
|
||||||
break;
|
break;
|
||||||
case RUNNING:
|
case RUNNING:
|
||||||
generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " " + lP + " " + lW + " " + time + " " + rW + " " + rP + " " + r.getColoredName();
|
generator = (l, r, lP, rP, lW, rW) -> {
|
||||||
|
List<Object> params = new ArrayList<>();
|
||||||
|
params.add(time);
|
||||||
|
params.add(l.getColoredName());
|
||||||
|
params.add(r.getColoredName());
|
||||||
|
params.add(lP);
|
||||||
|
params.add(rP);
|
||||||
|
for(int i = 0; i < lW.size(); i++) {
|
||||||
|
params.add(lW.get(i));
|
||||||
|
params.add(rW.get(i));
|
||||||
|
}
|
||||||
|
return new Message("BAR_RUNNING" + lW.size(), params.toArray());
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
case SPECTATE:
|
case SPECTATE:
|
||||||
default:
|
default:
|
||||||
generator = (l, r, lP, rP, lW, rW) -> l.getColoredName() + " §7Kampf vorbei " + time + " " + r.getColoredName();
|
generator = (l, r, lP, rP, lW, rW) -> new Message("BAR_SPECTATE", time, l.getColoredName(), r.getColoredName());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,31 +117,35 @@ public class FightUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private interface Generator {
|
private interface Generator {
|
||||||
String gen(FightTeam l, FightTeam r, String lPlayers, String rPlayers, String lWinconditions, String rWinconditions);
|
Message gen(FightTeam l, FightTeam r, String lPlayers, String rPlayers, List<Message> lWinconditions, List<Message> rWinconditions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
|
public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
|
||||||
GlobalRecorder.getInstance().bossBar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
|
setBossbar(leftBlueProgress, leftRedProgress, new Message("OLD_STRING", leftBlueText), new Message("OLD_STRING", leftRedText));
|
||||||
BountifulWrapper.impl.setBossbar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BossBarType bossBarType(Player player) {
|
public void setBossbar(double leftBlueProgress, double leftRedProgress, Message leftBlueText, Message leftRedText) {
|
||||||
return currentBarType.get(player);
|
GlobalRecorder.getInstance().bossBar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
|
||||||
|
BossBarType.BLUE_LEFT.progress = leftBlueProgress;
|
||||||
|
BossBarType.RED_LEFT.progress = leftRedProgress;
|
||||||
|
BossBarType.BLUE_LEFT.text = leftBlueText;
|
||||||
|
BossBarType.RED_LEFT.text = leftRedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendToPlayers() {
|
private void sendToPlayers() {
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
BossBarType type = BossBarType.byAngle(CraftbukkitWrapper.impl.headRotation(player));
|
BossBarType bar = BossBarType.byAngle(CraftbukkitWrapper.impl.headRotation(player));
|
||||||
BossBarType current = currentBarType.get(player);
|
|
||||||
|
|
||||||
if(type != current) {
|
Object[] params = bar.text.getParams().clone();
|
||||||
if(current != null)
|
for(int i = 0; i < params.length; i++) {
|
||||||
BountifulWrapper.impl.removeFromBar(player, current);
|
if(params[i] instanceof Message) {
|
||||||
BountifulWrapper.impl.addToBar(player, type);
|
Message msg = (Message) params[i];
|
||||||
currentBarType.put(player, type);
|
params[i] = FightSystem.getMessage().parse(msg.getMsg(), player, msg.getParams());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BountifulWrapper.impl.sendBar(player, bar.team, bar.progress, FightSystem.getMessage().parse(bar.text.getMsg(), player, params));
|
||||||
});
|
});
|
||||||
BountifulWrapper.impl.broadcastBossbar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tpsWatcher() {
|
private void tpsWatcher() {
|
||||||
@ -141,15 +155,20 @@ public class FightUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum BossBarType {
|
public enum BossBarType {
|
||||||
BLUE_LEFT(345, 165),
|
BLUE_LEFT(Fight.getBlueTeam(), 345, 165),
|
||||||
RED_LEFT(165, 345);
|
RED_LEFT(Fight.getRedTeam(), 165, 345);
|
||||||
|
|
||||||
private static final boolean BLUE_NEG_Z = Config.blueNegZ();
|
private static final boolean BLUE_NEG_Z = Config.blueNegZ();
|
||||||
|
|
||||||
private final double minAngle;
|
private final double minAngle;
|
||||||
private final double maxAngle;
|
private final double maxAngle;
|
||||||
|
|
||||||
BossBarType(double minAngle, double maxAngle) {
|
private final FightTeam team;
|
||||||
|
private double progress;
|
||||||
|
private Message text;
|
||||||
|
|
||||||
|
BossBarType(FightTeam team, double minAngle, double maxAngle) {
|
||||||
|
this.team = team;
|
||||||
this.minAngle = minAngle;
|
this.minAngle = minAngle;
|
||||||
this.maxAngle = maxAngle;
|
this.maxAngle = maxAngle;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
package de.steamwar.fightsystem.winconditions;
|
package de.steamwar.fightsystem.winconditions;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
|
|
||||||
public interface PrintableWincondition {
|
public interface PrintableWincondition {
|
||||||
String getDisplay(FightTeam team);
|
Message getDisplay(FightTeam team);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ 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.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
@ -62,8 +63,8 @@ public class WinconditionPercentSystem extends Wincondition implements Listener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplay(FightTeam team) {
|
public Message getDisplay(FightTeam team) {
|
||||||
return team.getPrefix() + (Math.round(100.0 * getPercent(team)) / 100.0) + "§8%";
|
return new Message("BAR_PERCENT", team.getPrefix() + (Math.round(100.0 * getPercent(team)) / 100.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,6 +27,7 @@ import de.steamwar.fightsystem.states.FightState;
|
|||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
import de.steamwar.fightsystem.states.StateDependentCountdown;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -104,8 +105,8 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplay(FightTeam team) {
|
public Message getDisplay(FightTeam team) {
|
||||||
return team.getPrefix() + teamMap.get(team).getPoints() + " §8Punkte";
|
return new Message("BAR_POINTS", team.getPrefix() + teamMap.get(team).getPoints());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TeamPoints {
|
private class TeamPoints {
|
||||||
|
@ -24,6 +24,7 @@ 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.Message;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -55,8 +56,8 @@ public class WinconditionPumpkinTechKO extends Wincondition implements Printable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplay(FightTeam team) {
|
public Message getDisplay(FightTeam team) {
|
||||||
return team.getPrefix() + teamMap.get(team).pumpkins + " §8Kanonen";
|
return new Message("BAR_CANNONS", team.getPrefix() + teamMap.get(team).pumpkins);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TeamPumpkin {
|
private class TeamPumpkin {
|
||||||
|
@ -25,6 +25,7 @@ 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.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -63,8 +64,8 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplay(FightTeam team) {
|
public Message getDisplay(FightTeam team) {
|
||||||
return team.getPrefix() + (Math.round(100.0 * getPercent(team)) / 100.0) + "§8%";
|
return new Message("BAR_PERCENT", team.getPrefix() + (Math.round(100.0 * getPercent(team)) / 100.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TeamPercent extends StateDependent {
|
public static class TeamPercent extends StateDependent {
|
||||||
|
@ -25,6 +25,7 @@ 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.FlatteningWrapper;
|
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||||
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
@ -53,8 +54,8 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplay(FightTeam team) {
|
public Message getDisplay(FightTeam team) {
|
||||||
return team.getPrefix() + teamMap.get(team).water + " §8Wasser";
|
return new Message("BAR_WATER", team.getPrefix() + teamMap.get(team).water);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TeamWater {
|
private class TeamWater {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren