Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 00ce659

Browse files
committed
Added README
1 parent e7dbde4 commit 00ce659

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Badlion AntiCheat API
2+
3+
This repository explains how to use Badlion AntiCheat Api bundled in the BAC plugin.
4+
5+
You can purchase it at [https://store.badlion.net/category/bac/](https://store.badlion.net/category/bac/)
6+
7+
#### Maven dependency
8+
9+
1. Clone this repository
10+
2. Run `mvn clean install`
11+
3. Add the following code to your pom.xml file :
12+
```xml
13+
<dependency>
14+
<groupId>net.badlion.heartbeat</groupId>
15+
<artifactId>heartbeat-api</artifactId>
16+
<version>1.0-SNAPSHOT</version>
17+
<scope>provided</scope>
18+
</dependency>
19+
```
20+
21+
*/!\ Make sure to set it as provided or it won't be working properly.*
22+
23+
### API Usage
24+
25+
All the methods that you can use are documented [here](https://github.com/BadlionNetwork/BACPluginAPI/blob/master/src/main/java/net/badlion/heartbeatapi/HeartbeatApi.java).
26+
27+
### Plugin Message API
28+
29+
In case you are running the plugin on your BungeeCord proxy, and you want to know if an user is using Badlion Anticheat from your Bukkit server, you can use our plugin message API
30+
31+
```java
32+
public class BadlionAnticheatExample extends JavaPlugin implements Listener, PluginMessageListener {
33+
34+
@Override
35+
public void onEnable() {
36+
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
37+
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", this);
38+
this.getServer().getPluginManager().registerEvents(this, this);
39+
}
40+
41+
@EventHandler
42+
public void onLogin(final PlayerJoinEvent event) {
43+
this.getServer().getScheduler().runTaskLater(this, new Runnable() {
44+
@Override
45+
public void run() {
46+
47+
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
48+
DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
49+
50+
try {
51+
dataOutputStream.writeUTF("heartbeat");
52+
} catch (IOException ignored) {
53+
return;
54+
}
55+
56+
event.getPlayer().sendPluginMessage(BadlionAnticheatExample.this, "BungeeCord", byteArrayOutputStream.toByteArray());
57+
}
58+
}, 20L);
59+
}
60+
61+
@Override
62+
public void onPluginMessageReceived(String channel, Player player, byte[] bytes) {
63+
if (channel.equals("BungeeCord")) {
64+
DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(bytes));
65+
66+
try {
67+
if (dataInputStream.readUTF().equals("heartbeat")) {
68+
switch (dataInputStream.readUTF()) {
69+
case "true":
70+
// Your code here
71+
// User is using Badlion AntiCheat
72+
break;
73+
74+
case "false":
75+
// Your code here
76+
// User is not using Badlion AntiCheat
77+
break;
78+
}
79+
}
80+
} catch (IOException ignored) {
81+
82+
}
83+
}
84+
}
85+
}
86+
87+
```
88+

0 commit comments

Comments
 (0)