Compare commits
2 commits
743072d8e3
...
32c3801acf
Author | SHA1 | Date | |
---|---|---|---|
32c3801acf | |||
9b214c7111 |
2 changed files with 26 additions and 7 deletions
|
@ -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;
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Loading…
Reference in a new issue