Developer API

You can use the API to integrate Grim into your plugin. The source code can be found on the github. You can find the latest API version on jitpack.

Getting Started

Kotlin
maven("https://jitpack.io/") {
        content {
            includeGroup("com.github.grimanticheat")
        }
    }

 

Kotlin
dependencies {
    compileOnly("com.github.grimanticheat:grimapi:VERSION") // replace this with actual version
}
XML
<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io/</url>
</repository>

 

XML
<dependency>
    <groupId>com.github.grimanticheat</groupId>
    <artifactId>grimapi</artifactId>
    <version>VERSION</version><!-- replace this with the actual version -->
</dependency>

Ensure that your plugin depends on GrimAC in your plugin.yml.

yaml
softdepend:
  - GrimAC

You can retrieve an instance of the API implementation using Bukkit’s service provider whenever your plugin starts.

Java
if (Bukkit.getPluginManager().isPluginEnabled("GrimAC")) {
            RegisteredServiceProvider<GrimAbstractAPI> provider = Bukkit.getServicesManager().getRegistration(GrimAbstractAPI.class);
            if (provider != null) {
                GrimAbstractAPI api = provider.getProvider();
            }
        }

Bukkit Events

A list of grim bukkit events can be found on the github. Here’s an example of how you can print to console when a player flags a checks.

Java
@EventHandler
    public void onGrimFlag(FlagEvent event) {
        GrimUser user = event.getPlayer();
        AbstractCheck check = event.getCheck();
        Bukkit.getConsoleSender().sendMessage(user.getName() + " flagged check " + check.getCheckName());
    }

Registering Variables

You can use the API to register variables you can use within the configuration files of Grim.

Java
// get a instance of the API
GrimAbstractAPI api = getInstance();

// registers a variable based on the user
api.registerVariable("%keep_alive_ping%", user -> user.getKeepAlivePing() + "");

// registers a static variable
api.registerVariable("%server%", user -> "Server Name");