mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-29 12:37:40 +01:00
Catch exceptions thrown by context calculators
This commit is contained in:
parent
9d780ae24a
commit
99c6fe20c2
@ -48,7 +48,12 @@ public class ContextManager<T> {
|
||||
|
||||
private MutableContextSet calculateApplicableContext(T subject, MutableContextSet accumulator) {
|
||||
for (ContextCalculator<T> calculator : calculators) {
|
||||
calculator.giveApplicableContext(subject, accumulator);
|
||||
try {
|
||||
calculator.giveApplicableContext(subject, accumulator);
|
||||
} catch (Exception e) {
|
||||
new RuntimeException("Exception thrown by ContextCalculator: " + calculator.getClass().getName(), e).printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
|
@ -39,14 +39,19 @@ import java.util.Set;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class SpongeCalculatorLink implements ContextCalculator<Subject> {
|
||||
private final org.spongepowered.api.service.context.ContextCalculator<Subject> calculator;
|
||||
private final org.spongepowered.api.service.context.ContextCalculator<Subject> delegate;
|
||||
|
||||
@Override
|
||||
public MutableContextSet giveApplicableContext(Subject subject, MutableContextSet accumulator) {
|
||||
Set<Context> contexts = new HashSet<>();
|
||||
calculator.accumulateContexts(subject, contexts);
|
||||
|
||||
accumulator.addAll(CompatibilityUtil.convertContexts(contexts));
|
||||
try {
|
||||
delegate.accumulateContexts(subject, contexts);
|
||||
accumulator.addAll(CompatibilityUtil.convertContexts(contexts));
|
||||
} catch (Exception e) {
|
||||
new RuntimeException("Exception thrown by delegate Sponge calculator: " + delegate.getClass().getName(), e).printStackTrace();
|
||||
}
|
||||
|
||||
return accumulator;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user