tweaks724/src/main/java/eu/m724/tweaks/ping/PingCommands.java
Minecon724 b23f773198
All checks were successful
/ deploy (push) Successful in 5m3s
New ping checker
2024-11-30 20:13:22 +01:00

30 lines
1.1 KiB
Java

/*
* 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;
}
}