Skip to content

Commit

Permalink
Added lunar ping command
Browse files Browse the repository at this point in the history
  • Loading branch information
Devlrxxh committed Mar 30, 2024
1 parent 083df2d commit de08161
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/me/lrxh/practice/commands/user/PingCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import me.lrxh.practice.Locale;
import me.lrxh.practice.match.Match;
import me.lrxh.practice.profile.Profile;
import me.lrxh.practice.util.BukkitReflection;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
Expand All @@ -13,13 +15,20 @@ public class PingCommand extends BaseCommand {

@Default
public void ping(Player player) {
player.sendMessage(Locale.PING_YOUR.format(player, BukkitReflection.getPing(player)));
Profile profile = Profile.getProfiles().get(player.getUniqueId());

if(profile.getMatch() != null){
Match match = profile.getMatch();
player.sendMessage(Locale.PING_YOUR.format(player, BukkitReflection.getPing(player)));
player.sendMessage(Locale.PING_OTHERS.format(player, BukkitReflection.getPing(match.getOpponent(player)), match.getOpponent(player).getName()));
}else {
player.sendMessage(Locale.PING_YOUR.format(player, BukkitReflection.getPing(player)));
}
}

@Default
@Syntax("<name>")
@CommandCompletion("@names")
public void pingOthers(Player player, String otherPlayer) {
player.sendMessage(Locale.PING_OTHERS.format(player, BukkitReflection.getPing(Bukkit.getPlayer(otherPlayer)), Bukkit.getPlayer(otherPlayer).getName()));
}
}

0 comments on commit de08161

Please sign in to comment.