refactor: don't request more ChomeNS Bot command suggestions when we already got one (it can still be forced through eval)

This commit is contained in:
Chayapak Supasakul 2025-01-14 19:42:48 +07:00
parent c0d010acf1
commit af509b8455
Signed by: ChomeNS
SSH key fingerprint: SHA256:0YoxhdyXsgbc0nfeB2N6FYE60mxMU7DS4uCUMaw2mvA

View file

@ -22,6 +22,8 @@ public class ChomeNSBotCommandSuggestions implements Listener {
private final MinecraftClient client;
public boolean receivedSuggestions = false; // can be set through eval
public List<ChomeNSBotCommand> commands = new ArrayList<>();
public ChomeNSBotCommandSuggestions (MinecraftClient client) {
@ -33,7 +35,9 @@ public class ChomeNSBotCommandSuggestions implements Listener {
public void init () {}
@Override
public void coreMoved () { forceRequest(); }
public void coreMoved () {
if (!receivedSuggestions) forceRequest();
}
public void forceRequest () {
final ClientPlayerEntity player = client.player;
@ -85,6 +89,8 @@ public class ChomeNSBotCommandSuggestions implements Listener {
}
)
.toList();
receivedSuggestions = true;
} catch (Exception ignored) {}
}
}