diff --git a/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapper.java b/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapper.java index 9b834eb5c..b6ec278d9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapper.java +++ b/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapper.java @@ -84,6 +84,11 @@ T invoke(String s, Object... args) { return Objects.requireNonNull(t.getValue(), "Object napper result must contain a non-null value!"); } + T invokeDefault() { + Result t = this.defaultValue.get(); + return t == null || t.hasError() ? null : t.getValue(); + } + public GroovyContainer getMod() { return mod; } @@ -114,6 +119,10 @@ public T doCall(String s, Object... args) { return invoke(s, args); } + public T doCall() { + return invokeDefault(); + } + @Override public String getDocumentation() { return documentation;