From 65a1295da7c181d6f4064512b3db34e6c7cbf612 Mon Sep 17 00:00:00 2001 From: Cyborger1 <45152844+Cyborger1@users.noreply.github.com> Date: Wed, 19 Oct 2022 14:39:50 -0400 Subject: [PATCH] Tweak null confidence case to allow populating feedback label list (#166) --- .../botdetector/http/BotDetectorClient.java | 4 ++-- .../com/botdetector/ui/BotDetectorPanel.java | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/botdetector/http/BotDetectorClient.java b/src/main/java/com/botdetector/http/BotDetectorClient.java index ea8fa50d..ec7a6865 100644 --- a/src/main/java/com/botdetector/http/BotDetectorClient.java +++ b/src/main/java/com/botdetector/http/BotDetectorClient.java @@ -359,13 +359,13 @@ public void onResponse(Call call, Response response) /** * Requests a bot prediction for the given {@code playerName}. - * Breakdown will not be provided in special cases (see {@link BotDetectorClient#requestPrediction(String, boolean)}). + * Breakdown will be provided by default in special cases (see {@link BotDetectorClient#requestPrediction(String, boolean)}). * @param playerName The player name to predict. * @return A future that will eventually return the player's bot prediction. */ public CompletableFuture requestPrediction(String playerName) { - return requestPrediction(playerName, false); + return requestPrediction(playerName, true); } /** diff --git a/src/main/java/com/botdetector/ui/BotDetectorPanel.java b/src/main/java/com/botdetector/ui/BotDetectorPanel.java index 30a8e057..8f05af7b 100644 --- a/src/main/java/com/botdetector/ui/BotDetectorPanel.java +++ b/src/main/java/com/botdetector/ui/BotDetectorPanel.java @@ -1103,8 +1103,7 @@ public void setPrediction(Prediction pred, PlayerSighting sighting) feedbackLabelComboBox.setSelectedItem(UNSURE_PREDICTION_LABEL); feedbackLabelComboBox.addItem(SOMETHING_ELSE_PREDICTION_LABEL); - if (pred.getPredictionBreakdown() == null || pred.getPredictionBreakdown().size() == 0 - || (isNullConfidence && !config.showBreakdownOnNullConfidence())) + if (pred.getPredictionBreakdown() == null || pred.getPredictionBreakdown().size() == 0) { predictionBreakdownLabel.setText(EMPTY_LABEL); predictionBreakdownPanel.setVisible(false); @@ -1113,8 +1112,16 @@ public void setPrediction(Prediction pred, PlayerSighting sighting) } else { - predictionBreakdownLabel.setText(toPredictionBreakdownString(pred.getPredictionBreakdown())); - predictionBreakdownPanel.setVisible(true); + if (isNullConfidence && !config.showBreakdownOnNullConfidence()) + { + predictionBreakdownLabel.setText(EMPTY_LABEL); + predictionBreakdownPanel.setVisible(false); + } + else + { + predictionBreakdownLabel.setText(toPredictionBreakdownString(pred.getPredictionBreakdown())); + predictionBreakdownPanel.setVisible(true); + } final String primaryLabel = pred.getPredictionLabel(); @@ -1272,9 +1279,7 @@ else if (!isValidPlayerName(target)) setPrediction(null); - // Note: The showBreakdown parameter is redundant due to the null confidence checks added, but we're including it for now. - // If to be removed, ensure the API breakdown parameter is always true. - detectorClient.requestPrediction(target, config.showBreakdownOnNullConfidence()).whenCompleteAsync((pred, ex) -> + detectorClient.requestPrediction(target).whenCompleteAsync((pred, ex) -> SwingUtilities.invokeLater(() -> { if (!sanitize(searchBar.getText()).equals(target))