API - Nutty101/NPC-Police GitHub Wiki

NPC Police has an API that allows you to customize and interact with the plugin. Below is a quick sample of getting a plugin working with the program:

This follows modifying the basic Spigot Plugin Example.

package com.meeku.tutorialPlugin;   
   
import org.bukkit.entity.Player;   
import org.bukkit.event.EventHandler;   
import org.bukkit.plugin.java.JavaPlugin;   
   
import net.livecar.nuttyworks.npc_police.api.events.BountyChangedEvent;   
import net.livecar.nuttyworks.npc_police.api.events.StatusChangedEvent;   
import net.livecar.nuttyworks.npc_police.api.managers.PlayerManager;   
   
public class SpigotBlankPlugin extends JavaPlugin {   
    
    // Fired when plugin is first enabled
    @Override
    public void onEnable() {
        // Do whatever code you need done here
        if (getServer().getPluginManager().getPlugin("NPC_Police") != null) {
            // Plugin Exists, Do something
        }
    }

    // Fired when a player changes wanted status
    @EventHandler
    public void onStatusChanged(StatusChangedEvent event) {

        Player plr = (Player) event.getPlayer();
        PlayerManager plrMgr = event.getPlayerManager();
        plr.sendMessage("You went from " + plrMgr.getPriorStatus().toString() + " to " + plrMgr.getCurrentStatus().toString());
        
    }
    
    @EventHandler
    public void onBountyChanged(BountyChangedEvent event) {

        Player plr = (Player) event.getPlayer();
        PlayerManager plrMgr = event.getPlayerManager();
        //clear the players bounty
        plrMgr.clearBounty();
        plr.sendMessage("Your bounty was going to increase by " + String.valueOf(event.getBounty()) + ", but i'm letting you off.");
        
    }   
    
}