added VaroRank
This commit is contained in:
@@ -81,3 +81,9 @@ shrinkingBorder:
|
|||||||
varoApi:
|
varoApi:
|
||||||
endpoint: "https://mhsl.eu/varo/api"
|
endpoint: "https://mhsl.eu/varo/api"
|
||||||
auth: "Basic xxx"
|
auth: "Basic xxx"
|
||||||
|
|
||||||
|
varoRank:
|
||||||
|
winners:
|
||||||
|
- 00000000-0000-0000-0000-000000000000
|
||||||
|
mostKills:
|
||||||
|
- 00000000-0000-0000-0000-000000000000
|
||||||
|
@@ -0,0 +1,60 @@
|
|||||||
|
package eu.mhsl.craftattack.spawn.craftattack.appliances.metaGameplay.varoRank;
|
||||||
|
|
||||||
|
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.displayName.DisplayName;
|
||||||
|
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class VaroRank extends Appliance implements DisplayName.Prefixed {
|
||||||
|
private List<UUID> winners = new ArrayList<>();
|
||||||
|
private List<UUID> mostKills = new ArrayList<>();
|
||||||
|
|
||||||
|
private final Component winnerBadge = Component.text("\uD83D\uDC51", NamedTextColor.YELLOW)
|
||||||
|
.hoverEvent(HoverEvent.showText(Component.text("Hat zusammen mit seinem Team Varo gewonnen")));
|
||||||
|
private final Component killBadge = Component.text("\uD83D\uDDE1", NamedTextColor.RED)
|
||||||
|
.hoverEvent(HoverEvent.showText(Component.text("Hat zusammen mit seinem Team die meisten Kills in Varo")));
|
||||||
|
|
||||||
|
public VaroRank() {
|
||||||
|
super("varoRank");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
Function<List<String>, List<UUID>> processUUIDs = list -> list.stream()
|
||||||
|
.map(String::trim)
|
||||||
|
.map(UUID::fromString)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
this.winners = processUUIDs.apply(this.localConfig().getStringList("winners"));
|
||||||
|
this.mostKills = processUUIDs.apply(this.localConfig().getStringList("mostKills"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable Component getNamePrefix(Player player) {
|
||||||
|
UUID playerId = player.getUniqueId();
|
||||||
|
|
||||||
|
boolean isWinner = this.winners.contains(playerId);
|
||||||
|
boolean hasMostKills = this.mostKills.contains(playerId);
|
||||||
|
|
||||||
|
if (!isWinner && !hasMostKills) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Component.text()
|
||||||
|
.color(NamedTextColor.GOLD)
|
||||||
|
.append(Component.text("["))
|
||||||
|
.append(isWinner ? this.winnerBadge : Component.empty())
|
||||||
|
.append(hasMostKills ? this.killBadge : Component.empty())
|
||||||
|
.append(Component.text("]"))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user