Compare commits

...

2 commits

2 changed files with 26 additions and 7 deletions

View file

@ -33,6 +33,8 @@ public class FindAltsCommand extends Command {
public Component execute(CommandContext context) throws Exception { public Component execute(CommandContext context) throws Exception {
final Bot bot = context.bot; final Bot bot = context.bot;
boolean argumentIsIP = true;
String targetIP; String targetIP;
final String player = context.getString(true, true); final String player = context.getString(true, true);
@ -41,6 +43,8 @@ public class FindAltsCommand extends Command {
if (playerEntry == null) targetIP = player; if (playerEntry == null) targetIP = player;
else { else {
argumentIsIP = false;
final CompletableFuture<String> future = bot.players.getPlayerIP(playerEntry); final CompletableFuture<String> future = bot.players.getPlayerIP(playerEntry);
targetIP = future.get(5, TimeUnit.SECONDS); targetIP = future.get(5, TimeUnit.SECONDS);
@ -67,9 +71,12 @@ public class FindAltsCommand extends Command {
.map(Map.Entry::getKey); .map(Map.Entry::getKey);
Component component = Component Component component = Component
.translatable("Possible alts for the player %s:") .translatable("Possible alts for the %s %s:")
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
.arguments(Component.text(player).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))) .arguments(
Component.text(argumentIsIP ? "IP" : "player"),
Component.text(player).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
)
.appendNewline(); .appendNewline();
int i = 0; int i = 0;

View file

@ -34,14 +34,26 @@ public class SeenCommand extends Command {
final String player = context.getString(true, true); final String player = context.getString(true, true);
boolean online = false;
Component onlineComponents = Component.empty();
for (Bot eachBot : bot.bots) { for (Bot eachBot : bot.bots) {
if (eachBot.players.getEntry(player) != null) return Component.empty() if (eachBot.players.getEntry(player) != null) {
.append(Component.text(player)) online = true;
.append(Component.text(" is currently online on "))
.append(Component.text(eachBot.host + ":" + eachBot.port)) onlineComponents = onlineComponents.append(
.color(NamedTextColor.RED); Component.empty()
.append(Component.text(player))
.append(Component.text(" is currently online on "))
.append(Component.text(eachBot.host + ":" + eachBot.port))
.color(NamedTextColor.RED)
);
}
} }
if (online) return onlineComponents;
final JsonElement playerElement = PlayersPersistentDataPlugin.playersObject.get(player); final JsonElement playerElement = PlayersPersistentDataPlugin.playersObject.get(player);
if (playerElement == null) throw new CommandException(Component.translatable( if (playerElement == null) throw new CommandException(Component.translatable(
"%s was never seen", "%s was never seen",