-
-
Notifications
You must be signed in to change notification settings - Fork 50
AntiCheats
In this section we're going over handling multiple anti cheat modes.
This part is very important. You need to specify what anticheats your module is supposed to work for. You can do so in your module constructor. You can add as many anticheats as you want at the end of your constructor, it's varargs so, basically, an array.
public AntiCheatExample() {
super("AntiCheats", "This module demonstrates how to use different anticheats", Keyboard.VK_F, Category.MOVEMENT, AntiCheat.VANILLA, AntiCheat.AAC, AntiCheat.VENOM);
}
The first anticheat specified is the default one.
Once you're done defining the anticheats you can start dividing your code. Don't get too attached to this method, though, because a new one is coming soon.
The current anticheat is defined in a protected variable inside of the Module class, which means you can just access anytime (can also be accessed from the outside through the method #getAntiCheat()
).
You can use some if-statements around or use a switch, depending on your needs. Here is an example:
switch(antiCheat) {
default:
case VANILLA: {
Player.sendMessage("You are currently using the Vanilla AntiCheat");
break;
}
case AAC: {
Player.sendMessage("You are currently using the AAC AntiCheat");
break;
}
case VENOM: {
Player.sendMessage("You are currently using the Venom AntiCheat");
break;
}
}
You can use this inside of the onUpdate, onPreMotion or even in the onRender3D! You can use it pretty much everywhere you need it.
You can switch your module's anticheat programmatically with module.setAntiCheat(AntiCheat.). You can also use the tabgui, clickgui, or the set command, in-game.
You can look at this gist to see what the final class would look like.