File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
ocraft-s2client-protocol/src/main/java/com/github/ocraft/s2client/protocol/response Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 37
37
38
38
import java .util .Collections ;
39
39
import java .util .List ;
40
+ import java .util .function .Predicate ;
40
41
41
42
import static com .github .ocraft .s2client .protocol .DataExtractor .tryGet ;
42
43
import static com .github .ocraft .s2client .protocol .Errors .required ;
@@ -58,7 +59,7 @@ private ResponseObservation(Sc2Api.ResponseObservation sc2ApiResponseObservation
58
59
super (ResponseType .OBSERVATION , GameStatus .from (status ));
59
60
60
61
this .actions = sc2ApiResponseObservation .getActionsList ().stream ()
61
- .filter (a -> a . getSerializedSize () > 0 ).map (Action ::from )
62
+ .filter (actionIsValid () ).map (Action ::from )
62
63
.collect (collectingAndThen (toList (), Collections ::unmodifiableList ));
63
64
64
65
this .actionErrors = sc2ApiResponseObservation .getActionErrorsList ().stream ()
@@ -74,6 +75,15 @@ private ResponseObservation(Sc2Api.ResponseObservation sc2ApiResponseObservation
74
75
.collect (collectingAndThen (toList (), Collections ::unmodifiableList ));
75
76
}
76
77
78
+ private Predicate <Sc2Api .Action > actionIsValid () {
79
+ return a -> a .getSerializedSize () > 0 && (
80
+ a .hasActionRaw () ||
81
+ a .hasActionChat () ||
82
+ a .hasActionFeatureLayer () ||
83
+ a .hasActionRender () ||
84
+ a .hasActionUi ());
85
+ }
86
+
77
87
public static ResponseObservation from (Sc2Api .Response sc2ApiResponse ) {
78
88
if (!hasObservationResponse (sc2ApiResponse )) {
79
89
throw new IllegalArgumentException ("provided argument doesn't have observation response" );
You can’t perform that action at this time.
0 commit comments