Skip to content

Commit df4104a

Browse files
committed
Added banning API call
1 parent a241237 commit df4104a

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<groupId>com.github.anthill-platform</groupId>
1111
<artifactId>anthill-runtime-java</artifactId>
1212
<packaging>jar</packaging>
13-
<version>0.2.1</version>
13+
<version>0.2.2</version>
1414

1515
<name>Anthill Java Runtime</name>
1616
<description>Java Runtime for Anthill Platform</description>

src/org/anthillplatform/runtime/services/GameService.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.anthillplatform.runtime.requests.JsonRequest;
66
import org.anthillplatform.runtime.requests.Request;
77
import org.anthillplatform.runtime.util.JsonRPC;
8+
import org.anthillplatform.runtime.util.Utils;
89
import org.anthillplatform.runtime.util.WebSocketJsonRPC;
910
import org.java_websocket.handshake.ServerHandshake;
1011
import org.json.JSONArray;
@@ -85,6 +86,12 @@ public JoinMultiWrapper(LoginService.AccessToken accessToken, String ip)
8586
}
8687
}
8788

89+
public interface IssueBanCallback
90+
{
91+
void result(GameService service, Request request, Request.Result result);
92+
}
93+
94+
8895
public static class PartyMember
8996
{
9097
private String account;
@@ -1568,4 +1575,33 @@ public PartySession openExistingPartySession(
15681575

15691576
return partySession;
15701577
}
1578+
1579+
public void issueABan(
1580+
LoginService.AccessToken accessToken,
1581+
String account,
1582+
Date expires,
1583+
String reason,
1584+
IssueBanCallback callback)
1585+
{
1586+
JsonRequest jsonRequest = new JsonRequest(getLocation() + "/ban/issue",
1587+
new Request.RequestCallback()
1588+
{
1589+
@Override
1590+
public void complete(Request request, Request.Result result)
1591+
{
1592+
callback.result(GameService.this, request, result);
1593+
}
1594+
});
1595+
1596+
Request.Fields fields = new Request.Fields();
1597+
1598+
fields.put("account", account);
1599+
fields.put("reason", reason);
1600+
fields.put("expires", Utils.DATE_FORMAT.format(expires));
1601+
1602+
jsonRequest.setAPIVersion(getAPIVersion());
1603+
jsonRequest.setToken(accessToken);
1604+
jsonRequest.post(fields);
1605+
1606+
}
15711607
}

0 commit comments

Comments
 (0)