├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src └── main └── java └── net └── badlion └── heartbeatapi ├── HeartbeatApi.java └── event ├── bukkit ├── BacBanEvent.java └── BacKickEvent.java ├── bungee ├── BacBanEvent.java └── BacKickEvent.java └── velocity ├── BacBanEvent.java └── BacKickEvent.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea/ 3 | target/ 4 | .project 5 | .classpath -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018-2020 ESL Gaming Online, Inc 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 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 | 14 | net.badlion.heartbeat 15 | heartbeat-api 16 | 1.0-SNAPSHOT 17 | provided 18 | 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 | 89 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | net.badlion.heartbeat 8 | heartbeat-api 9 | 1.0-SNAPSHOT 10 | 11 | jar 12 | 13 | HeartbeatApi 14 | 15 | 16 | UTF-8 17 | 18 | 19 | 20 | 21 | bungeecord-repo 22 | https://oss.sonatype.org/content/repositories/snapshots 23 | 24 | 25 | 26 | spigot-repo 27 | https://hub.spigotmc.org/nexus/content/repositories/snapshots/ 28 | 29 | 30 | 31 | 32 | 33 | net.md-5 34 | bungeecord-api 35 | 1.12-SNAPSHOT 36 | jar 37 | provided 38 | 39 | 40 | 41 | net.md-5 42 | bungeecord-api 43 | 1.12-SNAPSHOT 44 | javadoc 45 | provided 46 | 47 | 48 | 49 | org.spigotmc 50 | spigot-api 51 | 1.12.2-R0.1-SNAPSHOT 52 | provided 53 | 54 | 55 | 56 | org.bukkit 57 | bukkit 58 | 1.12.2-R0.1-SNAPSHOT 59 | provided 60 | 61 | 62 | 63 | 64 | 65 | 66 | org.apache.maven.plugins 67 | maven-compiler-plugin 68 | 3.8.1 69 | 70 | 1.7 71 | 1.7 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/main/java/net/badlion/heartbeatapi/HeartbeatApi.java: -------------------------------------------------------------------------------- 1 | package net.badlion.heartbeatapi; 2 | 3 | import java.util.Collection; 4 | import java.util.UUID; 5 | 6 | public abstract class HeartbeatApi { 7 | protected static HeartbeatApi instance; 8 | 9 | /** 10 | * Get the api instance 11 | * Must be called after the Badlion Heartbeat plugin is initialized 12 | * 13 | * @return A singleton instance of the api 14 | */ 15 | public static HeartbeatApi getInstance() { 16 | return HeartbeatApi.instance; 17 | } 18 | 19 | /** 20 | * Returns {@code true} if a player is using Badlion Anti-Cheat 21 | * 22 | * @param uuid UUID of player to check 23 | * @return {@code true} if using Badlion Anti-Cheat 24 | */ 25 | public abstract boolean isPlayerUsingBadlionAnticheat(UUID uuid); 26 | 27 | /** 28 | * Get if BAC-only mode is enabled 29 | * 30 | * @return {@code true} if BAC-only mode is enabled 31 | */ 32 | public abstract boolean isBacOnly(); 33 | 34 | /** 35 | * Enable or disable BAC-only mode (disabled by default) 36 | * If enabled, player will need to use Badlion-Anticheat to log in the server 37 | * Enabling this option while players are on will not kick them out of the network 38 | * We recommend calling this method as quickly as you can in your plugin(s). 39 | * This setting will be stored in the config to persist if the server restarts. 40 | * 41 | * @param enabled New state for the BAC-only mode 42 | */ 43 | public abstract void setBacOnly(boolean enabled); 44 | 45 | /** 46 | * Add a player to the whitelist 47 | * That player will be able to connect even if BAC-only mode is enabled and he is not using Badlion Anti-Cheat 48 | * This whitelist will be stored in the config to persist if the server restarts. 49 | * 50 | * @param uuid UUID of player to add 51 | */ 52 | public abstract void addPlayerToWhitelist(UUID uuid); 53 | 54 | /** 55 | * Remove a player from the whitelist 56 | * 57 | * @param uuid UUID of player to remove 58 | */ 59 | public abstract void removePlayerFromWhitelist(UUID uuid); 60 | 61 | /** 62 | * Get the whitelisted players who can bypass the BAC-only mode 63 | * 64 | * @return Collection of uuids 65 | */ 66 | public abstract Collection getWhitelistedPlayers(); 67 | 68 | /** 69 | * This is a Bungeecord feature 70 | * Get the server names where BAC is required on. 71 | * This means that each server in this list requires users to have BAC enabled to be able to join 72 | * Supports regex as well 73 | * 74 | * @return Collection of server names 75 | */ 76 | public abstract Collection getBacRequiredServers(); 77 | 78 | /** 79 | * This is a Bungeecord feature 80 | * Adds a server from the BAC required server list 81 | * 82 | * @param serverName Server name of server to add 83 | */ 84 | public abstract void addServerToRequiredServers(String serverName); 85 | 86 | /** 87 | * This is a Bungeecord feature 88 | * Removes a server from the BAC required server list 89 | * 90 | * @param serverName Server name of server to remove 91 | */ 92 | public abstract void removeServerToRequiredServers(String serverName); 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/net/badlion/heartbeatapi/event/bukkit/BacBanEvent.java: -------------------------------------------------------------------------------- 1 | package net.badlion.heartbeatapi.event.bukkit; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.event.HandlerList; 5 | 6 | import java.util.UUID; 7 | 8 | /** 9 | * Is thrown when a player is banned by Badlion AntiCheat. 10 | * Contains the UUID of the player. {@link BacBanEvent#getUniqueId()} 11 | * 12 | * Note : He is maybe not online when this event is thrown. 13 | */ 14 | public class BacBanEvent extends Event { 15 | private static final HandlerList handlers = new HandlerList(); 16 | 17 | private final UUID uniqueId; 18 | 19 | public BacBanEvent(UUID uniqueId) { 20 | this.uniqueId = uniqueId; 21 | } 22 | 23 | @SuppressWarnings("unused") 24 | public static HandlerList getHandlerList() { 25 | return BacBanEvent.handlers; 26 | } 27 | 28 | public UUID getUniqueId() { 29 | return this.uniqueId; 30 | } 31 | 32 | @Override 33 | public HandlerList getHandlers() { 34 | return BacBanEvent.handlers; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/badlion/heartbeatapi/event/bukkit/BacKickEvent.java: -------------------------------------------------------------------------------- 1 | package net.badlion.heartbeatapi.event.bukkit; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.event.HandlerList; 5 | 6 | import java.util.UUID; 7 | 8 | /** 9 | * Is thrown when a player is kicked by Badlion AntiCheat (for auth errors or cheating). 10 | * Contains the UUID of the player. {@link BacKickEvent#getUniqueId()} 11 | * 12 | * Note : He is maybe not online anymore when this event is thrown. 13 | */ 14 | public class BacKickEvent extends Event { 15 | private static final HandlerList handlers = new HandlerList(); 16 | 17 | private final UUID uniqueId; 18 | 19 | public BacKickEvent(UUID uniqueId) { 20 | this.uniqueId = uniqueId; 21 | } 22 | 23 | @SuppressWarnings("unused") 24 | public static HandlerList getHandlerList() { 25 | return BacKickEvent.handlers; 26 | } 27 | 28 | public UUID getUniqueId() { 29 | return this.uniqueId; 30 | } 31 | 32 | @Override 33 | public HandlerList getHandlers() { 34 | return BacKickEvent.handlers; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/badlion/heartbeatapi/event/bungee/BacBanEvent.java: -------------------------------------------------------------------------------- 1 | package net.badlion.heartbeatapi.event.bungee; 2 | 3 | import net.md_5.bungee.api.Callback; 4 | import net.md_5.bungee.api.event.AsyncEvent; 5 | 6 | import java.util.UUID; 7 | 8 | /** 9 | * Is thrown when a player is banned by Badlion AntiCheat. 10 | * Contains the UUID of the player. {@link BacBanEvent#getUniqueId()} 11 | * 12 | * Note : He is maybe not online when this event is thrown. 13 | */ 14 | public class BacBanEvent extends AsyncEvent { 15 | 16 | private final UUID uniqueId; 17 | 18 | public BacBanEvent(Callback done, UUID uniqueId) { 19 | super(done); 20 | 21 | this.uniqueId = uniqueId; 22 | } 23 | 24 | public UUID getUniqueId() { 25 | return this.uniqueId; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/net/badlion/heartbeatapi/event/bungee/BacKickEvent.java: -------------------------------------------------------------------------------- 1 | package net.badlion.heartbeatapi.event.bungee; 2 | 3 | import net.md_5.bungee.api.Callback; 4 | import net.md_5.bungee.api.event.AsyncEvent; 5 | 6 | import java.util.UUID; 7 | 8 | /** 9 | * Is thrown when a player is kicked by Badlion AntiCheat (for auth errors or cheating). 10 | * Contains the UUID of the player. {@link BacKickEvent#getUniqueId()} 11 | * 12 | * Note : He is maybe not online anymore when this event is thrown. 13 | */ 14 | public class BacKickEvent extends AsyncEvent { 15 | private final UUID uniqueId; 16 | 17 | public BacKickEvent(Callback done, UUID uniqueId) { 18 | super(done); 19 | 20 | this.uniqueId = uniqueId; 21 | } 22 | 23 | public UUID getUniqueId() { 24 | return this.uniqueId; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/net/badlion/heartbeatapi/event/velocity/BacBanEvent.java: -------------------------------------------------------------------------------- 1 | package net.badlion.heartbeatapi.event.velocity; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Is thrown when a player is banned by Badlion AntiCheat. 7 | * Contains the UUID of the player. {@link BacBanEvent#getUniqueId()} 8 | * 9 | * Note : He is maybe not online when this event is thrown. 10 | */ 11 | public class BacBanEvent { 12 | private final UUID uniqueId; 13 | 14 | public BacBanEvent(UUID uniqueId) { 15 | this.uniqueId = uniqueId; 16 | } 17 | 18 | public UUID getUniqueId() { 19 | return this.uniqueId; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/net/badlion/heartbeatapi/event/velocity/BacKickEvent.java: -------------------------------------------------------------------------------- 1 | package net.badlion.heartbeatapi.event.velocity; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Is thrown when a player is kicked by Badlion AntiCheat (for auth errors or cheating). 7 | * Contains the UUID of the player. {@link BacKickEvent#getUniqueId()} 8 | * 9 | * Note : He is maybe not online anymore when this event is thrown. 10 | */ 11 | public class BacKickEvent { 12 | private final UUID uniqueId; 13 | 14 | public BacKickEvent(UUID uniqueId) { 15 | this.uniqueId = uniqueId; 16 | } 17 | 18 | public UUID getUniqueId() { 19 | return this.uniqueId; 20 | } 21 | } 22 | --------------------------------------------------------------------------------