SteamWar/BungeeCore
Archiviert
13
2

Update Title style
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2023-05-13 14:38:42 +02:00
Ursprung 7cd4a5bac8
Commit 9af07f821d

Datei anzeigen

@ -35,7 +35,7 @@ import net.md_5.bungee.api.scheduler.TaskScheduler;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level; import java.util.function.IntFunction;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class FightEndsHandler extends PacketHandler { public class FightEndsHandler extends PacketHandler {
@ -127,46 +127,41 @@ public class FightEndsHandler extends PacketHandler {
UserElo.setElo(player, gameMode, playerElo); UserElo.setElo(player, gameMode, playerElo);
int newProgression = UserElo.getProgression(player, gameMode); int newProgression = UserElo.getProgression(player, gameMode);
BaseComponent[] eloGainComponent = TextComponent.fromLegacyText(((eloGain > 0) ? "§a+" : (eloGain == 0 ? "§7" : "§c")) + eloGain); animate(player(player), UserElo.toEmblem(oldProgression).trim(), UserElo.toEmblem(newProgression).trim(), (oldProgression < newProgression) ? "§a" : "§c", eloGain);
if (oldProgression == newProgression) {
send(player(player), UserElo.toEmblem(oldProgression).trim(), eloGainComponent);
continue;
}
animate(player(player), UserElo.toEmblem(oldProgression).trim(), UserElo.toEmblem(newProgression).trim(), (oldProgression < newProgression) ? "§a" : "§c", eloGainComponent);
} }
} }
private void animate(ProxiedPlayer player, String oldEmblem, String newEmblem, String arrowColor, BaseComponent[] eloGainComponent) { private void animate(ProxiedPlayer player, String oldEmblem, String newEmblem, String arrowColor, int eloGain) {
String finalOldEmblem = (oldEmblem.isEmpty() ? "/" : oldEmblem); String finalOldEmblem = (oldEmblem.isEmpty() ? "/" : oldEmblem).trim();
String finalNewEmblem = (newEmblem.isEmpty() ? "/" : newEmblem); String finalNewEmblem = (newEmblem.isEmpty() ? "/" : newEmblem).trim();
IntFunction<String> getRankup = i -> {
if (oldEmblem.equals(newEmblem)) return "§8" + finalOldEmblem;
if (i < 8) return "§8" + finalOldEmblem;
if (i < 16) return "§8" + finalOldEmblem + arrowColor + " >";
if (i < 24) return "§8" + finalOldEmblem + arrowColor + " >>";
if (i < 32) return "§8" + finalOldEmblem + arrowColor + " >>>";
return "§8" + finalOldEmblem + arrowColor + " >>> §8" + finalNewEmblem;
};
String color = ((eloGain > 0) ? "§a+" : (eloGain == 0 ? "§7" : "§c"));
TaskScheduler scheduler = ProxyServer.getInstance().getScheduler(); TaskScheduler scheduler = ProxyServer.getInstance().getScheduler();
scheduler.schedule(BungeeCore.get(), () -> { double eloStep = eloGain / 40.0;
send(player, "§8" + finalOldEmblem, eloGainComponent); for (int i = 0; i < 40; i++) {
}, 0, TimeUnit.SECONDS); BaseComponent[] eloGainComponent = TextComponent.fromLegacyText(color + (int) (eloStep * (i + 1)));
scheduler.schedule(BungeeCore.get(), () -> { int finalI = i;
send(player, "§8" + finalOldEmblem + arrowColor + " >", eloGainComponent); scheduler.schedule(BungeeCore.get(), () -> {
}, 500, TimeUnit.MILLISECONDS); if (player == null) return;
scheduler.schedule(BungeeCore.get(), () -> { if (!player.isConnected()) return;
send(player, "§8" + finalOldEmblem + arrowColor + " >>", eloGainComponent); Title title = new BungeeTitle().title(TextComponent.fromLegacyText(getRankup.apply(finalI)))
}, 1000, TimeUnit.MILLISECONDS); .subTitle(eloGainComponent)
scheduler.schedule(BungeeCore.get(), () -> { .fadeIn(finalI == 0 ? 5 : 0)
send(player, "§8" + finalOldEmblem + arrowColor + " >>>", eloGainComponent); .stay(40)
}, 1500, TimeUnit.MILLISECONDS); .fadeOut(finalI == 39 ? 5 : 0);
scheduler.schedule(BungeeCore.get(), () -> { title.send(player);
send(player, "§8" + finalOldEmblem + arrowColor + " >>> §8" + finalNewEmblem, eloGainComponent); }, i * 50L, TimeUnit.MILLISECONDS);
}, 2000, TimeUnit.MILLISECONDS); }
}
private void send(ProxiedPlayer player, String text, BaseComponent[] eloGainComponent) {
if (player == null) return;
if (!player.isConnected()) return;
Title title = new BungeeTitle().title(TextComponent.fromLegacyText(text))
.subTitle(eloGainComponent)
.fadeIn(5)
.stay(40)
.fadeOut(5);
title.send(player);
} }
private ProxiedPlayer player(int userId) { private ProxiedPlayer player(int userId) {