-
Notifications
You must be signed in to change notification settings - Fork 0
How to use the AliceAPI (Making a custom check)
Nik edited this page Jan 16, 2021
·
4 revisions
For this example, we'll be making a very basic BadPackets Check
First, let's make a class that implements listener
public class CustomCheck implements Listener {
@EventHandler
public void onMoveEvent(final PlayerMoveEvent e) {
}
}
Perfect, First let's check if the player's pitch goes above 90.0 which is impossible in Vanilla
@EventHandler
public void onMoveEvent(final PlayerMoveEvent e) {
final float pitch = Math.abs(e.getTo().getPitch());
if (pitch > 90.0F) {
//TODO: Flag
}
}
In order to flag, First we need to get the API Instance
AliceAPI api = AliceAPIProvider.getAPI();
Now let's flag the player for "BadPackets" and add a small verbose message
public class CustomCheck implements Listener {
@EventHandler
public void onMoveEvent(final PlayerMoveEvent e) {
final float pitch = Math.abs(e.getTo().getPitch());
if (pitch > 90.0F) {
AliceAPI api = AliceAPIProvider.getAPI();
api.flag(e.getPlayer(), "BadPackets", "Pitch: " + pitch);
}
}
}
Perfect, now let's go in-game and try to go above 90.0
As you can see, our check works perfectly, And we flagged for BadPackets A If the check that you want to flag for has different modules, such as A, B, C. The flag method will always flag for the first module it finds Alternatively you can define the module's name