/* * Copyright (C) 2024 Minecon724 * Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file * in the project root for the full license text. */ package eu.m724.tweaks.ping; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.ComponentBuilder; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class PingCommands implements CommandExecutor { @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { if (command.getName().equals("ping")) { Player player = (Player) sender; BaseComponent[] component = new ComponentBuilder("Ping: ").color(ChatColor.GOLD) .append("%.2fms".formatted(PlayerPingStorage.getPingMillis(player))).color(ChatColor.AQUA) .create(); player.spigot().sendMessage(component); } return true; } }