From a41d22d762bd8191f4d84290492515121441fc8d Mon Sep 17 00:00:00 2001 From: 4drian3d Date: Thu, 16 Jun 2022 22:16:31 +0000 Subject: [PATCH] misc: Replaced some Components with native MiniPlaceholders components --- .../proxy/AuthmePlaceholders.java | 16 +++++++--------- .../spigot/AuthmePlaceholders.java | 17 +++++++---------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthmePlaceholders.java b/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthmePlaceholders.java index 46c17d1..876c21b 100644 --- a/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthmePlaceholders.java +++ b/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthmePlaceholders.java @@ -3,27 +3,25 @@ package com.glyart.authmevelocity.proxy; import com.velocitypowered.api.proxy.Player; import me.dreamerzero.miniplaceholders.api.Expansion; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.minimessage.tag.Tag; +import static me.dreamerzero.miniplaceholders.api.utils.Components.*; + final class AuthmePlaceholders { private AuthmePlaceholders(){} - private static final Component TRUE = Component.text("true", NamedTextColor.GREEN); - private static final Component FALSE = Component.text("false", NamedTextColor.RED); - static Expansion getExpansion(AuthMeVelocityPlugin plugin){ return Expansion.builder("authme") .filter(Player.class) .audiencePlaceholder("is_logged", (aud, queue, ctx) -> - Tag.selfClosingInserting(plugin.getAPI().isLogged((Player)aud) ? TRUE : FALSE)) + Tag.selfClosingInserting(plugin.getAPI().isLogged((Player)aud) ? TRUE_COMPONENT : FALSE_COMPONENT)) .globalPlaceholder("is_player_logged", (queue, ctx) -> { String playerName = queue.popOr(() -> "you need to provide a player").value(); return Tag.selfClosingInserting( - plugin.getProxy().getPlayer(playerName).map(pl -> plugin.getAPI().isLogged(pl)).orElse(false) - ? TRUE - : FALSE); + plugin.getProxy().getPlayer(playerName).map(pl -> plugin.getAPI().isLogged(pl)).isPresent() + ? TRUE_COMPONENT + : FALSE_COMPONENT + ); }) .build(); } diff --git a/spigot/src/main/java/com/glyart/authmevelocity/spigot/AuthmePlaceholders.java b/spigot/src/main/java/com/glyart/authmevelocity/spigot/AuthmePlaceholders.java index 508fa9f..7cad587 100644 --- a/spigot/src/main/java/com/glyart/authmevelocity/spigot/AuthmePlaceholders.java +++ b/spigot/src/main/java/com/glyart/authmevelocity/spigot/AuthmePlaceholders.java @@ -5,30 +5,27 @@ import org.bukkit.entity.Player; import fr.xephi.authme.api.v3.AuthMeApi; import me.dreamerzero.miniplaceholders.api.Expansion; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.minimessage.tag.Tag; +import static me.dreamerzero.miniplaceholders.api.utils.Components.*; + final class AuthmePlaceholders { private AuthmePlaceholders(){} - private static final Component TRUE = Component.text("true", NamedTextColor.GREEN); - private static final Component FALSE = Component.text("false", NamedTextColor.RED); - static Expansion getExpansion(){ return Expansion.builder("authme") .audiencePlaceholder("is_logged", (aud, queue, ctx) -> Tag.selfClosingInserting(AuthMeApi.getInstance().isAuthenticated((Player)aud) - ? TRUE - : FALSE) + ? TRUE_COMPONENT + : FALSE_COMPONENT) ) .globalPlaceholder("is_player_logged", (queue, ctx) -> { String playerName = queue.popOr(() -> "you need to provide a player name").value(); Player player = Bukkit.getPlayer(playerName); - if(player == null) return Tag.selfClosingInserting(FALSE); + if(player == null) return Tag.selfClosingInserting(FALSE_COMPONENT); return Tag.selfClosingInserting(AuthMeApi.getInstance().isAuthenticated(player) - ? TRUE - : FALSE); + ? TRUE_COMPONENT + : FALSE_COMPONENT); }) .build(); }