Skip to content

Commit c5a6042

Browse files
committed
use EMPTY ActionApplier on RequirementSet
1 parent 885a122 commit c5a6042

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/me/hsgamer/bettergui/requirement/RequirementSet.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ public RequirementSet(Menu menu, String name, Map<String, Object> section) {
4040
}).collect(Collectors.toList());
4141

4242
Map<String, Object> keys = new CaseInsensitiveStringMap<>(section);
43-
this.successActionApplier = new ActionApplier(menu, MapUtils.getIfFoundOrDefault(keys, Collections.emptyList(), "success-command", "success-action"));
44-
this.failActionApplier = new ActionApplier(menu, MapUtils.getIfFoundOrDefault(keys, Collections.emptyList(), "fail-command", "fail-action"));
43+
this.successActionApplier = Optional.ofNullable(MapUtils.getIfFound(keys, "success-command", "success-action"))
44+
.map(o -> new ActionApplier(menu, o))
45+
.orElse(ActionApplier.EMPTY);
46+
this.failActionApplier = Optional.ofNullable(MapUtils.getIfFound(keys, "fail-command", "fail-action"))
47+
.map(o -> new ActionApplier(menu, o))
48+
.orElse(ActionApplier.EMPTY);
4549
}
4650

4751
/**

0 commit comments

Comments
 (0)