refactor: fix nullable params

This commit is contained in:
Breno A. 2024-06-09 10:26:58 -03:00
parent 3b68645330
commit d4ce7aac08
4 changed files with 279 additions and 384 deletions

View File

@ -231,6 +231,10 @@ public class Achievements {
});
var a = this.getAchievement(i);
if(a == null) {
Grasscutter.getLogger().warn("null returned while getting achievement!");
return;
}
a.setStatus(Status.STATUS_REWARD_TAKEN);
this.save();
this.sendUpdatePacket(a);

View File

@ -25,7 +25,7 @@ public class AllActivityConditionBuilder {
private Map<ActivityConditions, ActivityConditionBaseHandler> initActivityConditions() {
Reflections reflector = Grasscutter.reflector;
return reflector.getTypesAnnotatedWith(ActivityCondition.class).stream()
.map(this::newInstance)
.map(this::newInstance).filter(Objects::nonNull)
.map(h -> new AbstractMap.SimpleEntry<>(extractActionType(h), h))
.collect(
Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue));

File diff suppressed because it is too large Load Diff

View File

@ -347,7 +347,7 @@ public final class Language {
return Files.getLastModifiedTime(path).toMillis();
} catch (Exception ignored) {
Grasscutter.getLogger()
.debug("Exception while checking modified time: ", path);
.debug("Exception while checking modified time: {}", path);
return Long.MAX_VALUE; // Don't use cache, something has gone wrong
}
})