33import agones .dev .sdk .Sdk ;
44import agones .dev .sdk .alpha .Alpha ;
55import agones .dev .sdk .alpha .SDKGrpc ;
6+ import com .google .protobuf .FieldMask ;
67import io .grpc .ManagedChannel ;
78import io .grpc .stub .StreamObserver ;
89import lombok .AccessLevel ;
@@ -30,6 +31,29 @@ public final class AgonesAlphaSdk {
3031 this .stub = SDKGrpc .newStub (channel );
3132 }
3233
34+ /**
35+ * adds a value to a list and returns updated list. returns NOT_FOUND if the list does not exist. returns
36+ * ALREADY_EXISTS if the value is already in the list. returns OUT_OF_RANGE if the list is already at Capacity.
37+ *
38+ * @param name the name to add.
39+ * @param value the value to add.
40+ * @param observer the observer to add.
41+ */
42+ public void addList (
43+ @ NotNull final String name ,
44+ @ NotNull final String value ,
45+ @ NotNull final StreamObserver <Alpha .List > observer
46+ ) {
47+ this .stub .addListValue (
48+ Alpha .AddListValueRequest
49+ .newBuilder ()
50+ .setName (name )
51+ .setValue (value )
52+ .build (),
53+ observer
54+ );
55+ }
56+
3357 /**
3458 * returns the list of the currently connected player ids.
3559 * this is always accurate from what has been set through this SDK, even if the value has yet to be updated on the
@@ -46,6 +70,38 @@ public void getConnectedPlayers(
4670 this .stub .getConnectedPlayers (Alpha .Empty .getDefaultInstance (), observer );
4771 }
4872
73+ /**
74+ * gets a counter. returns NOT_FOUND if the counter does not exist.
75+ *
76+ * @param name the name of the counter.
77+ * @param observer the observer to get counter.
78+ */
79+ public void getCounter (
80+ @ NotNull final String name ,
81+ @ NotNull final StreamObserver <Alpha .Counter > observer
82+ ) {
83+ this .stub .getCounter (
84+ Alpha .GetCounterRequest .newBuilder ().setName (name ).build (),
85+ observer
86+ );
87+ }
88+
89+ /**
90+ * gets a list. returns NOT_FOUND if the List does not exist.
91+ *
92+ * @param name the name to get.
93+ * @param observer the observer to get.
94+ */
95+ public void getList (
96+ @ NotNull final String name ,
97+ @ NotNull final StreamObserver <Alpha .List > observer
98+ ) {
99+ this .stub .getList (
100+ Alpha .GetListRequest .newBuilder ().setName (name ).build (),
101+ observer
102+ );
103+ }
104+
49105 /**
50106 * retrieves the current player capacity.
51107 * this is always accurate from what has been set through this SDK, even if the value has yet to be updated on the
@@ -225,6 +281,29 @@ public void playerDisconnect(
225281 );
226282 }
227283
284+ /**
285+ * removes a value from a list and returns updated list. returns NOT_FOUND if the list does not exist. returns
286+ * NOT_FOUND if the value is not in the list.
287+ *
288+ * @param name the name to remove.
289+ * @param value the value to remove.
290+ * @param observer the observer to add.
291+ */
292+ public void removeList (
293+ @ NotNull final String name ,
294+ @ NotNull final String value ,
295+ @ NotNull final StreamObserver <Alpha .List > observer
296+ ) {
297+ this .stub .removeListValue (
298+ Alpha .RemoveListValueRequest
299+ .newBuilder ()
300+ .setName (name )
301+ .setValue (value )
302+ .build (),
303+ observer
304+ );
305+ }
306+
228307 /**
229308 * update the {@link Sdk.GameServer.Status.PlayerStatus#getCapacity()} value with a new capacity.
230309 *
@@ -237,4 +316,54 @@ public void setPlayerCapacity(
237316 ) {
238317 this .stub .setPlayerCapacity (capacity , observer );
239318 }
319+
320+ /**
321+ * returns the updated counter. returns NOT_FOUND if the counter does not exist (name cannot be updated). returns
322+ * OUT_OF_RANGE if the count is out of range [0,Capacity]. returns INVALID_ARGUMENT if the field mask path(s) are not
323+ * field(s) of the counter. if a field mask path(s) is specified, but the value is not set in the request counter
324+ * object, then the default value for the variable will be set (i.e. 0 for "capacity" or "count").
325+ *
326+ * @param counter the counter to update.
327+ * @param updateMask the update mask to update.
328+ * @param observer the observer to update.
329+ */
330+ public void updateCounter (
331+ @ NotNull final Alpha .Counter counter ,
332+ @ NotNull final FieldMask updateMask ,
333+ @ NotNull final StreamObserver <Alpha .Counter > observer
334+ ) {
335+ this .stub .updateCounter (
336+ Alpha .UpdateCounterRequest
337+ .newBuilder ()
338+ .setCounter (counter )
339+ .setUpdateMask (updateMask )
340+ .build (),
341+ observer
342+ );
343+ }
344+
345+ /**
346+ * returns the updated list. returns NOT_FOUND if the list does not exist (name cannot be updated).
347+ * <p>
348+ * **THIS WILL OVERWRITE ALL EXISTING LIST.VALUES WITH ANY REQUEST LIST.VALUES**
349+ * <p>
350+ * use addListValue() or removeListValue() for modifying the List.Values field.
351+ * returns INVALID_ARGUMENT if the field mask path(s) are not field(s) of the list.
352+ *
353+ * @param observer the observer to update.
354+ */
355+ public void updateList (
356+ @ NotNull final Alpha .List list ,
357+ @ NotNull final FieldMask updateMask ,
358+ @ NotNull final StreamObserver <Alpha .List > observer
359+ ) {
360+ this .stub .updateList (
361+ Alpha .UpdateListRequest
362+ .newBuilder ()
363+ .setList (list )
364+ .setUpdateMask (updateMask )
365+ .build (),
366+ observer
367+ );
368+ }
240369}
0 commit comments