Skip to content

Commit

Permalink
Throw proper error when a predicate is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Apr 22, 2024
1 parent 5069d53 commit 79f3e9c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion settings.gradle
Expand Up @@ -18,4 +18,4 @@ pluginManagement {
}
}

rootProject.name = 'blabber'
rootProject.name = 'blabber'
Expand Up @@ -135,9 +135,11 @@ public boolean hasConditions() {
for (Map.Entry<String, Int2BooleanMap> conditionalState : this.conditionalChoices.entrySet()) {
List<DialogueChoice> availableChoices = getStates().get(conditionalState.getKey()).choices();
for (Int2BooleanMap.Entry conditionalChoice : conditionalState.getValue().int2BooleanEntrySet()) {
Identifier predicateId = availableChoices.get(conditionalChoice.getIntKey()).condition().orElseThrow().predicate();
LootCondition condition = context.getWorld().getServer().getLootManager().getElement(
LootDataType.PREDICATES, availableChoices.get(conditionalChoice.getIntKey()).condition().orElseThrow().predicate()
LootDataType.PREDICATES, predicateId
);
if (condition == null) throw new IllegalStateException("Could not find predicate " + predicateId);
boolean testResult = runTest(condition, context);
if (testResult != conditionalChoice.setValue(testResult)) {
if (ret == null) ret = new ChoiceAvailabilityPacket();
Expand Down
Expand Up @@ -92,11 +92,6 @@ public static ValidationResult validateStructure(DialogueTemplate dialogue) {
}
}

// Verify that all illustrations are real. We're doing this here because this is a class and not a record
// So we have our own constructor.
for (Map.Entry<String, DialogueState> state : dialogue.states().entrySet()) {
}

return warnings.isEmpty() ? ValidationResult.success() : new ValidationResult.Warnings(warnings);
}

Expand Down

0 comments on commit 79f3e9c

Please sign in to comment.