Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
da68b5672f
Commit
e8e6b5fcfd
@ -41,7 +41,7 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
|
|||||||
|
|
||||||
public BountifulWrapper8() {
|
public BountifulWrapper8() {
|
||||||
EntityEnderDragon dragon = new EntityEnderDragon(null);
|
EntityEnderDragon dragon = new EntityEnderDragon(null);
|
||||||
dragon.setLocation(Config.ArenaRegion.centerX(), 0, Config.ArenaRegion.centerZ(), 0, 0);
|
dragon.setLocation(Config.ArenaRegion.centerX(), -100, Config.ArenaRegion.centerZ(), 0, 0);
|
||||||
this.spawnDragonId = dragon.getId();
|
this.spawnDragonId = dragon.getId();
|
||||||
this.spawnDragon = new PacketPlayOutSpawnEntityLiving(dragon);
|
this.spawnDragon = new PacketPlayOutSpawnEntityLiving(dragon);
|
||||||
}
|
}
|
||||||
@ -162,37 +162,33 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PacketPlayOutEntityMetadata leftBlue;
|
private final Map<FightUI.BossBarType, PacketPlayOutEntityMetadata> barMap = new HashMap<>();
|
||||||
private PacketPlayOutEntityMetadata leftRed;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
|
public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
|
||||||
DataWatcher leftBlueWatcher = new DataWatcher(null);
|
barMap.clear();
|
||||||
leftBlueWatcher.a(0, (byte) 0x20);
|
barMap.put(FightUI.BossBarType.BLUE_LEFT, createPacket(leftBlueProgress, leftBlueText));
|
||||||
leftBlueWatcher.a(6, (float)(leftBlueProgress * 200));
|
barMap.put(FightUI.BossBarType.RED_LEFT, createPacket(leftRedProgress, leftRedText));
|
||||||
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);
|
private PacketPlayOutEntityMetadata createPacket(double progress, String text) {
|
||||||
leftRedWatcher.a(0, (byte) 0x20);
|
DataWatcher watcher = new DataWatcher(null);
|
||||||
leftRedWatcher.a(6, (float)(leftRedProgress * 200));
|
watcher.a(0, (byte) 0x20);
|
||||||
leftRedWatcher.a(10, leftRedText);
|
watcher.a(2, text);
|
||||||
leftRedWatcher.a(2, leftRedText);
|
watcher.a(3, (byte) 1);
|
||||||
leftRedWatcher.a(11, (byte) 1);
|
watcher.a(4, (byte) 1);
|
||||||
leftRedWatcher.a(3, (byte) 1);
|
watcher.a(6, (float)(progress * 200));
|
||||||
leftRed = new PacketPlayOutEntityMetadata(spawnDragonId, leftRedWatcher, true);
|
//watcher.a(10, text);
|
||||||
|
//watcher.a(11, (byte) 1);
|
||||||
|
return new PacketPlayOutEntityMetadata(spawnDragonId, watcher, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeFromBar(Player player, boolean leftBlueBar) {
|
public void removeFromBar(Player player, FightUI.BossBarType type) {
|
||||||
// not used
|
// not used
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addToBar(Player player, boolean leftBlueBar) {
|
public void addToBar(Player player, FightUI.BossBarType type) {
|
||||||
// not used
|
// not used
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +204,7 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
|
|||||||
seesDragon.add(player);
|
seesDragon.add(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(FightUI.getInstance().hasBlueLeft(player) ? leftBlue : leftRed);
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(barMap.get(FightUI.getInstance().bossBarType(player)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,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 {
|
||||||
@ -51,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;
|
||||||
@ -197,24 +205,22 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BossBar leftBlue = Bukkit.createBossBar("Blue", BarColor.BLUE, BarStyle.SOLID);
|
private final Map<FightUI.BossBarType, BossBar> barMap = new HashMap<>();
|
||||||
private final BossBar leftRed = Bukkit.createBossBar("Red", BarColor.RED, BarStyle.SOLID);
|
|
||||||
@Override
|
@Override
|
||||||
public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
|
public void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText) {
|
||||||
setupTeamBar(Fight.getBlueTeam(), leftBlue, leftBlueProgress);
|
setupTeamBar(Fight.getBlueTeam(), barMap.get(FightUI.BossBarType.BLUE_LEFT), leftBlueProgress, leftBlueText);
|
||||||
setupTeamBar(Fight.getRedTeam(), leftRed, leftRedProgress);
|
setupTeamBar(Fight.getRedTeam(), barMap.get(FightUI.BossBarType.RED_LEFT), leftRedProgress, leftRedText);
|
||||||
|
|
||||||
leftBlue.setTitle(leftBlueText);
|
|
||||||
leftRed.setTitle(leftRedText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupTeamBar(FightTeam team, BossBar bar, double progress) {
|
private void setupTeamBar(FightTeam team, BossBar bar, double progress, String title) {
|
||||||
BarColor color = chat2bar(team.getColor());
|
BarColor color = chat2bar(team.getColor());
|
||||||
if(bar.getColor() != color)
|
if(bar.getColor() != color)
|
||||||
bar.setColor(color);
|
bar.setColor(color);
|
||||||
|
|
||||||
if(bar.getProgress() != progress)
|
if(bar.getProgress() != progress)
|
||||||
bar.setProgress(progress);
|
bar.setProgress(progress);
|
||||||
|
|
||||||
|
bar.setTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BarColor chat2bar(ChatColor color) {
|
private BarColor chat2bar(ChatColor color) {
|
||||||
@ -247,13 +253,13 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeFromBar(Player player, boolean leftBlueBar) {
|
public void removeFromBar(Player player, FightUI.BossBarType type) {
|
||||||
(leftBlueBar ? leftBlue : leftRed).removePlayer(player);
|
barMap.get(type).removePlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addToBar(Player player, boolean leftBlueBar) {
|
public void addToBar(Player player, FightUI.BossBarType type) {
|
||||||
(leftBlueBar ? leftBlue : leftRed).addPlayer(player);
|
barMap.get(type).addPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,8 +59,8 @@ public class BountifulWrapper {
|
|||||||
void setEquipmentPacketSlot(Object packet, String slot);
|
void setEquipmentPacketSlot(Object packet, String slot);
|
||||||
|
|
||||||
void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText);
|
void setBossbar(double leftBlueProgress, double leftRedProgress, String leftBlueText, String leftRedText);
|
||||||
void removeFromBar(Player player, boolean leftBlueBar);
|
void removeFromBar(Player player, FightUI.BossBarType type);
|
||||||
void addToBar(Player player, boolean leftBlueBar);
|
void addToBar(Player player, FightUI.BossBarType type);
|
||||||
void broadcastBossbar();
|
void broadcastBossbar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,11 +46,11 @@ public class FightUI {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final boolean blueNegZ = Config.blueNegZ();
|
private final Map<Player, BossBarType> currentBarType = new HashMap<>();
|
||||||
private final Map<Player, Boolean> hasBlueLeft = 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);
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,8 +61,11 @@ public class FightUI {
|
|||||||
double blueHearts = blue.getCurrentHearts();
|
double blueHearts = blue.getCurrentHearts();
|
||||||
double redHearts = red.getCurrentHearts();
|
double redHearts = red.getCurrentHearts();
|
||||||
double totalHearts = blueHearts + redHearts;
|
double totalHearts = blueHearts + redHearts;
|
||||||
if(totalHearts == 0.0)
|
if(redHearts == 0.0 || blueHearts == 0.0) {
|
||||||
|
blueHearts = 0.5;
|
||||||
|
redHearts = 0.5;
|
||||||
totalHearts = 1.0;
|
totalHearts = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
int timeLeft = StateDependentCountdown.getMainCountdown() != null ? StateDependentCountdown.getMainCountdown().getTimeLeft() : 0;
|
int timeLeft = StateDependentCountdown.getMainCountdown() != null ? StateDependentCountdown.getMainCountdown().getTimeLeft() : 0;
|
||||||
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);
|
||||||
@ -108,35 +111,55 @@ public class FightUI {
|
|||||||
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);
|
GlobalRecorder.getInstance().bossBar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
|
||||||
BountifulWrapper.impl.setBossbar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
|
BountifulWrapper.impl.setBossbar(leftBlueProgress, leftRedProgress, leftBlueText, leftRedText);
|
||||||
sendToPlayers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBlueLeft(Player player) {
|
public BossBarType bossBarType(Player player) {
|
||||||
return hasBlueLeft.get(player);
|
return currentBarType.get(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendToPlayers() {
|
private void sendToPlayers() {
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
float headRot = CraftbukkitWrapper.impl.headRotation(player) % 360;
|
BossBarType type = BossBarType.byAngle(CraftbukkitWrapper.impl.headRotation(player));
|
||||||
if(headRot < 0)
|
BossBarType current = currentBarType.get(player);
|
||||||
headRot += 360;
|
|
||||||
|
|
||||||
//TODO: Rotation did not work
|
if(type != current) {
|
||||||
boolean useNegZ = headRot >= 180;
|
|
||||||
Boolean current = hasBlueLeft.get(player);
|
|
||||||
boolean flip = current == null || useNegZ == (current == blueNegZ);
|
|
||||||
|
|
||||||
if(flip) {
|
|
||||||
if(current != null)
|
if(current != null)
|
||||||
BountifulWrapper.impl.removeFromBar(player, current);
|
BountifulWrapper.impl.removeFromBar(player, current);
|
||||||
current = (useNegZ == blueNegZ);
|
BountifulWrapper.impl.addToBar(player, type);
|
||||||
BountifulWrapper.impl.addToBar(player, current);
|
currentBarType.put(player, type);
|
||||||
hasBlueLeft.put(player, current);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
BountifulWrapper.impl.broadcastBossbar();
|
BountifulWrapper.impl.broadcastBossbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 final Queue<String> queue = new LinkedList<>();
|
||||||
private static boolean subtitleScheduled = false;
|
private static boolean subtitleScheduled = false;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren