1. Docs
  2. /
  3. BanManager
  4. /
  5. API

API

BanManager hs a developer API allowing other plugins to read and modify punishment data

Versioning

The API uses Semantic Versioning, meaning whenever a non-backwards compatible change is made, the major version will increment. You can rest assured knowing your integration will not break between releases, providing the major version remains the same.


Add BanManager to your project

Artifacts are published to the Frostcast CI repository

Maven

Add the following to your POM:

<repositories>
  <repository>
    <id>confuser-repo</id>
    <url>https://ci.frostcast.net/plugin/repository/everything</url>
  </repository>
</repositories>

To make use of BanManager's API, simply add the relevant build as a Maven dependency to your project. For access to BmAPI only, please use BanManagerCommon. For anything else, use the server implementation specific build.

BanManagerCommon

<dependencies>
  <dependency>
    <groupId>me.confuser.banmanager</groupId>
    <artifactId>BanManagerCommon</artifactId>
    <version>7.7.0-SNAPSHOT</version>
    <scope>provided</scope>
  </dependency>
</dependencies>

Bukkit

<dependencies>
  <dependency>
    <groupId>me.confuser.banmanager</groupId>
    <artifactId>BanManagerBukkit</artifactId>
    <version>7.7.0-SNAPSHOT</version>
    <scope>provided</scope>
  </dependency>
</dependencies>

BungeeCord

<dependencies>
  <dependency>
    <groupId>me.confuser.banmanager</groupId>
    <artifactId>BanManagerBungeeCord</artifactId>
    <version>7.7.0-SNAPSHOT</version>
    <scope>provided</scope>
  </dependency>
</dependencies>

Sponge

<dependencies>
  <dependency>
    <groupId>me.confuser.banmanager</groupId>
    <artifactId>BanManagerSponge</artifactId>
    <version>7.7.0-SNAPSHOT</version>
    <scope>provided</scope>
  </dependency>
</dependencies>

BmAPI

This is a static API class for BanManager to create and manipulate punishments.

Caveats:

  • Unless a method is marked as thread safe, ensure they are always executed asynchronously to avoid causing server lag (by blocking the main Minecraft Server thread)
  • The API does not check permissions for exemptions like commands do

A list of methods are available at the javadocs.

Events

Provides a way to listen to punishment changes, e.g. when a player is banned or unbanned. Each event contains the punishment reason, actor (who caused the event) and the player or ip it affects.

A server specific build is required to access these, e.g. BanManagerBukkit.

Events in the present tense can be cancelled, e.g. PlayerMuteEvent, whereas events in the past tense cannot e.g. PlayerMutedEvent.

These events are used internally by BanManager and are triggered asynchronously.

The following events are supported:

  • IpBanEvent
  • IpBannedEvent
  • IpMuteEvent
  • IpMutedEvent
  • IpRangeBanEvent
  • IpRangeBannedEvent
  • IpRangeUnbanEvent
  • IpUnbanEvent
  • IpUnmutedEvent
  • NameBanEvent
  • NameBannedEvent
  • NameUnbanEvent
  • PlayerBanEvent
  • PlayerBannedEvent
  • PlayerDeniedEvent
  • PlayerKickedEvent
  • PlayerMuteEvent
  • PlayerMutedEvent
  • PlayerNoteCreatedEvent
  • PlayerReportDeletedEvent
  • PlayerReportEvent
  • PlayerReportedEvent
  • PlayerUnbanEvent
  • PlayerUnmuteEvent
  • PlayerWarnEvent
  • PlayerWarnedEvent
  • PluginReloadedEvent

Examples

Bukkit

import me.confuser.banmanager.bukkit.api.events.PlayerBannedEvent;

public class BanListener implements Listener {
  @EventHandler
  public void notifyOnBan(PlayerBannedEvent event) {
    PlayerBanData ban = event.getBan();

    if (!event.isSilent()) {
      Bukkit.broadcast(ban.getPlayer().getName() + " has been banned!");
    }
  }
}

Sponge

import me.confuser.banmanager.sponge.api.events.PlayerBannedEvent;

public class BanListener {
  @Listener(order = Order.POST)
  public void notifyOnBan(PlayerBannedEvent event) {
    PlayerBanData ban = event.getBan();

    if (!event.isSilent()) {
      Sponge.getServer().getConsole().sendMessage(Text.of(ban.getPlayer().getName() + " has been banned!"));
    }
  }
}

About

  • by James Mortemore © 2012 - 2024