Skip to content

Commit

Permalink
chore: expose agones api count&list methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakShearman committed Aug 19, 2024
1 parent c6a4a68 commit 844abe4
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,30 +116,30 @@ private void loadAgones() {

private void loadAgonesCountsAndLists() {
MinecraftServer.getGlobalEventHandler().addListener(AsyncPlayerConfigurationEvent.class, event -> {
this.updateCounter("players", 1);
this.addToList("players", event.getPlayer().getUuid().toString());
this.updateAgonesCounter("players", 1);
this.addToAgonesList("players", event.getPlayer().getUuid().toString());
}).addListener(PlayerDisconnectEvent.class, event -> {
this.updateCounter("players", -1);
this.removeFromList("players", event.getPlayer().getUuid().toString());
this.updateAgonesCounter("players", -1);
this.removeFromAgonesList("players", event.getPlayer().getUuid().toString());
});
}

private void updateCounter(String name, long diff) {
public void updateAgonesCounter(String name, long diff) {
this.betaSdk.updateCounter(BetaAgonesSDKProto.UpdateCounterRequest.newBuilder()
.setCounterUpdateRequest(BetaAgonesSDKProto.CounterUpdateRequest.newBuilder()
.setName(name)
.setCountDiff(diff))
.build(), new IgnoredStreamObserver<>());
}

private void addToList(String listName, String value) {
public void addToAgonesList(String listName, String value) {
this.betaSdk.addListValue(BetaAgonesSDKProto.AddListValueRequest.newBuilder()
.setName(listName)
.setValue(value)
.build(), new IgnoredStreamObserver<>());
}

private void removeFromList(String listName, String value) {
public void removeFromAgonesList(String listName, String value) {
this.betaSdk.removeListValue(BetaAgonesSDKProto.RemoveListValueRequest.newBuilder()
.setName(listName)
.setValue(value)
Expand Down Expand Up @@ -178,7 +178,11 @@ private void readyAgones() {
return this.protoClient;
}

public @Nullable SDKGrpc.SDKStub getSdk() {
public @Nullable SDKGrpc.SDKStub getAgonesSdk() {
return this.sdk;
}

public @Nullable dev.agones.sdk.beta.SDKGrpc.SDKStub getAgonesBetaSdk() {
return this.betaSdk;
}
}

0 comments on commit 844abe4

Please sign in to comment.